Open ljkitt opened 9 months ago
@ljkitt I Think You have Misunderstanding to use Qpy's Load and Dump with with qasm3 load and dump thing and that's why your code shows error. QPY and Qasm3 are different components of Qiskit.
Here is your Modified Code
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit.circuit.library.standard_gates import *
qr = QuantumRegister(1, name='qr')
cr = ClassicalRegister(1, name='cr')
qc = QuantumCircuit(qr, cr, name='qc')
qc.measure(qr, cr)
from qiskit.providers.fake_provider import FakeGuadalupeV2
from qiskit import transpile
backend = FakeGuadalupeV2()
qc = transpile(qc, backend=backend, basis_gates=None, optimization_level=2, coupling_map=None)
from qiskit.qasm3 import dumps
dumps(qc)
from qiskit import qpy
with open('tmp.qpy', 'wb') as fd:
qpy.dump(qc, fd)
with open('tmp.qpy', 'rb') as fd:
new_qc = qpy.load(fd)[0]
Here is the documentation of QPY And Qasm3 https://docs.quantum.ibm.com/api/qiskit/qpy https://docs.quantum.ibm.com/build/interoperate-qiskit-qasm3
I Hope it helps
I Hope It Helps
Environment
What is happening?
Creating a circuit and transpiling it with a coupling map or using a backend, then having a roundtrip conversion with Qasm3, and finally converting to Qpy, results in a KeyError, for example:
How can we reproduce the issue?
Run the following:
What should happen?
The program should be able to dump qpy from the circuit without error.
Any suggestions?
No response