-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qiskit.qasm3.loads( ) loses qubit mapping #11480
Comments
Brining in the minimal reproducer inline (it's helpful if all the context is in the issue, and using as few additional libraries as possible): from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeWashington
import qiskit.qasm3
backend = FakeWashington()
qc = QuantumCircuit(4)
qc.h(0)
for i in range(1, 4):
qc.cx(0, i)
qc.measure_all()
transpiled = transpile(qc, backend=backend, optimization_level=3, seed_transpiler=111)
roundtrip = qiskit.qasm3.loads(qiskit.qasm3.dumps(transpiled)) Now the result of drawing transpiled.draw(idle_wires=False)
roundtrip.draw(idle_wires=False)
However, the OQ3 import actually has brought in the physical-qubit layout information in some form: roundtrip.layout
There are two problems with this at the moment:
I suspect the most reasonable solution to this will be for the Qiskit |
I believe that the majority of this issue should have been fixed by Qiskit/qiskit-qasm3-import#30. The handling isn't entirely perfect (the drawer visualisation still is awkward, for example), but the physical qubit numbers are now certainly round-tripped. I'll close this as "complete" for now, but feel free to re-open if there's more to discuss. |
Environment
Python 3.10.12
openqasm3 0.5.0
qiskit-qasm3-import 0.4.1
pytket-qiskit 0.46.0
qiskit 0.45.1
qiskit-aer 0.13.1
qiskit-algorithms 0.2.1
qiskit-dynamics 0.4.2
qiskit-experiments 0.5.4
qiskit-ibm-experiment 0.3.5
qiskit-ibm-provider 0.7.2
qiskit-ibm-runtime 0.17.0
qiskit-terra 0.45.1
What is happening?
When a simple circuit, like GHZ, is transpiled for a backend, next saved as Qasm3,
the qiskit.qasm3.loads( .) forgets the qubit mapping assigned by the transpiler and counts qubits from 0 to N-1. Such a read-in circuit would not run on the HW properly.
How can we reproduce the issue?
Run this reproducer:
https://bitbucket.org/balewski/quantummind/src/master/Qiskit/issues/issue27b_qasm3_IO.py
It executes 3 commands:
And shows qcT uses qubits IDs ~100, but qc2 drops ids to be 0-3
What should happen?
Both circuits: qcT and qc2 should use the same qubits
Any suggestions?
No response
The text was updated successfully, but these errors were encountered: