-
Notifications
You must be signed in to change notification settings - Fork 605
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 qml.commutator function #5051
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5051 +/- ##
==========================================
+ Coverage 99.36% 99.68% +0.31%
==========================================
Files 392 393 +1
Lines 35850 35602 -248
==========================================
- Hits 35623 35489 -134
+ Misses 227 113 -114 ☔ View full report in Codecov by Sentry. |
[sc-53926] |
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 great Korbinian! Happy to approve once the tests are updated with the bugfix for qml.equal
with Sum
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.
Left some documentation formatting concerns, but once those are resolved, I'll be happy to approve 👍
Thanks christina! Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@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.
We may need to retrigger the CI to get codecov to work, but looks good nonetheless.
Adding native commutators for paulis. Works between `PauliSentence` and any of `Operator, PauliWord, PauliSentence` Builds on top of #5051 Todo - [x] Basic functionality - [x] Basic functionality tests - [x] update qml.commutator - [x] changelog --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: Christina Lee <christina@xanadu.ai>
…r possible (#5098) Upgrade qml.commutator to use pauli artihmetic whenever that is possible (i.e. whenever both operators have a `pauli_rep`. This was initiated in #5051 (comment) Similar things could be done in qml.dot and other points of the codebase. The grander idea is to use fater pauli arithmetic under the hood whenever that is possible. The main feature of this update is performance: ```python op1 = qml.dot(range(30), [X(i) @ X(i+1) for i in range(30)]) op2 = qml.dot(range(30), [Y(i) @ Y(i+1) for i in range(30)]) %timeit qml.commutator(op1, op2) # on main branch 11.9 ms ± 32.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) %timeit qml.commutator(op1, op2) # this branch 1.28 ms ± 3.42 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) ``` - [x] Basic functionality - [x] Handle Zero case (empty PauliSentence) with 0 * Identity() - [x] Add test ensuring pauli route is taken - [x] All tests pass - [x] Test mixed cases (ops and Paulis) - [x] changelog [sc-56865] --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: Christina Lee <christina@xanadu.ai>
A function to compute commutators between operators, PauliWord and PauliSentence instances.
Work in progress, happy to hear early feedback!