-
Notifications
You must be signed in to change notification settings - Fork 586
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
BugFix: Controlled.generator correctly projects with control values #5068
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5068 +/- ##
==========================================
- Coverage 99.67% 99.66% -0.01%
==========================================
Files 394 394
Lines 35670 35461 -209
==========================================
- Hits 35554 35343 -211
- Misses 116 118 +2 ☔ 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.
We should also add some tests to ensure this definition of the generator agrees with the qml.exp(op.generator(), 1j*op.data[0])
convention for a generator. op
and that exponential operator should have the same form.
We could potentially even add this check to assert_valid
:
https://github.com/PennyLaneAI/pennylane/blob/master/pennylane/ops/functions/assert_valid.py
to test generators more generally, but for now we should just check those two forms have the same matrix.
I added a quick check for this in the test case, is checking matrix equivalence the proper way of doing this? |
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.
Thanks for finding this and making a fix 🎉
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!
…5068) **Context:** `Controlled.generator` always projects onto the $\ket{1}$ space of the control wire without considering control values. **Description of the Change:** Now `Controlled.generator` correctly projects the operator based on the control value specified **Benefits:** Fixes a bug --------- Co-authored-by: Christina Lee <christina@xanadu.ai>
Awesome!! Just Linking to Shortcut story: [sc-55065] |
Context:
Controlled.generator
always projects onto theDescription of the Change:
Now
Controlled.generator
correctly projects the operator based on the control value specifiedBenefits:
Fixes a bug