Skip to content
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 support for controlled phase gate (ControlledPhaseShift/CPhase) #112

Closed
mlxd opened this issue Jul 16, 2021 · 2 comments
Closed

Add support for controlled phase gate (ControlledPhaseShift/CPhase) #112

mlxd opened this issue Jul 16, 2021 · 2 comments

Comments

@mlxd
Copy link
Member

mlxd commented Jul 16, 2021

Use of the ControlledPhaseShift gate is currently supported by PennyLane default_qubit in Python (see here for supported gates and here for the Python implementation). This gate should also be natively supported in the C++ layer by lightning.qubit.

This will require the following steps:

  • A new ControlledPhaseShift class is created mirroring existing C++ gate structures (see here).
  • The new class is added to the list of supported gates.
  • The new class matches the functionality of the Python implementation.
  • Tests are added for the new gate (see here).
@maliasadi
Copy link
Member

Important notes to double-check before a pull request:
1. Named this new gate CPhaseShiftGate, to keep the name consistency of derived gates;
2. Added a bulk of comments describing this new gate at Gates.hpp:362;
3. Matched all functionalities of this new gate with the implemented ones, however, in comparison with the Python implm., there are _eigvals (returning eigenvalues), and decomposition methods that I wasn't sure about implementing them. Let me know if they are required too; and
4. Utilized gtest suites of lightning_gates_unittest.cpp to test new routines.

@mlxd
Copy link
Member Author

mlxd commented Jul 21, 2021

  1. Named this new gate CPhaseShiftGate, to keep the name consistency of derived gates;

Yep, that is fine.

  1. Added a bulk of comments describing this new gate at Gates.hpp:362;

Comments are usually a good call

  1. Matched all functionalities of this new gate with the implemented ones, however, in comparison with the Python implm., there are _eigvals (returning eigenvalues), and decomposition methods that I wasn't sure about implementing them. Let me know if they are required too; and

There should be no hard requirement for these, if they are not implemented for other existing C++ methods.

  1. Utilized gtest suites of lightning_gates_unittest.cpp to test new routines.

👍

We will do a review of the PR, and can make suggestions once it is created. Feel free to create it and tag people as needed.

mlxd added a commit that referenced this issue Jul 28, 2021
* Add CPhaseShiftGate with tests (#112)

* Add CPhaseShiftGate with tests (#112)

* Update support for ControlledPhaseShift Gate (#114)

* Update test-cases for ControlledPhaseShift Gate (#114)

* Update test-cases and formatting with clang-format-12 (#114)

Co-authored-by: Lee James O'Riordan <[email protected]>
@mlxd mlxd closed this as completed Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants