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
Support arbitrary generating terms in pulse Hamiltonians with stoch_pulse_grad
#4132
Conversation
…e into hybrid-pulse-diff-0
Codecov Report
@@ Coverage Diff @@
## master #4132 +/- ##
=======================================
Coverage 99.77% 99.77%
=======================================
Files 340 340
Lines 30595 30607 +12
=======================================
+ Hits 30525 30537 +12
Misses 70 70
|
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.
Very nice upgrade @dwierichs 💪
Much appreciate the developer comments 🤩
There is a slight performance regression on the first execution as ParametrizedHamiltonian
gets jit compiled inside the ODE solver (because the ode fun
is jit-compiled), most likely due to the extra steps from qml.exp
, so dont think there is much we can do. Could short-cut the execution by checking whether it is a pauli word, but that might make the code significantly uglier.
Execution time seems unchanged 👍
I tried this and it seems to be fine to me, actually 😇 Let me know what you think :) edit: The definition of |
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.
Very neat upgrade with not many changes in code and tests, really nice work @dwierichs 👌
With the upcoming short-cutting for Pauli-words looks good to me 🙂
@Qottmann while fixing the bug in #4156 I found a simple way to extract the prefactor of a Pauli word that I didn't see before. I used this to implement the |
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.
Couple of questions and suggestion, otherwise it looks good 💯
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 for fixing the short-cut for pauli words 👌 Jit times look much better compared to current master for those cases. Execution time is the same 👍
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
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 a lot! 👍
Context:
Thus far, the gradient transform
stoch_pulse_grad
only supports Pauli words as generating terms in the pulse Hamiltonian.Description of the Change:
This PR generalizes the support to arbitrary generating terms, using the existing generalized shift rule framework.
The inserted operations are no longer
PauliRot
gates butExp
operators, because for non-Pauli word generators, the decomposition into Pauli rotation gates is not always desired.Decomposing
Exp
operations with Pauli words in the exponent yields back thePauliRot
operations used bystoch_pulse_grad
until now.Benefits:
Support many more pulse Hamiltonians, in particular e.g. neutral atom Hamiltonians.
Possible Drawbacks:
Breaking change: For Pauli word-generated terms, the inserted operations are now
Exp
operations instead ofPauliRot
gates.Open TODOs
[sc-34236]