🐛 Export independently scheduled measurements - #2452
Conversation
Permit measurement destination fusion across disjoint recursive effects while accounting for the earlier write in classical snapshot validation. Assisted-by: GPT-5 via Codex
Document the successful native-export matrix and the retained stale-snapshot boundary. Assisted-by: GPT-5 via Codex
MatthiasReumann
left a comment
There was a problem hiding this comment.
Solid work 🗿 Left some nitpicks. Nothing too dramatic! I'll leave it to @burgholzer to judge how these changes fit into the bigger picture of the QASM export.
| if (destination) { | ||
| throw std::runtime_error( | ||
| "QC measurement has more than one classical destination"); | ||
| } |
There was a problem hiding this comment.
We can keep this assumption for now. However, generally, this could be valid right? @burgholzer
There was a problem hiding this comment.
🤖 AI text below 🤖
Yes, this is valid QC IR: the measurement returns an i1 that can be stored in
several destinations. This is an existing native-Qiskit exporter limitation,
not a dialect invariant; this PR moves the check into a shared helper.
Keeping the restriction here as suggested. Supporting multiple destinations
would require one measurement followed by classical copies that preserve write
order and captured values. That extension is outside this PR's scope.
Use TypeSwitch and shared memory-effect handling while preserving static-index disambiguation and the existing exporter limits. Cover disjoint bit accesses and intervening register allocations. Assisted-by: GPT-5 via Codex
|
Important Approval pendingCodeRabbit has no unresolved comments, but it has not reviewed the latest commit. Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Keep indexed writes and scalar snapshots from the updated routing branch. Index fused measurement destinations at their earlier write position and verify snapshot semantics before and after delayed stores. Assisted-by: Codex
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🤖 AI text below 🤖
Description
Stacked on #2351, updated through parent commit
2850cf57e(including currentmain). This PR fixes the native Qiskit exporter boundary exposed by theremaining 25 Benchpress feed-forward profiles, separately from the routing
correction in the parent PR. Merge the parent first, then retarget this PR to
main.Mapping may legally separate a measurement from its classical destination by
other measurements or independent control flow. Permit destination fusion when
recursive effects cannot access that bit, using CBit's non-aliasing register
contract and static-index disambiguation. Keep measurements at their original
quantum positions and add no scratch classical bits.
Record the earlier fused write in the parent's write index, including nested
operations. Both scalar snapshot materialization and deferred-expression
validation must observe that write. Preserve the parent's scope-based caches
and scalar snapshot support instead of restoring recursive write scans.
Overlapping accesses, unknown effects, and unsupported stale snapshots remain
diagnosed. Stale register snapshots wider than 64 bits remain unsupported.
The unique measurement-destination requirement remains an exporter limitation,
not a QC dialect invariant; multiple classical destinations are outside this PR.
Current validation
test_mlir_qiskit_translation.pyandtest_mlir_loops.pypass.consumers before and after the delayed store. A final controlled-qubit
measurement verifies the captured value without adding classical bits.
against
origin/codex/preserve-mapped-classical-controlpass. Generated stubsadd no API changes relative to the parent.
validation of this update.
Historical Benchpress validation
At source commit
7dad9e19e, a fresh wheel with Qiskit 2.5.0 passed all 42targeted Benchpress native-export checks: 31 previously guarded profiles, ten
existing profiles, and BV100. No OpenQASM fallback was used. All 4,621
conditionals remained, nested gates passed Qiskit basis/connectivity analysis,
and BV100 retained exactly 99 classical bits and measurements. All 80
Benchpress integration tests and the then-current 330 Qiskit translation tests
passed; the preceding build failed 12 of the new positive cases.
These Benchpress checks were not rerun for this update. The old integration
snapshot-rejection test predates the parent's scalar snapshot support and has
not been revalidated.
The historical Benchpress checks used a corresponding local integration update:
pin that PR snapshot, retire the temporary textual event-order checker, retain
input restrictions, and enable only the validated profiles. Those adapter
changes are not part of this Core diff. The full benchmark suite was not
restarted; structural counts are not a general dynamic-program equivalence
proof.
No changelog or migration entry is needed for this unreleased-v4 fix with no
public API changes. Implementation, tests, and this description were prepared
with AI assistance through Codex. Human review remains required.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).