✨ Support classical results in QCO conditionals#1938
Merged
Conversation
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Integrate the Python CI and Jeff return-placement fixes from #1939. Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Member
Author
|
This feels very reasonable to me and it passes all tests. I am proceeding to merge. @MatthiasReumann for awareness as this also touches the IndexSwitchOp and its mapping. Hope this does not tae away too much of the work you had already done to support it. |
burgholzer
marked this pull request as ready for review
July 25, 2026 07:40
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 🤖
Summary
qco.ifandqco.index_switchto return ordinary classical SSA valuesbefore their existing linear quantum results.
scf.ifandscf.index_switchoperations throughQC-to-QCO and QCO-to-QC conversion without introducing scratch memory.
tied-value helpers, builders, mapping, tensor traversal, module equivalence,
and affected optimizations for the segmented result model.
QC → QCO → QC → QIR pipeline.
Motivation
This capability was identified while working on the OpenQASM integration in
#1910 and while reducing the structured-control-flow fixes that became #1935.
QCO conditionals previously represented only linear quantum results. Preserving
classical SCF results therefore required either rejecting otherwise valid
programs or lowering classical state through temporary memory.
The new representation keeps classical values in ordinary SSA form while
retaining QCO's explicit single-use quantum flow:
Conditional region arguments remain linear-only. Classical inputs continue to
use normal SSA capture, while
qco.yieldreturns the completeclassical-plus-linear result signature.
Implementation notes
AttrSizedResultSegmentsand expose explicitclassical and linear result accessors.
args(...)assignments andretain quantum-only textual compatibility.
qco.yieldverification preserves the stricter modifiercontracts.
linear results with QC references on the QC side.
classical yield operands while realigning only quantum values.
keeping the linear suffix permutation-aware.
Validation
All affected targets build successfully. The focused suites pass 933 tests in
total:
Repository lint, changed-source
clang-tidy, andgit diff --checkpass. Twoindependent read-only reviews were performed; the final review found no
remaining actionable issues.