Support decomposition to/from Adjoint Ops to the GraphSolver#3001
Open
maliasadi wants to merge 10 commits into
Open
Support decomposition to/from Adjoint Ops to the GraphSolver#3001maliasadi wants to merge 10 commits into
maliasadi wants to merge 10 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3001 +/- ##
=======================================
Coverage 96.99% 96.99%
=======================================
Files 165 165
Lines 19091 19091
Branches 1816 1816
=======================================
Hits 18518 18518
Misses 420 420
Partials 153 153 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
albi3ro
reviewed
Jul 21, 2026
| * - AdjointGenerated: A rule synthesized by adjointing a base decomposition rule. | ||
| */ | ||
| enum class RuleOrigin : uint8_t { Default = 0, Fixed = 1, Alternative = 2 }; | ||
| enum class RuleOrigin : uint8_t { Default = 0, Fixed = 1, Alternative = 2, AdjointGenerated = 3 }; |
Contributor
There was a problem hiding this comment.
Should we differentiate between adjoint genereated from default, adjoint generated from fixed and adjoint generated from alternative?
albi3ro
reviewed
Jul 21, 2026
| { | ||
| RuleNode adj; | ||
| adj.name = base.name + "_adjoint"; | ||
| adj.output = makeAdjoint(base.output); |
Contributor
There was a problem hiding this comment.
Do we have to worry about this in-place mutating base.output?
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.
Context:
The decomposition graph solver could not decompose Adjoint ops. This PR adds this support to the graph solver to handle them, mirroring the two decomposition families used by PL:
Decompose
Adjoint(Op)directly: Rules registered against the adjoint operator itself:self_adjointandadjoint_rotationfuncs in PL. and other custom rules like_adjoint_rot, etc. These were already supported by the graph. ARuleNodewhose output hasadjoint = trueis registered and solved like any other rule; so no new logic was needed to the solver; they just need to be provided as rules. I'll take care of this in a follow-up PR to integrate the support with the graph-decomposition pass.Decompose Op, then adjoint each produced gate: From each base rule
Op, the graph builder should synthesizeAdjoint(Op)with the same multiplicities. I assumed that gate-order reversal doesn't affect resources, so the graph only needs theAdjoint(Op)counts; the actual reversal happens in the follow-up PR when integrating with the pass.Both pathways coexist in the graph, and the solver picks the cheapest decomp pathway! 🎉
Benefits:
Possible Drawbacks:
Adjoint(Op)and track them all throughout multiple decomp pathways.Related GitHub Issues:
[sc-125400]