-
Notifications
You must be signed in to change notification settings - Fork 624
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
Update qml.math.norm
for dispatching autograd
; stop rounding when postselecting
#4766
Conversation
Hello. You may have forgotten to update the changelog!
|
qml.math.norm
and qml.math.ndim
qml.math.norm
for dispatching autograd
[sc-50617] |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4766 +/- ##
==========================================
- Coverage 99.65% 99.65% -0.01%
==========================================
Files 387 387
Lines 34967 34711 -256
==========================================
- Hits 34847 34590 -257
- Misses 120 121 +1 ☔ View full report in Codecov by Sentry. |
qml.math.norm
for dispatching autograd
qml.math.norm
for dispatching autograd
; stop rounding when postselecting
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! just one concern about docs.
also curious, but this might be a more general discussion - is qml.math.norm
a standard thing to use? I figured we'd generally try to match the numpy API, in which case we should use qml.math.linalg.norm
.
Also, if that's the only problem, I wonder if we're better off fixing autograd norms in the pennylane/numpy
module instead of the math
module. do you have thoughts on any of those things?
There aren't any functions in
That's a good point, we could do that. @trbromley what are your thoughts about this? We could fix |
Co-authored-by: Christina Lee <[email protected]>
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! we can ignore my norm
rant for now. the function already exists in multi_dispatch, and we might as well lean on that. but fwiw, we do use qml.math.linalg.matrix_power
in a few places 😁
Context:
Differentiation of
qml.math.norm
does not work for L2 norm. This was causing incorrect gradients with autograd. Moreover, due to the rounding function, the gradient ofQNode
s being postselected is incorrect, so that needs to be removed.Description of the Change:
autograd
interface withqml.math.norm
whenord=None
andaxis=None
. Otherwise, we dispatch toscipy.linalg.norm
as we did before.qml.measure
docs about jitting with postselection on zero probability states.Benefits:
qml.math.norm
is differentiable for all interfaces forord=None
andaxis=None
.Possible Drawbacks:
Postselection with jitting can lead to incorrect results and errors if postselecting on a state with zero probability. However, this is an edge case that is not causing problems frequently.
Related GitHub Issues:
#4867