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

SynchronizeTerminalMeasurements doesn't handle multi-qubit measurements #4907

Closed
daxfohl opened this issue Jan 28, 2022 · 0 comments · Fixed by #4911
Closed

SynchronizeTerminalMeasurements doesn't handle multi-qubit measurements #4907

daxfohl opened this issue Jan 28, 2022 · 0 comments · Fixed by #4911
Assignees
Labels
kind/bug-report Something doesn't seem to work.

Comments

@daxfohl
Copy link
Contributor

daxfohl commented Jan 28, 2022

Description of the issue

The logic for SynchronizeTerminalMeasurements goes qubit-by-qubit checking for measurements that are terminal but not at the last moment, and moves such measurements to the last moment. Thus if a two-qubit measurement has a single-qubit gate after it, the logic still moves the measurement to terminal position since one of its qubits is unblocked.

How to reproduce the issue

Add the following test to synchronize_terminal_measurements_test.py. The circuit should be unmodified by the transformer. But the transformer moves the measurement to the end.

def test_multi_qubit():
    q0, q1 = cirq.LineQubit.range(2)
    circuit = cirq.Circuit(
        cirq.measure(q0, q1, key='m'), cirq.H(q1)
    )
    assert_optimizes(before=circuit, after=circuit.copy())

Cirq version
0.14.1

@daxfohl daxfohl added the kind/bug-report Something doesn't seem to work. label Jan 28, 2022
@tanujkhattar tanujkhattar self-assigned this Jan 28, 2022
CirqBot pushed a commit that referenced this issue Jan 31, 2022
…ronizeTerminalMeasurements` (#4911)

- Part of #4722
- Follows the new Transformer API #4483
- Supports no compile tags NoCompile Tag for optimizers #4253
- Fixes #4907
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
…ronizeTerminalMeasurements` (quantumlib#4911)

- Part of quantumlib#4722
- Follows the new Transformer API quantumlib#4483
- Supports no compile tags NoCompile Tag for optimizers quantumlib#4253
- Fixes quantumlib#4907
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
…ronizeTerminalMeasurements` (quantumlib#4911)

- Part of quantumlib#4722
- Follows the new Transformer API quantumlib#4483
- Supports no compile tags NoCompile Tag for optimizers quantumlib#4253
- Fixes quantumlib#4907
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.
Projects
None yet
2 participants