-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add CPhaseShiftGate with tests (#112) #114
Conversation
Codecov Report
@@ Coverage Diff @@
## master #114 +/- ##
=======================================
Coverage 98.14% 98.14%
=======================================
Files 3 3
Lines 54 54
=======================================
Hits 53 53
Misses 1 1
Continue to review full report at Codecov.
|
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 the submission @maliasadi
In addition to my listed suggestions, it would also be worth adding a test-case to the Python code (see here for example).
Also, before pushing, it is worth running make format
to ensure the C++ formatting conforms to the standards expected. You may need to install clang-format
for this to work.
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.
Hi @maliasadi thanks again for your work on this. I have some follow-up suggestions. Also, please be sure to run make format
before committing and pushing.
Also, just to note, the failing tests on Ubuntu 18.04 are due to an issue with the Github actions image we use. A fix is currently under review, and should solve 2 of those test failures. |
Thank you for your suggestions @mlxd. It's weird that the formatting is failed again! 🤔 make clean && \
pip install -e . && \
make test && \
make test-cpp && \
make format They are all pass on my side. Do you have any idea why formatting fails here? Also |
Ah yes, this is likely an older version of clang-format you have on your system. Certain formatting rules changed with v11+, so likely you have 10 or lower on Ubuntu 18.04.
Yes, this would be expected, as the PennyLane minimum supported Python version is 3.7. |
Yes, you're right! I was using clang-format-10. Thank you @mlxd! I think it's fixed 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.
Thanks @maliasadi, this looks great! Approved! Though we should coordinate merging this with #113.
* Add support for Controlled Phase Gate (CPhaseShift). | ||
[(#112)](https://github.com/PennyLaneAI/pennylane-lightning/issues/112) |
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.
* Add support for Controlled Phase Gate (CPhaseShift). | |
[(#112)](https://github.com/PennyLaneAI/pennylane-lightning/issues/112) | |
* Add support for Controlled Phase Gate (`CPhaseShift`). | |
[(#114)](https://github.com/PennyLaneAI/pennylane-lightning/pull/114) |
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 updating the log file! I update it only because I was asked to do before creating the pull-request.
: shift(std::pow(M_E, CplxType(0, phi))), matrix{1, 0, 0, 0, 0, 1, | ||
0, 0, 0, 0, 1, 0, | ||
0, 0, 0, shift} {} |
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.
Maybe nice to have the matrix part shown in a 4x4 grid to make it visually easy to see what's going on.
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.
(unless clang requires it to be like the above)
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.
This is re-arranged by clang-format, indeed!
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.
Yep, I think we may need to revisit clang formatting rules at a later date to better fix these.
|
||
void Pennylane::CPhaseShiftGate::applyGenerator( | ||
const StateVector &state, | ||
|
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.
"CRX", "CRY", "CRZ", "CRot"}; | ||
const vector<string> param_gates = { | ||
"RX", "RY", "RZ", "PhaseShift", "Rot", | ||
"CRX", "CRY", "CRZ", "CRot", "ControlledPhaseShift"}; |
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.
"CRX", "CRY", "CRZ", "CRot", "ControlledPhaseShift"}; | |
"CRX", "CRY", "CRZ", "CRot", "ControlledPhaseShift"}; |
As a follow up, I am happy to approve this too. I think it best to allow this PR be merged before #113 as the changes are significant. |
Well done on the PR @maliasadi ! |
Couldn't done it without your suggestions and supports. Thank you! |
Context:
Add support for Controlled Phase Gate (
CPhaseShift
).Description of the Change:
Implemented
CPhaseShift
gate mirroring existing C++ gate structures,as well as, tested and added to the list of supported gates.
Benefits:
In quantum computing, quantum logic gates are the building blocks of quantum circuits. To make a C++ support for entire gates in pennylane-lightning, this update is adding the missing 2-qubit
CPhaseShift
gate support.Possible Drawbacks:
Related GitHub Issues:
(#112) created by @mlxd