qml.transforms.expand_invalid_trainable_hadamard_gradient

expand_invalid_trainable_hadamard_gradient(tape, depth=10, **kwargs)

Expand out a tape so that it supports differentiation of requested operations with the Hadamard test gradient.

This is achieved by decomposing all trainable operations that are not in the Hadamard compatible list until all resulting operations are in the list up to maximum depth depth. Note that this might not be possible, in which case the gradient rule will fail to apply.

Parameters
  • tape (QuantumTape) – the input tape to expand

  • depth (int) – the maximum expansion depth

  • **kwargs – additional keyword arguments are ignored

Returns

the expanded tape

Return type

QuantumTape