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

Expand out a tape so that it supports differentiation of requested operations.

This is achieved by decomposing all trainable operations that have Operation.grad_method=None until all resulting operations have a defined gradient method, up to maximum depth depth. Note that this might not be possible, in which case the gradient rule will fail to apply.

  • tape (QuantumTape) – the input tape to expand

  • depth (int) – the maximum expansion depth

  • **kwargs – additional keyword arguments are ignored


the expanded tape

Return type