Custom parameterised gates on default device

Is there a good way to declare a custom unitary gate (ideally from a matrix representation) with learnable parameters? I tried to subclass pennylane.operations.Operation in a similar fashion to pennylane.ops.qubit.QubitUnitary, but couldn’t get past the following error “DeviceError: Gate MyCustomGate not supported on device default.qubit.autograd”. I couldn’t see how but perhaps it is possible to use QubitUnitary directly to create a trainable gate? Any help much appreciated!

Hi @DanielPolatajko!

Check out ArbitraryUnitary, which provides a parametrization of an arbitrary n qubit unitary into 4 ** n - 1 real parameters.

Thanks!

1 Like

Sweet, thanks very much!

No problem @DanielPolatajko! Let us know if you have any further questions.