-
-
Notifications
You must be signed in to change notification settings - Fork 73
β¨ Legalize control flow for selected payloads #2162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a691b7
β¨ Legalize control flow for selected payloads
burgholzer b00e2e1
β»οΈ Remove redundant modifier legality exemptions
simon1hofmann 97aa100
π Align control flow release scope
simon1hofmann 7f44fbb
β»οΈ Simplify structured payload legalization
burgholzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Compiler-only control-flow legalization | ||
|
|
||
| Status: implemented. | ||
|
|
||
| ## Scope and release boundary | ||
|
|
||
| Core #2162 follows #2219 without QDMI runtime or adapter ancestry and targets | ||
| Core 4.0. Core #2365 and QDMI #523 track the separate Core 4.1/QDMI 1.4 | ||
| adaptation and do not gate this prototype. The rebase preserves the capability | ||
| snapshot; human review must still settle the provider-neutral vocabulary. | ||
|
|
||
| Legalize structural control flow against the selected target environment. Retain | ||
| supported constructs, lower unsupported static loops and switches where | ||
| possible, and fail closed when residual control flow cannot be represented. | ||
| Scalar computation, measurement provenance, allocation, functions and final QIR | ||
| profile verification remain separate work. | ||
|
|
||
| ## Implementation | ||
|
|
||
| Keep two passes in one source: bounded static-loop unrolling before cleanup, | ||
| then dialect conversion for residual branches and loops. Reuse MLIR symbol DCE, | ||
| SCCP, native static trip counts, loop unrolling and conversion legality. Require | ||
| structured QCO/SCF input; producers normalize CFG branches before compilation. | ||
| Preserve literal-bound proofs, the 65,536 cloned-operation limit, and signed | ||
| arithmetic safety checks for full unrolling. Reject invalid linear captures; | ||
| carry quantum values explicitly through regions. | ||
|
|
||
| The canonical pipeline receives one selected TargetEnvironment and shares its | ||
| prepared target with all passes. It does not reintroduce removed cleanup passes | ||
| or unknown-target fallbacks. Both legalization passes consume the existing | ||
| cached TargetEnvironmentAnalysis. Capability names and constraints remain | ||
| provisional. | ||
|
|
||
| Single-case switches require only multiway branching. Cleanup after mapping | ||
| remains; the redundant cleanup immediately after control legalization is | ||
| removed. | ||
|
|
||
| ## Validation | ||
|
|
||
| The optimized native build passed all 3,217 configured tests, with one existing | ||
| optional-device skip. The compiler suite passed all 191 tests, including early | ||
| CFG rejection, runtime assertions, single-case quantum and classical switches, | ||
| full-width trip counts, unroll bounds, and linear-state constraints. MLIR | ||
| documentation, repository lint, and whole changed-file C++ lint passed. | ||
|
|
||
| Simon Hofmann's human co-authorship and the existing review history are | ||
| preserved. The child commits are restacked on the shared-environment | ||
| implementation in #2219. |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of this is a bit odd. Can we make this a little more natural? same holds for the other pass. Maybe the passes could even be combined. I like the "legalize-control-flow" part of this. Maybe a combination of both makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to add to that there is also the
QuantumLoopUnrollpass defined right above that. I think these two could potentially be one.