🐛 Initialize Qiskit classical bits in OpenQASM 3 - #2399
Merged
Conversation
Preserve Qiskit zero-initialization semantics when a circuit measures only part of its classical storage. Assisted-by: GPT-5 via Codex
Assisted-by: GPT-5 via Codex
burgholzer
enabled auto-merge (squash)
September 5, 2026 09:56
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 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
falsestore 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
falsebit 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 lintChecklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).