Computing Library › Quantum Ml
Quantum Ml

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

Kronos motion — parameter scan

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) = is f'(theta) = (f(theta + pi/2) - f(theta - pi/2)) / 2. This is not a finite-difference approximation; it is an exact identity for such gates, so it does not suffer the truncation error of numerical differentiation.

python
# 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

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.