Skip to content

🐛 Initialize Qiskit classical bits in OpenQASM 3 - #2399

Merged
burgholzer merged 3 commits into
v3.xfrom
codex/backport-qiskit-classical-init
Sep 5, 2026
Merged

🐛 Initialize Qiskit classical bits in OpenQASM 3#2399
burgholzer merged 3 commits into
v3.xfrom
codex/backport-qiskit-classical-init

Conversation

@burgholzer

@burgholzer burgholzer commented Sep 5, 2026

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Backport explicit classical-bit initialization from the v4 Qiskit QDMI backend.

Qiskit initializes classical bits to zero, while OpenQASM 3 bit declarations leave them uninitialized. Prepend a false store for every classical bit so partially measured circuits preserve their Qiskit semantics.

This extracts the focused fix and regression test from #2288 without backporting the unrelated v4 circuit-surface removal.

The v3 legacy importer now type-checks indexed assignment targets as scalar elements and accepts only leading false bit stores as the IR zero default; later classical computation remains rejected.

Validation

  • uv run --no-sync pytest test/python/plugins/qiskit/test_mock_backend.py (21 passed)
  • uv run --no-sync pytest test/python/plugins/qiskit/test_backend.py test/python/plugins/qiskit/test_estimator.py test/python/plugins/qiskit/test_sampler.py (65 passed)
  • mqt-core-ir-test --gtest_filter=Qasm3ParserTest.* (104 passed)
  • uvx nox -s lint

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

Preserve Qiskit zero-initialization semantics when a circuit measures only part of its classical storage.

Assisted-by: GPT-5 via Codex
@burgholzer burgholzer added fix Fix for something that isn't working QDMI Anything related to QDMI backport Changes that have been backported to a stable release branch labels Sep 5, 2026
@burgholzer burgholzer self-assigned this Sep 5, 2026
@burgholzer burgholzer added this to the v3.9.3 milestone Sep 5, 2026
@burgholzer
burgholzer enabled auto-merge (squash) September 5, 2026 09:56

@denialhaag denialhaag 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.

LGTM! :shipit:

Teach the v3 importer to recognize indexed bit targets and treat leading false stores as the legacy IR default, while continuing to reject later classical computation.

Assisted-by: GPT-5 via Codex
@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@burgholzer
burgholzer merged commit ea962bd into v3.x Sep 5, 2026
25 checks passed
@burgholzer
burgholzer deleted the codex/backport-qiskit-classical-init branch September 5, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Changes that have been backported to a stable release branch fix Fix for something that isn't working QDMI Anything related to QDMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants