-
Notifications
You must be signed in to change notification settings - Fork 196
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
Fix tutorial_pulse_programming101.py
to type cast expval
#1317
Conversation
👋 Hey, looks like you've updated some demos! 🐘 Don't forget to update the Please hide this comment once the field(s) are updated. Thanks! |
Thank you for opening this pull request. You can find the built site at this link. Deployment Info:
Note: It may take several minutes for updates to this pull request to be reflected on the deployed site. |
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 @andrijapau!
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.
lgtm
Context:
In PennyLaneAI/pennylane#6939, a fix was made to
qml.expval
so that it no longer silently converts the result to a real number. However, intutorial_pulse_programming101.py
we use a Hamiltonian with complex-typed coefficients. This resulted in an imaginary expectation value (X+0j
) and broke thejax.value_and_grad
function.Description of change:
Wrap the
qnode
function to get the expectation value and convert it to a real number. This allowsjax.value_and_grad
to be used and fixes the demo.