-
Notifications
You must be signed in to change notification settings - Fork 677
[Decomposition] Custom decomposition rules for symbolic operators #7347
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7347 +/- ##
==========================================
- Coverage 99.69% 99.69% -0.01%
==========================================
Files 537 537
Lines 50955 50954 -1
==========================================
- Hits 50800 50799 -1
Misses 155 155 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…o symbolic-rules-01
…o symbolic-rules-01
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'll complete the review as soon as possible (need to interrupt for a few minutes :) )
Co-authored-by: Pietropaolo Frisoni <[email protected]>
…o symbolic-rules-01
…o symbolic-rules-01
…o symbolic-rules-01
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 don't have more questions here! Just a good-to-have non-blocking comment
**Context:** This is a follow-up PR to #7347 **Description of the Change:** There was previously a lot of custom logic for retrieving decomposition rules of symbolic operators. With the infrastructure added in #7347, this PR is able to clean up most of it. - We no longer hard-code a list of operators whose adjoint is an instance of the same type. Instead, each operator with a custom adjoint decomposition registers a decomposition rule for the adjoint of itself. For example, `Hadamard` was previously hardcoded as an operator that is its own adjoint, now there is a decomposition rule for `"Adjoint(Hadamard)"` which produces an instance of the base operator. - We removed the constraint that powers of an operator must be integers. Non-integer powers can be supported by adding custom decomposition rules for `"Pow(SomeOp)"`. All operators in PL which overrides `pow` now has a custom decomposition rule registered under the power of itself. - Defined some general stock decomposition rules that can be registered under any operator. For example, a `self_adjoint` decomposition rule is defined, and it is registered with all operators that are self-adjoint (to avoid having duplicate code) **Related Shortcut Stories:** [sc-90114] --------- Co-authored-by: Pietropaolo Frisoni <[email protected]>
…7362) **Context:** As a follow up to #7347, most of the custom logic for handling controlled decompositions can be generalized away. **Description of the Change:** - `controlled_resource_rep` now mirrors the custom dispatch logic of `qml.ctrl` for consistency. - We no longer refer to a hard-coded list of custom controlled operators when constructing the decomposition graph, instead, each operator that has a corresponding custom controlled operator now has a decomposition rule registered under its controlled version, e.g., decomposition rules added for `"C(H)"` that produces a `CH`. - Defined controlled decomposition rules for `QubitUnitary`, `H`, `X`, `Y`, `Z`, `SWAP`, `RX`, `RY`, `RZ`, `Rot`. `PhaseShift`, `GlobalPhase`. **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-90116] --------- Co-authored-by: Pietropaolo Frisoni <[email protected]> Co-authored-by: Yushao Chen (Jerry) <[email protected]>
Context:
Description of the Change:
Symbolic operator types can now be given as strings to the
op_type
argument ofadd_decomps
or as keys of the dictionaries passed to thealt_decomps
andfixed_decomps
arguments of thedecompose
transform, allowing custom decomposition rules to be defined and registered for symbolic operators.>>> print(qml.draw(circuit)()) 0: ──RX(-0.50)─╭●────────────┤ <Z> 1: ────────────╰X──RY(-0.50)─┤
Benefits:
Possible Drawbacks:
Related GitHub Issues:
[sc-89297]