`synchronize_terminal_measurements()` misorders measurements with the same key
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #8226 by @Sanjays2402 — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 20/100
Research direction
Start by reading synchronize_terminal_measurements() and running the reproduction in the issue. Compare its output with align_right() and check whether measurements sharing a key retain their logical ordering. Done means synchronization no longer changes the expected measurement outcome; an open pull request is already linked.
Written by the indexing model from the issue text.
Description
Description of the issue
(not 100% sure this isn't intended behavior)
when two measurements have the same key, reordering them results in a logically different circuit. Transformers like align_left() and align_right() correctly account for this by preventing the reordering of measurements with the same key, but synchronize_terminal_measurements() does not (see below)
How to reproduce the issue
circuit = cirq.Circuit(
cirq.X(cirq.q(1)),
cirq.measure(cirq.q(0), key="key1"),
cirq.measure(cirq.q(1), key="key1"),
cirq.measure(cirq.q(1), key="key2"),
)
print(circuit)
print(cirq.align_right(circuit)) # no change, as it would require reordering the two measurements with `key="key1"`
print(cirq.synchronize_terminal_measurements(circuit))
prints:
0: ───M('key1')───────────────────────────
1: ───X───────────M('key1')───M('key2')───
0: ───M('key1')───────────────────────────
1: ───X───────────M('key1')───M('key2')───
0: ───────────────────M('key1')───
1: ───X───M('key1')───M('key2')───
where the final circuit is not logically equivalent (the expected measurement outcome for "key1" is flipped)
Cirq version
1.3.0.dev20230830191034
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 48
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from quantumlib/Cirq
-
Potential missed optimization: `drop_diagonal_before_measurement` leaves an identity `PhasedXZGate` that blocks further removalPossibly taken @jangyoujin0917 claimed this 22 days ago. Openarea/gates area/optimization kind/feature-request triage/accepted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
quantumlib/Cirq#8523 · 1 comment ·
Maintainers usually reply within 1 day
-
`defer_measurements` ignores `BitMaskKeyCondition.index` and changes circuit behaviorMay be free again @Tejendra-06 claimed this 54 days ago, and no pull request is open. Opengood for learning help wanted kind/bug-report skill/experienced triage/accepted triage/wont-fix
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
quantumlib/Cirq#8361 · 8 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
kind/feature-request triage/discuss
quantumlib/Cirq#8598 ·
Maintainers usually reply within 1 day
-
area/docstrings area/google kind/bug-report triage/discuss
Difficulty 1/5 1-3 hours Newbie friendliness 91/100
quantumlib/Cirq#8587 ·
Maintainers usually reply within 1 day
-
kind/bug-report triage/discuss
Difficulty 2/5 1-3 hours Newbie friendliness 57/100
quantumlib/Cirq#8580 ·
Maintainers usually reply within 1 day
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day