qml.workflow.interfaces.autograd.autograd_execute

autograd_execute(tapes, execute_fn, jpc, device=None)[source]

Execute a batch of tapes with Autograd parameters on a device.

Parameters
  • tapes (Sequence[QuantumTape]) – batch of tapes to execute

  • execute_fn (Callable[[Sequence[QuantumTape]], ResultBatch]) – a function that turns a batch of circuits into results

  • jpc (JacobianProductCalculator) – a class that can compute the vector Jacobian product (VJP) for the input tapes.

Returns

A nested tuple of tape results. Each element in the returned tuple corresponds in order to the provided tapes.

Return type

TensorLike

Example:

>>> from pennylane.workflow.jacobian_products import DeviceDerivatives
>>> from pennylane.workflow.autograd import autograd_execute
>>> execute_fn = qml.device('default.qubit').execute
>>> config = qml.devices.ExecutionConfig(gradient_method="adjoint", use_device_gradient=True)
>>> jpc = DeviceDerivatives(qml.device('default.qubit'), config)
>>> def f(x):
...     tape = qml.tape.QuantumScript([qml.RX(x, 0)], [qml.expval(qml.Z(0))])
...     batch = (tape, )
...     return autograd_execute(batch, execute_fn, jpc)
>>> qml.grad(f)(qml.numpy.array(0.1))
-0.09983341664682815