-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
kind/bug-reportSomething doesn't seem to work.Something doesn't seem to work.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Description
Description of the issue
The eject_phased_paulis
transformer exhibits incorrect behavior when interacting with X or Y gates preceding measurements. Specifically, the transformer erroneously merges these gates into measurements, as demonstrated by the following transformation:
Original circuit:
0: ───X───M('c_0')───M('c_1')───
Transformed circuit:
0: ───!M('c_0')───M('c_1')───
This issue notably affects the measurement outcome of c_1
, potentially altering the execution results of circuits incorporating mid-circuit measurements. A temporary solution might involve verifying the position of the measurement within the circuit, ensuring it only merges operations when measurements are at the end of the circuit.
How to reproduce the issue
import cirq
circuit = cirq.Circuit(
cirq.X(cirq.LineQubit(0)),
cirq.measure(cirq.LineQubit(0), key='c_0'),
cirq.measure(cirq.LineQubit(0), key='c_1'),
)
circuit_trans = cirq.eject_phased_paulis(circuit)
print(circuit)
print(circuit_trans)
Execution result:
0: ───X───M('c_0')───M('c_1')───
0: ───!M('c_0')───M('c_1')───
Cirq version
1.3.0
Metadata
Metadata
Assignees
Labels
kind/bug-reportSomething doesn't seem to work.Something doesn't seem to work.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on