Automatic differentiation (AD) computes exact derivatives of a program by applying the chain rule to every elementary operation it performs. In quantum control, this means the gradient of any figure of merit — a fidelity plus leakage penalties, a robustness average, a measure of entanglement — can be obtained without deriving it by hand. Since the late 2010s, AD frameworks built for machine learning (TensorFlow, PyTorch, JAX, Julia’s Zygote and Enzyme) have become a standard tool for pulse optimization, often on GPUs [1].

The idea

A simulation of controlled dynamics is a long chain of differentiable operations: build the Hamiltonian from the control parameters, propagate, evaluate the cost. AD differentiates such chains in one of two modes:

  • Forward mode carries derivatives along with the values. Its cost grows with the number of inputs, so it suits a few control parameters (GOAT is forward-mode differentiation of the Schrödinger equation).
  • Reverse mode (back-propagation) records the computation and then sweeps backwards. It gives the gradient of one scalar output with respect to all inputs at a cost of a small multiple of one evaluation, independent of the number of parameters.

GRAPE’s backward propagation is exactly reverse-mode differentiation, derived by hand for one specific cost function. AD generalizes it: change the cost, add constraints or penalties, make the Hamiltonian depend non-linearly on the controls — and the gradient follows automatically.

What it enabled

  • Composite cost functions. Fidelity, leakage to non-computational levels, pulse smoothness, power and occupation of forbidden states can be combined freely and weighted, with GPU acceleration [1].
  • Open systems at scale. Differentiating through stochastic quantum trajectories instead of the full density matrix avoids the \(d^2\) growth of Liouville space [2]; see Control of open quantum systems.
  • Differentiable programming. A neural-network agent that maps the current state to the control can be trained by differentiating through both the network and the equations of motion. This model-based alternative to reinforcement learning has been demonstrated for robust state preparation [3]; see Reinforcement & machine learning for control.
  • Integrated device workflows. Toolsets combine gradient-based pulse optimization with calibration and model learning on real hardware [4, 5]; see System identification for control.

Caveats

  • Memory. Reverse mode stores intermediate results. For long time grids or large systems this can exceed memory; checkpointing trades extra computation for memory. Semi-automatic differentiation uses the analytic GRAPE-type gradient for the dynamics and AD only for the final functional. This removes most of the memory and run-time overhead of full AD while still allowing practically any functional, including non-analytic ones such as the gate concurrence [6].
  • Matrix functions. Gradients through matrix exponentials, eigendecompositions and complex arithmetic must be supported correctly by the framework. Degenerate eigenvalues are a classic source of numerical trouble; see Numerical propagation & simulation.
  • Discretize-then-differentiate. AD returns the exact gradient of the discretized simulation. With adaptive ODE solvers this can differ from the gradient of the continuous problem, and adjoint-ODE methods offer an alternative.
  • Optimizers. AD supplies gradients; convergence still depends on the optimizer. Quasi-Newton methods suit smooth deterministic costs (Quasi-Newton & second-order methods); stochastic optimizers such as Adam suit noisy or sampled costs.