✨ Add a pass hoisting auxiliary qubits out of callees - #2199
Open
DRovara wants to merge 2 commits into
Open
Conversation
12 tasks
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 20, 2026 18:33
bdd5ccb to
2322369
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 24, 2026 09:33
2322369 to
0a3482a
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 24, 2026 09:52
0a3482a to
72a90b8
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 25, 2026 07:50
72a90b8 to
a364f13
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
2 times, most recently
from
August 25, 2026 10:48
a9f0e11 to
cb5e8ba
Compare
burgholzer
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 25, 2026 21:44
cb5e8ba to
07ed715
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
2 times, most recently
from
August 26, 2026 14:11
0b3b7b7 to
6c790e8
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 26, 2026 14:34
6c790e8 to
03424aa
Compare
DRovara
marked this pull request as ready for review
August 26, 2026 14:37
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 27, 2026 11:40
03424aa to
b122873
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
2 times, most recently
from
August 28, 2026 07:28
a89bb64 to
1bef556
Compare
DRovara
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 28, 2026 08:11
1bef556 to
e331d0d
Compare
burgholzer
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 28, 2026 12:30
e331d0d to
1ae55bf
Compare
Move locally allocated scratch qubits to supported callers while leaving unsupported call paths unchanged. Assisted-by: Claude Opus 5 <noreply@anthropic.com> Assisted-by: Codex
burgholzer
force-pushed
the
mlir/auxiliary-qubit-hoisting
branch
from
August 30, 2026 14:21
1ae55bf to
4cb6f99
Compare
12 tasks
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
Sixth of a stack replacing #1970. Builds on #2198.
quantum-auxiliary-qubit-hoistingturns a qubit a callee allocates and releases itself into an extra argument and an extra result, handed back reset, so the caller owns the allocation and can reuse one qubit across several calls. Externally visible functions, declarations and recursive functions are left alone. If tracing an allocation reaches a nested call whose correspondence cannot be derived, that candidate is also left unchanged.Candidates are visited callees first, in a post-order over the call graph. Hoisting out of a callee puts an allocation into each of its callers, which may itself be hoistable; processing in module order used to strand that allocation wherever the declarations happened to sit, so the same
main -> mid -> leafcall graph gave different results depending on declaration order.A post-order was chosen over iterating to a fixed point deliberately: hoisting into a function with n callers multiplies allocations, so iterating could blow up exponentially in call-graph depth.
Testing
13 cases in
test_qco_auxiliary_qubit_hoisting.cpp, scheduled on this pass alone, covering hoisting through measure/reset, through a tensor, through a nested call, across multiple call sites, and the cases that must not hoist.hoistingIsIndependentOfDeclarationOrderbuilds the same call graph twice and reorders the declarations in one; it is mutation-verified against the module-order implementation. A compact parsed-IR regression confirms that an allocation flowing through a recursive callee is not hoisted.The complete optimization suite passes all 246 tests.
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).