-
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 error if differentiating diff_method=None #6770
Conversation
Hello. You may have forgotten to update the changelog!
|
…yLaneAI/pennylane into no-grad-on-diff-method-none
@albi3ro Should this be part of the release? |
Nope. It's changing architectural components and core behavior. |
…ck` (#6788) **Context:** While we have logic for sampling with jax, it does not really integrate very well into the workflow. While you can technically set `diff_method=None` right now and jit the execution end-to-end, trying to jit `diff_method=None` will cause incomprehensible error messages on non-DQ devices. We want to *forbid* differentiation `diff_method=None`, but keep a way to jit a finite shot execution. **Description of the Change:** In order to allow jitting finite shot executions, we need a way for the device to be able to configure whether or not the data is converted to numpy. To do so, we simply add another property to the `ExecutionConfig`, `convert_to_numpy`. If `False`, then we will not use a `pure_callback` to convert the parameters to numpy. If `True`, we use a `pure_callback` and convert the parameters to numpy. **Benefits:** Speed ups due to being able to jit the entire execution. ![image](https://github.com/user-attachments/assets/738076c6-7bb5-4c38-a8cc-97e138325dbc) **Possible Drawbacks:** `ExecutionConfig` gets an addtional property, making it more complicated. **Related GitHub Issues:** Fixes #6054 Fixes #3259 Blocks #6770 --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6770 +/- ##
=======================================
Coverage 99.60% 99.60%
=======================================
Files 476 476
Lines 45178 45181 +3
=======================================
+ Hits 44999 45002 +3
Misses 179 179 ☔ 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.
This is great 🚀 !
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! Just some good-to-have suggestions
Co-authored-by: Yushao Chen (Jerry) <chenys13@outlook.com>
**Context:** PR #6770 accidentally broke lightning, becasue we are now sending numpy data to lightning instead of autograd. The autograd arrays had slightly different casting rules. With numpy, we are no longer implicitly casting to integers. **Description of the Change:** Always cast the input to `BasisState` to integers. **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Context:
If someone tries to differentiate a qnode that has
diff_method=None
, they may get less-than-useful error message. We also assume that no interface parameters are used withdiff_method=None
Description of the Change:
Uses the ML boundary when
diff_method=None
and raises an informative error if differentiation is requested.Benefits:
ML parameters can be used with
diff_method=None
, and incorrect usage provides good error messages.Possible Drawbacks:
Related GitHub Issues:
Solves #6769 [sc-81490]