Closed kdk closed 4 years ago
Collect2qBlocks
includes multiple gates with conditionals into the same block. For example, the circuit
┌─────────┐┌───────┐┌───┐┌───────┐┌───┐┌─────────┐┌─┐
q6476_0: |0>┤ U2(0,0) ├┤ U1(0) ├┤ X ├┤ U1(0) ├┤ X ├┤ U2(0,0) ├┤M├
└────┬────┘└───────┘└─┬─┘└───────┘└─┬─┘└────┬────┘└╥┘
q6476_1: |0>─────┼────────────────┼─────────────┼───────┼──────╫─
│ │ │ │ ║
q6476_2: |0>─────┼────────────────┼─────────────┼───────┼──────╫─
│ │ │ │ ║
q6476_3: |0>─────┼────────────────┼─────────────┼───────┼──────╫─
│ │ │ │ ║
q6476_4: |0>─────┼────────────────┼─────────────┼───────┼──────╫─
│ │ │ │ ║
q6476_5: |0>─────┼────────────────┼─────────────┼───────┼──────╫─
│ │ │ │ ║
q6476_6: |0>─────┼────────────────┼─────────────┼───────┼──────╫─
│ │ │ │ ║
q6476_7: |0>─────┼────────────────■─────────────■───────┼──────╫─
│ │ ║
q6477_0: |0>─────┼──────────────────────────────────────┼──────╫─
│ │ ║
q6477_1: |0>─────┼──────────────────────────────────────┼──────╫─
┌──┴──┐ ┌──┴──┐ ║
c1144_0: 0 ══╡ = 0 ╞════════════════════════════════╡ = 1 ╞═══╩═
└─────┘ └─────┘
is collected into the blocks[['u2', 'u1', 'cx', 'u1', 'cx', 'u2'], ['measure']]
which ConsolidateBlocks
then joins together.
I don't think that this grouping is correct as I cannot see a logical value that the condition on the unitary could hold in this instance. Therefore, I think that the update that is needed is to refine how Collect2QBlocks
deals with gates which contain conditions.
From https://travis-ci.com/Qiskit/qiskit-terra/jobs/242965523#L6482 :
Information
Attaching a callback to print the pass name and output dag, it looks like the conditional is lost in ConsolidateBlocks.