Skip to content

⚡ Keep wide OpenQASM register conditions linear - #2181

Draft
simon1hofmann wants to merge 1 commit into
codex/target-compilation-liveness-scalingfrom
codex/openqasm-register-condition-sharing
Draft

⚡ Keep wide OpenQASM register conditions linear#2181
simon1hofmann wants to merge 1 commit into
codex/target-compilation-liveness-scalingfrom
codex/openqasm-register-condition-sharing

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

  • Recognize complete classical-register equality produced by the frontend and emit direct arbitrary-width OpenQASM conditions.
  • Fuse only eligible static measurement destinations and reject partial, duplicate, mixed, dynamic, modified, or stale snapshots.
  • Share repeated pure register-condition roots within one unchanged classical snapshot, keeping wide programs linear in IR size.
  • Preserve initialized OpenQASM 3 whole-register equality without claiming general arbitrary-width classical-expression support.

Stack

  1. ✨ Preserve classical control through target mapping #2179 — classical-control-aware target mapping
  2. ⚡ Avoid redundant target-compilation liveness analysis #2180 — target-compilation liveness scaling
  3. ⚡ Keep wide OpenQASM register conditions linear #2181 — wide OpenQASM register conditions (this PR)

Overlap

Open pull request #2169 adds compile-time fixed-width OpenQASM angles. It changes related semantics documentation, implementation, and tests. The behavior is independent, but this PR requires a semantic rebase and the full OpenQASM/QC test matrix if #2169 lands first.

Testing

  • mqt-core-mlir-unittest-qc-translation: 184 passed.
  • mqt-core-mlir-unittest-openqasm-target: 177 passed.
  • Type stubs, uvx nox -s lint, and git diff --check: passed on the complete detached stack.

AI assistance: Codex assisted with implementation, review, testing, stack construction, and this description.

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.

@simon1hofmann simon1hofmann added this to the MLIR Support milestone Aug 20, 2026
@simon1hofmann simon1hofmann added enhancement Improvement of existing feature c++ Anything related to C++ code MLIR Anything related to MLIR OpenQASM Anything related to OpenQASM labels Aug 20, 2026
@simon1hofmann simon1hofmann self-assigned this Aug 20, 2026
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v22.1.8) reports: 1 concern(s)
  • mlir/lib/Dialect/QC/Translation/TranslateQCToOpenQASM3.cpp:24:1: warning: [misc-include-cleaner]

    included header DenseSet.h is not used directly

       24 | #include <llvm/ADT/DenseSet.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       25 | #include <llvm/ADT/STLExtras.h>

Have any feedback or feature suggestions? Share it here.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.36697% with 42 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../Dialect/QC/Translation/TranslateQCToOpenQASM3.cpp 87.8% 40 Missing ⚠️
...lib/Dialect/QC/Translation/OpenQASMToQCEmitter.cpp 98.0% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Share pure register conditions within one classical snapshot and reconstruct complete arbitrary-width equalities during OpenQASM emission. Keep stale, partial, dynamic, and ambiguous forms fail-closed.

Assisted-by: Codex
Signed-off-by: Simon Hofmann <simon.t.hofmann@tum.de>
@burgholzer
burgholzer force-pushed the codex/openqasm-register-condition-sharing branch from 9e29e44 to fe5b4b4 Compare August 24, 2026 13:59
@burgholzer burgholzer self-assigned this Aug 24, 2026
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 enhancement Improvement of existing feature MLIR Anything related to MLIR OpenQASM Anything related to OpenQASM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants