pennylane icon indicating copy to clipboard operation
pennylane copied to clipboard

Adding `PSWAP` operation

Open antalszava opened this issue 2 years ago • 2 comments

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 to pennylane/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 and default.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.

antalszava avatar May 16 '22 17:05 antalszava

Hey @antalszava,

  1. What is the generator for this?
  2. Power is not some direct multiple of the parameters. How to add this? Or leave this?

ankit27kh avatar Jun 13 '22 01:06 ankit27kh

Hi @ankit27kh,

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

antalszava avatar Jun 14 '22 19:06 antalszava