execute(tapes, device, execute_fn, gradient_fn, gradient_kwargs, _n=1, max_diff=2, mode=None)¶
Execute a batch of tapes with Torch parameters on a device.
This function may be called recursively, if
gradient_fnis a differentiable transform, and
_n < max_diff.
tapes (Sequence[QuantumTape]) – batch of tapes to execute
device (Device) – Device to use to execute the batch of tapes. If the device does not provide a
batch_executemethod, by default the tapes will be executed in serial.
execute_fn (callable) – The execution function used to execute the tapes during the forward pass. This function must return a tuple
(results, jacobians). If
jacobiansis an empty list, then
gradient_fnis used to compute the gradients during the backwards pass.
gradient_kwargs (dict) – dictionary of keyword arguments to pass when determining the gradients of tapes
gradient_fn (callable) – the gradient function to use to compute quantum gradients
_n (int) – a positive integer used to track nesting of derivatives, for example if the nth-order derivative is requested.
max_diff (int) – If
gradient_fnis a gradient transform, this option specifies the maximum order of derivatives to support. Increasing this value allows for higher order derivatives to be extracted, at the cost of additional (classical) computational overhead during the backwards pass.
mode (str) – Whether the gradients should be computed on the forward pass (
forward) or the backward pass (
A nested list of tape results. Each element in the returned list corresponds in order to the provided tapes.
- Return type
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry