The Parameter-Shift Rule
The parameter-shift rule computes exact gradients of a quantum circuit by evaluating the same circuit at two shifted parameter values.
Gradients on quantum hardware
Training a parameterized circuit by gradient descent requires derivatives of the loss with respect to gate angles. On a quantum device you cannot inspect the state to backpropagate; you can only run circuits and measure. The parameter-shift rule solves this: for a gate generated by a Pauli operator, the exact derivative of the expectation value equals the difference of the expectation at two shifted angles, divided by two.
The formula
For a rotation gate RG(theta) = exp(-i theta G / 2) with G having eigenvalues plus and minus one-half (Pauli generators), the derivative of the expectation f(theta) =
# Parameter-shift gradient for one angle (schematic)
import math
def param_shift_grad(circuit, theta, i, shots):
s = math.pi / 2
plus = theta.copy(); plus[i] += s
minus = theta.copy(); minus[i] -= s
return (circuit(plus, shots) - circuit(minus, shots)) / 2
Why exactness matters
Finite differences require a small step and amplify measurement noise as the step shrinks, forcing a bias-variance compromise. The parameter-shift rule uses a large, fixed shift and remains unbiased, so the only error is statistical from finite shots. This makes it the standard for hardware gradients despite its cost.
The cost
- Two circuit evaluations per parameter per gradient, so cost grows linearly in the number of parameters.
- Each evaluation needs many shots to control shot noise, multiplying the total execution count.
- Gates with more than two generator eigenvalues need generalized shift rules with more evaluation points.
Context and alternatives
The rule is the gradient engine of hybrid training. When parameter counts are large, gradient-free optimizers such as SPSA or stochastic variants that shift a random subset of parameters per step reduce the evaluation load. Combined with the quantum Fisher information, parameter-shift gradients enable natural-gradient descent, which often converges in fewer steps.