PennyLaneAI/pennylane-lightning

Add support for controlled phase gate (ControlledPhaseShift/CPhase)

Closed this issue · 2 comments

mlxd commented

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).

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 commented
  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.