✨ Add a pass promoting qubit-tensor arguments to scalar qubits - #2198
Open
DRovara wants to merge 1 commit into
Open
✨ Add a pass promoting qubit-tensor arguments to scalar qubits#2198DRovara wants to merge 1 commit into
DRovara wants to merge 1 commit into
Conversation
This was referenced Aug 20, 2026
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 20, 2026 18:33
c26e9c0 to
6a27630
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 24, 2026 09:33
6a27630 to
1578b46
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 24, 2026 09:52
1578b46 to
8f2aa97
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
2 times, most recently
from
August 25, 2026 08:02
350ff04 to
d7f7ec2
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 25, 2026 10:48
d7f7ec2 to
5d0e1f0
Compare
burgholzer
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 25, 2026 21:44
5d0e1f0 to
2aebe38
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 26, 2026 14:08
2aebe38 to
2531a37
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
2 times, most recently
from
August 26, 2026 14:34
8a3cb58 to
bf470f6
Compare
DRovara
marked this pull request as ready for review
August 26, 2026 14:37
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 27, 2026 11:40
bf470f6 to
fdd4d49
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 27, 2026 13:16
fdd4d49 to
e1745be
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 28, 2026 07:28
e1745be to
1144497
Compare
DRovara
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 28, 2026 08:11
1144497 to
72bfe08
Compare
burgholzer
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 28, 2026 12:30
72bfe08 to
84eafd4
Compare
Promote quantum function arguments when call sites agree and cover the interprocedural transformations. Assisted-by: Claude Opus 5 <noreply@anthropic.com> Assisted-by: Codex
burgholzer
force-pushed
the
mlir/quantum-argument-promotion
branch
from
August 30, 2026 14:21
84eafd4 to
69a17d9
Compare
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
Fifth of a stack replacing #1970. Builds on #2197.
quantum-argument-promotionreplaces a qubit-tensor argument by one qubit argument and one qubit result per element the callee actually touches, so untouched elements no longer cross the call boundary. Call sites are rewritten to extract before the call and re-insert afterwards.The rewrite lifts every extraction in front of the call and sinks every insertion behind it, which is only sound when the accesses do not depend on each other's order. Two shapes are rejected, both found by review of the original PR and reproduced before fixing:
x(h(slot 0))was silently turned into one computingx(slot 1), with the pass reporting success.use_empty()assertion.Note the dialect's own canonicalizers already encode the first invariant:
FoldExtractAfterInsertPatternfoldsextract(insert(%q, %t, i), i)to%q, andCommuteAdjacentInsertExtractPatternonly commutes when the two indices are provably distinct constants.Testing
12 cases in
test_qco_quantum_argument_promotion.cpp, scheduled on this pass alone. The two regression cases are given as parsed MLIR becauseQCOProgramBuildercannot construct a write-before-read chain. Both are mutation-verified: removing either guard reproduces the original miscompile and the original crash respectively.noPromotionForFoldedPassThroughneeded a fix while splitting. It was passing only because the preceding pass in the pipeline incidentally folded the pass-through through its greedy pattern driver — nothing canonicalizes between the passes. The fold is now applied explicitly as the stated precondition, since promoting an unfolded pass-through is wasted work rather than a miscompile.optimizations 152.
AI assistance
Code and this description were produced with Claude Code (Opus 5) and Codex, acting on my instructions and within the scope I authorized.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).