Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Behavior of Transformer eject_phased_paulis with Mid-Circuit Measurements #6507

Open
p51lee opened this issue Mar 20, 2024 · 0 comments
Labels
kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@p51lee
Copy link

p51lee commented Mar 20, 2024

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

@p51lee p51lee added the kind/bug-report Something doesn't seem to work. label Mar 20, 2024
@NoureldinYosri NoureldinYosri added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Mar 20, 2024
@pavoljuhas pavoljuhas added triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Projects
None yet
Development

No branches or pull requests

3 participants