Skip to content

fix(transformers): do not reorder measurements sharing a key - #8226

Open
Sanjays2402 wants to merge 1 commit into
quantumlib:mainfrom
Sanjays2402:fix/sync-terminal-measurements-repeated-key
Open

fix(transformers): do not reorder measurements sharing a key#8226
Sanjays2402 wants to merge 1 commit into
quantumlib:mainfrom
Sanjays2402:fix/sync-terminal-measurements-repeated-key

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #6329

synchronize_terminal_measurements moved a measurement to the final moment even when a later measurement reused the same key. Reordering two measurements that share a key changes the record order for that key, so the result is not logically equivalent to the input (align_left/align_right already refuse this reordering).

find_terminal_measurements now tracks measurement keys seen in later moments, mirroring the existing seen_control_keys handling, and no longer treats such a measurement as terminal. Regression test uses the circuit from the issue.

synchronize_terminal_measurements moved a measurement to the final moment
even when a later measurement reused the same key. Reordering two
measurements with the same key changes the record order for that key, so
the transformed circuit is not logically equivalent to the input.

find_terminal_measurements now tracks measurement keys seen in later
moments (mirroring the existing seen_control_keys handling) and does not
classify a measurement as terminal when a later measurement reuses its
key. align_left/align_right already refuse this reordering.

Adds a regression test using the circuit from the issue report.
@Sanjays2402
Sanjays2402 requested a review from a team as a code owner July 25, 2026 20:55
@Sanjays2402
Sanjays2402 requested a review from tanujkhattar July 25, 2026 20:55
@github-actions github-actions Bot added the size: S 10< lines changed <50 label Jul 25, 2026
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.60%. Comparing base (726eed6) to head (df685b3).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8226   +/-   ##
=======================================
  Coverage   99.60%   99.60%           
=======================================
  Files        1118     1118           
  Lines      101667   101673    +6     
=======================================
+ Hits       101261   101267    +6     
  Misses        406      406           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

synchronize_terminal_measurements() misorders measurements with the same key

1 participant