BarrierBeforeFinalMeasurements
fails if there are loose qubits or clbits
#8923
Labels
bug
Something isn't working
Environment
What is happening?
The
BarrierBeforeFinalMeasurements
pass fails if any of the proceeding operations involve loose qubits or clbits (i.e. those not in registers).How can we reproduce the issue?
Loose qubit:
gives
Similarly, if I put the qubit in a register and use only the loose clbit, such as by constructing the circuit with
I get a similar error on the clbit:
What should happen?
The clbit error is the only one that particularly matters, since
BarrierBeforeFinalMeasurements
is run as part of routing where the qubit registers have already been canonicalised. We shouldn't be getting an error in the internal structures.Any suggestions?
The pass creates a new internal DAG for the barrier layer like this: https://github.com/Qiskit/qiskit-terra/blob/fca8db6b86cba106ed0449a99cd10223899b6145/qiskit/transpiler/passes/utils/barrier_before_final_measurements.py#L53-L58
which doesn't include loose clbits. We don't want to use
DAGCircuit.copy_empty_like
because that would also copy things like metadata and global phase, but we do need to add the loose bits.The text was updated successfully, but these errors were encountered: