SabreSwap
can throw away classically conditioned gates and all successors
#8040
Labels
bug
Something isn't working
Environment
What is happening?
The
SabreSwap
transpiler pass can sometimes remove classically conditioned gates from the circuit, and all their successors, whether or not the successors have classical conditions.This is (I believe) the cause of the current failures in the randomised test suite (from #2645 (comment) to #2645 (comment)).
How can we reproduce the issue?
What should happen?
The transpiled circuit should not have lost the second classically controlled gate.
Any suggestions?
Conditions currently aren't being accounted for in the "expected number of predecessors" calculation that determines whether a gate is eligible to be added to the circuit. The current
_is_resolved
check, since #7952, is:but conditions are not part of the
cargs
. Since the condition is equality to the known value, if the relevant node is not in the original front layer, itsapplied_predecessors
(which correctly account for conditions) can be increased beyond the count of its qargs and cargs, so the condition never triggers.(#7952 didn't cause this issue, it just didn't completely address the issue of all classical arguments.)
The fix is to account for all possible predecessors in
SabreSwap._is_resolved
.The text was updated successfully, but these errors were encountered: