-
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
[unitaryHACK] Add the CPhase operation #1319
Conversation
Thanks @nahumsa! Let us know as soon as the PR is ready for review, and someone from the team will be on hand to answer any questions/provide a review 🙂 |
Hi @josh146. I guess this is ready for a review. |
Could someone clarify why the |
Is it ok just to remove |
Codecov Report
@@ Coverage Diff @@
## master #1319 +/- ##
=======================================
Coverage 98.16% 98.16%
=======================================
Files 148 148
Lines 11456 11457 +1
=======================================
+ Hits 11246 11247 +1
Misses 210 210
Continue to review full report at Codecov.
|
Hi @nahumsa, thank you for exploring this addition and identifying that we already have an equivalent gate! Could we create the alias by having CPhase = ControlledPhaseShift in the |
Sure! I thought about doing just that, but at the end I think I overcomplicated the solution. 😅 |
No worries at all! :) Let us know if you'd like us to go for another review round or if any questions come up. |
Would it be good to remove the tests as well, or should I keep it? Since it is exactly the same tests as |
The test cases could be removed and potentially the existing ones that test the eigvals and decomposition of @pytest.mark.parametrize("phi", [-0.1, 0.2, 0.5])
@pytest.mark.parametrize("cphase_op", [qml.ControlledPhaseShift, qml.CPhase])
def test_controlled_phase_shift_decomp(self, phi):
op = cphase_op(phi, wires=[0, 1])
(...) This will make sure that aliasing works fine. |
Awesome, just added this parameterized test, thanks! |
Great! 🙏 The aliasing could be used in framework-specific files too, so we could assign the |
Sure. I'll do that. |
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.
Awesome! :) This is looking great, left two comments, but very near being ready. 🙂
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 to me! 🎉 🙂 Thank you @nahumsa for your contribution and for tracking down how exactly it's best to have this addition! 💪
Thank you, @antalszava, for such an amazing guidance through this PR! 😄 |
Context: Add a new diagonal operator,
CPhase
.Description of the Change: Adds the
CPhase
operator as an alias for theControlledPhaseShift
operator.Benefits: Adds the
CPhase
diagonal operator.Possible Drawbacks:
It has the same structure asControlledPhaseShift
, maybe adds duplicated code that could be solved by usingCPhase
as an alias for theControlledPhaseShift
.Related GitHub Issues: closes #1147