-
Notifications
You must be signed in to change notification settings - Fork 625
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 double QubitUnitary bug from Catalyst #6926
Fix double QubitUnitary bug from Catalyst #6926
Conversation
@erick-xanadu we can try to test the affected tmrw. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6926 +/- ##
=======================================
Coverage 99.59% 99.59%
=======================================
Files 480 480
Lines 45495 45496 +1
=======================================
+ Hits 45310 45311 +1
Misses 185 185 ☔ View full report in Codecov by Sentry. |
@JerryChen97, yes I also tested it and it works! Thanks! I'm just running Catalyst tests to see if anything else breaks but I don't think so. I would also like to spend a little bit of time see if we can fix this in Catalyst. But it is good to know that there is a fix that solves it. |
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 @JerryChen97 , I left an alternative solution in the comments. Both solutions work. I think mine works because the previous operation was removed from the queue. I'm not entirely sure yet why your approach works. Do you know?
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.
Makes sense to me! 🚀
My approach was only considering the behavior diff between legacy The redundant However, I do have concerns about such hacky fix. Especially what if the other methods implemented in real On my end I would like to also try moving CQU to |
Do not merge until concerns were cleared |
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.
Can we just add it to ops_with_custom_ctrl_op
and remove the special QubitUnitary
logic? Looks to like it it should be able to fit that mold now.
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.
Requesting changes based on updating the name.
Never mind, I just realized |
Added full test suite to see if we broke any other pipelines |
Hello, from a quick pull request filter, it seems this is currently the only PR that needs gpu test suite run on it. I have changed the gpu test suite as part of #6927 . Please pull in latest master to ensure the gpu tests continue to be run. I will be disabling the existing gpu runners shortly. |
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.
Can we also add a test to make sure the bug is really fixed? Maybe something like:
with qml.queuing.AnnotatedQueue() as q:
qml.ctrl(qml.QubitUnitary(np.eye(2), 0), 1)
assert len(q.queue) == 1
No wry! After confirming nothing else broken we don't need GPU tests any more. I'll move labels |
@albi3ro Done! |
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.
Left a comment on the changelog entry, but looks good 👍
Co-authored-by: Christina Lee <[email protected]>
Context:
A recent deprecation #6840 deprecated the usage of
QubitUnitary
type inputbase
for instantiation ofControlledQubitUnitary
.However, a modification that was equivalent in PennyLane caused unexpected behavior in Catalyst, PennyLaneAI/catalyst#1494.
After investigation, it appears to be the issue with the private method
_try_wrap_in_custom_ctrl_op
ofpennylane/ops/op_math/controlled.py
, since it used to call the deprecatedinit
to directly use base asQubitUnitary
, and to safely deprecate it we decided to locally replace with equivalentControlledQubitUnitary(base=op.matrix(), ...)
, this caused Catalyst to received doubleQubitUnitary
.It is also noteable that the call
ControlledQubitUnitary
should not appear in this script, since logically all the classes living incontrolled_ops
depend oncontrolled.py
, which means that from the very beginning the affected private method served as a tricky hack with cyclic dependence.Therefore, we would like to replace the
ControlledQubitUnitary
call with a directControlledOp
.Description of the Change:
source files: as mentioned above.
tests: necessary improvements were made to correctly reflect the assertion results.
Benefits:
Possible Drawbacks:
Related GitHub Issues:
PennyLaneAI/catalyst#1494