-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: circuitRelated to the core of the `QuantumCircuit` class or the circuit libraryRelated to the core of the `QuantumCircuit` class or the circuit library
Milestone
Description
Environment
- Qiskit Terra version: 1.0.0.dev0+ac7aca3
- Python version: 3.11
- Operating system: Linux
What is happening?
Trying to convert a circuit with a control flow operation in it to an instruction using qiskit.converters.circuit_to_instruction
fails while processing the control flow condition. It is treating it like a c_if
legacy style condition even for control flow ops and this causes it to fail with a NotImplementedError
because the function is trying to call c_if
.
How can we reproduce the issue?
>>> qc = QuantumCircuit(2)
>>> qc.h(0)
<qiskit.circuit.instructionset.InstructionSet object at 0x7f0813ebc280>
>>> qc.cx(0, 1)
<qiskit.circuit.instructionset.InstructionSet object at 0x7f0813ebef80>
>>> qc.measure_all()
>>> with qc.if_test((qc.clbits[0], 0)):
... qc.x(0)
>>> circuit_to_instruction(qc)
What should happen?
We either should have a descriptive error saying we can't nest control flow operations in an instruction or update the .condition
handling in circuit_to_instruction
to understand a control flow operation.
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: circuitRelated to the core of the `QuantumCircuit` class or the circuit libraryRelated to the core of the `QuantumCircuit` class or the circuit library