Skip to content

🐛 Export measurements across quantum operations - #2439

Merged
burgholzer merged 3 commits into
mainfrom
codex/export-delayed-measurement
Sep 7, 2026
Merged

🐛 Export measurements across quantum operations#2439
burgholzer merged 3 commits into
mainfrom
codex/export-delayed-measurement

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

The native Qiskit exporter rejects valid programs when a SWAP or another quantum
operation separates a measurement from the store of its result. Allow constants,
unitary operations (including barriers), and resets between them. Keep the
measurement at its original position and use its existing classical destination,
without adding classical bits.

Continue rejecting intervening classical accesses and control flow: fusing the
store into the measurement writes the destination earlier and may otherwise
change the program's meaning. Update the documented export contract.

This addresses the exporter restriction discussed in #2351 independently of the
mapping fixes and the sorter changes in #2436. Neither PR is a dependency.

No standalone changelog entry or migration instructions are needed for this
correction to unreleased v4 functionality.

Validation

  • Merged main at 6b9385280, including 🐛 Enforce unitary effect contracts #2435 and 🐛 Synthesize one-qubit gates without entanglers #2444, and rebuilt the MLIR
    bindings at db22ece60.
  • All 306 Qiskit translation tests passed with Python 3.13 and Qiskit 2.5.2.
  • All 13 focused delayed-measurement tests passed. Ten positive cases cover X,
    SWAP, reset, barrier, and inverse modifiers through QC and QCO conversion.
    They check operation order, wire and destination identity, classical-bit
    count, and measured value.
  • Intervening bit and whole-register writes and the deferred classical-snapshot
    case remain rejected. The existing control-flow checks still pass.
  • uvx nox -s lint and git diff --check passed.
  • uvx nox -s stubs passed and produced no tracked stub changes.
  • uvx nox -s cpp-lint -- upstream/main passed with zero clang-format or
    clang-tidy findings, checking the full changed C++ file with clang-tidy 23.

Implementation, tests, documentation, and this description were prepared with
AI assistance via Codex. CI and human-review confirmations remain open for the
updated revision.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

Allow unitary operations and resets between a measurement and its destination store without moving the measurement. Retain conservative rejection across classical accesses and control flow.

Assisted-by: GPT-6 via Codex
Signed-off-by: Simon Hofmann <simon.t.hofmann@tum.de>
@simon1hofmann simon1hofmann self-assigned this Sep 7, 2026
@simon1hofmann simon1hofmann added c++ Anything related to C++ code documentation Improvements or additions to documentation fix Fix for something that isn't working MLIR Anything related to MLIR python Anything related to Python code skip-changelog Changes that do not need to show up in the changelog labels Sep 7, 2026
Comment thread bindings/mlir/qiskit/QiskitExport.cpp
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Cover delayed measurement stores across inverse modifiers through both QC and QCO after the unitary effect contract update.

Assisted-by: GPT-5 via Codex
@simon1hofmann
simon1hofmann requested review from burgholzer and a lite review from Copilot and removed request for Copilot September 7, 2026 19:02
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Approval pending

CodeRabbit 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.

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this works 👍🏻

@burgholzer
burgholzer merged commit 3f80188 into main Sep 7, 2026
23 checks passed
@burgholzer
burgholzer deleted the codex/export-delayed-measurement branch September 7, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code documentation Improvements or additions to documentation fix Fix for something that isn't working MLIR Anything related to MLIR python Anything related to Python code skip-changelog Changes that do not need to show up in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants