You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I should be able to use qiskit.qasm3.dump or qiskit.qasm3.dumps on a dynamic circuit. However, for a teleportation circuit it throws an error
fromqiskitimport*fromqiskit.quantum_infoimportrandom_unitary# Create a random state for qubit Crandom_1q_gate=random_unitary(2).to_instruction()
# Create a register for each qubit of interestqrA=QuantumRegister(1, 'qA')
qrB=QuantumRegister(1, 'qB')
qrC=QuantumRegister(1, 'qC')
anc_top=QuantumRegister(1, 'ancilla_top')
anc_bottom=QuantumRegister(1, 'ancilla_bottom')
# Create a single classical registercr=ClassicalRegister(2, 'c')
cr_ancilla=ClassicalRegister(1, 'ancilla_bits')
# Create circuitqc=QuantumCircuit(anc_top, qrC, qrA, qrB, anc_bottom, cr, cr_ancilla)
qc.reset(range(5))
# Start in the |1> stateqc.x(qrC)
# Make C qubit in random quantum stateqc.compose(random_1q_gate, qrC, inplace=True)
# Form Bell pair between A and Bqc.h(qrA)
qc.cx(qrA, qrB)
qc.barrier()
# Bell measurementqc.cx(qrC, qrA)
qc.h(qrC)
qc.measure([qrC[0], qrA[0]], [cr[0], cr[1]])
qc.barrier()
# Corrective Pauli gateswithqc.switch(cr) ascase:
# If returned bit-string is 00 = 0withcase(0):
pass# If returned bit-string is 01 = 1withcase(1):
qc.z(qrB)
# If returned bit-string is 10 = 2withcase(2):
qc.x(qrB)
# If returned bit-string is 11 = 3withcase(3):
qc.z(qrB)
qc.x(qrB)
qc.barrier()
# Apply inverse of unitary that generated state Cqc.compose(random_1q_gate.inverse(), qrB, inplace=True)
# We should be back in the ground stateqc.cx(qrB, anc_bottom)
qc.measure(anc_bottom, cr_ancilla[0])
fromqiskitimportqasm3qasm3.dumps(qc)
gives
File [~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/qasm3/exporter.py:195](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/qasm3/exporter.py:195), in Exporter.dump(self, circuit, stream)
[185](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/qasm3/exporter.py:185) """Convert the circuit to OpenQASM 3, dumping the result to a file or text stream."""
[186](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/qasm3/exporter.py:186) builder = QASM3Builder(
[187](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/qasm3/exporter.py:187) circuit,
...
--> [176](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/circuit/tools/pi_check.py:176) complex_inpt = complex(inpt)
[177](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/circuit/tools/pi_check.py:177) real, imag = map(normalize, [complex_inpt.real, complex_inpt.imag])
[179](https://file+.vscode-resource.vscode-cdn.net/Users/paul/Desktop/~/mambaforge/envs/qiskit-one/lib/python3.12/site-packages/qiskit/circuit/tools/pi_check.py:179) jstr = "\\jmath" if output == "latex" else "j"
TypeError: only length-1 arrays can be converted to Python scalars
How can we reproduce the issue?
Try the above
What should happen?
I should be able to dump a dynamic circuit to QASM3
Any suggestions?
No response
The text was updated successfully, but these errors were encountered:
Obviously still a problem, but I suspect it's more likely to do with our dodgy handling of Instruction.params rather than the dynamic-circuit bits, since UnitaryGate has a Numpy array in its params.
Environment
What is happening?
I should be able to use
qiskit.qasm3.dump
orqiskit.qasm3.dumps
on a dynamic circuit. However, for a teleportation circuit it throws an errorgives
How can we reproduce the issue?
Try the above
What should happen?
I should be able to dump a dynamic circuit to QASM3
Any suggestions?
No response
The text was updated successfully, but these errors were encountered: