-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Information
- Qiskit Terra version: main
- Python version: any
- Operating system: any
What is the current behavior?
If two classical registers have a non-empty intersection of clbits, it's possible to have InstructionSet.c_if
resolve an integer index to a different value than the original QuantumCircuit
would.
Steps to reproduce the problem
In [1]: from qiskit.circuit import QuantumCircuit, ClassicalRegister, Clbit, Qubit
...: clbits = [Clbit() for _ in [None]*3]
...: # Two overlapping classical registers.
...: cr1 = ClassicalRegister(bits=clbits[:2])
...: cr2 = ClassicalRegister(bits=clbits[1:])
...:
...: qc = QuantumCircuit([Qubit()], cr1, cr2)
...: qc.x(0).c_if(2, 0)
...: qc.measure(0, 2)
...:
...: clbit_from_c_if = qc.data[0][0].condition[0]
...: clbit_from_measure = qc.data[1][2][0]
...: clbit_from_c_if is clbit_from_measure
Out[1]: False
What is the expected behavior?
They should resolve to the same clbit, because they use the same index.
Suggested solutions
Instead of storing references to the classical registers in the instruction set, store a reference to the circuit, or a bound callable that came from the circuit to resolve the indices.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working