"swap followed by measure" optimization pass#1890
Conversation
ajavadia
left a comment
There was a problem hiding this comment.
There are some problems with this pass. It should only remove swap gates that are followed by measure on both wires. So this is a valid optimization (second test case):
qr0:--X--m-- qr0:--m----
| | |
qr1:--X--|--m ==> qr1:--|--m-
| | | |
cr0:-----.--|-- cr0:--|--.-
cr1:--------.-- cr1:--.----
However the 1st and 4th test cases are not valid transformations:
qr0:--X--m-- qr0:----
| |
qr1:--X--|-- ==> qr1:--m-
| |
cr0:-----.-- cr0:--.-
qr0:--X-------- qr0:--m--
| |
qr1:--X--X----- qr1:--|--
| ==> |
qr2:-----X--m-- qr2:--|--
| |
cr0:--------.-- cr0:--.--
Here the qubits that are not measured live on, and by removing the swap, you invalidate their permutation due to that swap. So this can only be done when we are left with classical bits, in which case we can retarget the measurements (modify their clbit target), and remove the swap.
Co-Authored-By: 1ucian0 <luciano@debian.org>
…sure_simplification_pass
|
two files must be removed from this PR: |
|
Fixed. I also moved the fixed point to check the DAG instead of counting ops. |
|
Can you add a changelog line for this as well? Approved. |
This PR goes on top of #1889
Removes the swap before the measurement.