pennylane
pennylane copied to clipboard
Adding `PSWAP` operation
Context
We would like to define a new operation called PSWAP
, as defined in the PennyLane-Braket plugin.
Steps to take
Adding the operation
- Adding the
PSWAP
class and its attributes topennylane/ops/qubit/parametric_ops.py
. - Complete its docstring in a similar fashion as for other operations. Make sure the class is accessible through
qml.PSWAP
. - Add its decomposition, matrix, eigenvalues, adjoint and generator.
- Make sure the operation works with parameters from all interfaces (autograd, Torch, TensorFlow and JAX)
Adding devices support
- Add support for the operation in the
default.qubit
anddefault.mixed
devices
Testing
- Add the matrix to
pennylane/tests/gate_data.py
- Test the gate itself
- Test the gradients with multiple interfaces (autograd, torch, tensorflow and jax) with an analytical formula.
Notes
You can refer to the implementation and testings of IsingXX
, IsingYY
and IsingZZ
.
As an example, here is the implementation and the testing of the decomposition for the IsingYY
operation. The linked test file contains further test cases for IsingYY
.
Hey @antalszava,
- What is the generator for this?
- Power is not some direct multiple of the parameters. How to add this? Or leave this?
Hi @ankit27kh,
- It seems there may not actually be a generator found for this gate. If that's the case indeed, it's fine to leave this out. Thanks for catching this.
- It's okay to leave the definition of the power out of the gate definition in such a case (should fall back to the general case).