-
Notifications
You must be signed in to change notification settings - Fork 616
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
Add grouping support for arithmetic ops #5070
Conversation
[sc-53504] |
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.
Thanks @mudit2812
Great to see progress on grouping with arithmetic ops!
I gave it a first pass and there are honestly a lot of things that I dont quite understand yet. Could you help me by providing some context to the changes where I ask questions and generally add a description to the PR what the goal is as well as developer comments. Since there are no added tests it is hard to understand the context of the PR.
Re caching and Sum not having a coeffs attribute, I think this is something we wanted to add for feature parity anyway. If this attribute existed, would this make this PR any easier?
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5070 +/- ##
==========================================
- Coverage 99.68% 99.67% -0.02%
==========================================
Files 392 392
Lines 35844 35565 -279
==========================================
- Hits 35732 35448 -284
- Misses 112 117 +5 ☔ View full report in Codecov by Sentry. |
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.
looks awesome ⚛️ just a few little questions
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.
Great job @mudit2812 🥳
Left some comments on the pauli checks. Looks overall good though 👍
Co-authored-by: Korbinian Kottmann <43949391+Qottmann@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5070 +/- ##
==========================================
- Coverage 99.68% 99.67% -0.02%
==========================================
Files 394 394
Lines 36160 35875 -285
==========================================
- Hits 36047 35759 -288
- Misses 113 116 +3 ☔ View full report in Codecov by Sentry. |
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.
looks awesome. just left one suggestion to make sure we clean up in case of errors
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
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.
looks good to me now 👍
Context:
Adding support for
Prod
andSProd
to be used with grouping.Description of the Change:
Tensor.__matmul__
to stop mutating in-place and return a new op instead.Tensor
. Consequently,Tensor.copy()
andTensor.map_wires()
also had to be updated.Tensor__init__
to fix incorrect validation after the previous changes. The warning about overlapping wires is now raised inTensor.queue()
instead of at the beginning of construction, so that raising the warning pre-maturely can be prevented.qml.pauli.group_observables
now returnsProd
s if the observable list contains new arithmetic ops.pauli_to_binary
to rely on the Pauli rep. All operations that can be grouped should now always have a valid Pauli rep, so we don't need to worry about other cases, aspauli_to_binary
is only a utility function for grouping.are_pauli_words_qwc
to correctly handle ops with Pauli reps. This change however means that any new arithmetic ops that havepauli_rep=None
will still not work with this function. If we eventually start doing more simplification eagerly, this can be addressed.split_non_commuting
now createsProd
s instead ofTensor
s for creating observables for measurements that use wires. Also made a change so that if a measurement without any wires is made, the observable that is created usestape.wires
.Benefits:
Possible Drawbacks:
Related GitHub Issues: