Skip to content

🩹 Preserve scoped classical storage in exporters - #2755

Merged
burgholzer merged 3 commits into
mainfrom
codex/scoped-classical-storage
Oct 13, 2026
Merged

burgholzer merged 3 commits into
mainfrom
codex/scoped-classical-storage

Conversation

@burgholzer

@burgholzer burgholzer commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Preserve classical bit declarations inside loops and branches when exporting to OpenQASM 3 and Qiskit. OpenQASM retains declaration scope; Qiskit allocates circuit storage and restores zero-initialized local bits on each block entry.

Use source locations as best-effort naming hints for scalar qubits and local storage. Explicit attributes retain priority and preserve parameter binding, Qiskit identities, declared register names, and QIR result labels. Export and execution work after plain textual IR drops cosmetic locations. Dynamic quantum allocation and general dynamic-bound Qiskit export remain unsupported.

Validation: 325 native OpenQASM tests and 455 Python translation tests passed for the implementation. This follow-up passed 14 focused naming/storage tests, repository lint, and MLIR reference generation. Independent review has no unresolved findings. CI for the updated head is pending.

AI assistance covered implementation, review, tests, documentation, and this description. Human acceptance remains.

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

Keep local classical declarations in OpenQASM control-flow blocks and
reset zero-initialized Qiskit storage on each block entry. Retain source
names without displacing declared registers, preserve location details,
and reject empty named quantum registers before layout construction.

Assisted-by: GPT-6 via Codex
@burgholzer burgholzer added fix Fix for something that isn't working c++ Anything related to C++ code python Anything related to Python code MLIR Anything related to MLIR labels Oct 13, 2026
@burgholzer burgholzer self-assigned this Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.64286% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../Dialect/QC/Translation/TranslateQCToOpenQASM3.cpp 94.0% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Keep location names as optional export hints while explicit attributes
preserve binding names, source identities, and result labels. Exercise
scoped storage export and execution after a plain IR round trip drops
cosmetic location names.

Assisted-by: GPT-6 via Codex
@burgholzer burgholzer added this to the v4.1.0 - QDMI 1.4 / MQSF milestone Oct 13, 2026
@burgholzer
burgholzer enabled auto-merge (squash) October 13, 2026 19:15
@burgholzer
burgholzer merged commit 8e147c7 into main Oct 13, 2026
55 of 61 checks passed
@burgholzer
burgholzer deleted the codex/scoped-classical-storage branch October 13, 2026 20:33
@burgholzer burgholzer mentioned this pull request Oct 13, 2026
8 of 10 tasks
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 fix Fix for something that isn't working MLIR Anything related to MLIR python Anything related to Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant