Open lmondada opened 4 months ago
I'm not sure what to conclude here. It looks valid as a DAG but not as a Circuit
. What should be the output of c.get_commands()
? The problem is that conditional gates can only be conditioned on bit values as they are at the time of gate application -- not on previous values.
I don't think compilation passes should end up with DAGs like this.
For reference, the SquashRzPhasedX
pass transforms this circuit:
into this:
which has the same issue.
I think the unwritten rule we are violating is that a Boolean wire must be the only path in the DAG from its source to its target node.
This issue has been automatically marked as stale.
After investigating #1324, it seems the bug is not in
SquashRzPhasedX
, but in the command iteration utility. In fact, consider the following circuit:This circuit definition is slightly awkward, as I don't think there is any
add_op
-type calls I can use to build the circuit as needed. The "trick" here is that a measurement is performed and a quantum gate is then added on the measured qubit post-measurement. However, the gate is classically controlled on the classical value of the classical bit before the measurement. It is a valid DAG, but there is no linear order of the "measure" and "add_conditional" operations that would yield this graph. As far as I can tell, though, it is valid. It looks as follows:The following assertion then fails:
AFAIK this is an invalid state for the iterator to be in.
Full MWE: