-
Notifications
You must be signed in to change notification settings - Fork 575
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 ControlledPhaseShift #1338
Fix ControlledPhaseShift #1338
Conversation
Wow! Great catch @ryanlevy. Thanks for this! This is something that definitely should have been picked up by our tests, so a sign that our tests are lacking 🙂 Do you think you will be able to add a test that ensures the decomposition is correct for a weird set of wires (e.g., It could be something as simple as original_mat = qml.ControlledPhaseShift(x, wires=[2, 0]).matrix
decomposed_mats = [op.matrix for op in qml.ControlledPhaseShift.decomposition(x, wires=[2, 0])] and performing matrix multiplication to ensure that the original matrix and decomposed matrix match. |
By the way, don't forget to update the changelog with a link back to this PR, and add your name to the contributors section :) |
Codecov Report
@@ Coverage Diff @@
## master #1338 +/- ##
=======================================
Coverage 98.16% 98.16%
=======================================
Files 145 145
Lines 11093 11093
=======================================
Hits 10889 10889
Misses 204 204
Continue to review full report at Codecov.
|
Thanks for the reminder! I've updated the tests, but the (see #1313) |
Ah, of course! This is because PennyLane allows arbitrary labels for wires (e.g., The only time wire ordering can be deduced is if the operation is provided alongside a device --- the ordering of the wires on the device is considered canonical. |
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 from my end, thanks @ryanlevy!
Context:
In PR #1064 the new ControlledPhaseShift was added, however the CNOT wires are fixed to 0 and 1 instead of the user input
Description of the Change: Wires in the CNOT decomposition are no longer fixed to 0 and 1
Benefits: Fixes new operation
Possible Drawbacks: None
Related GitHub Issues: None?