Gradients and the parameter-shift rule
How a quantum circuit’s exact gradient is obtained from two extra runs, and what that costs.
7 min read · reviewed December 2026
Why gradients
Gradient descent moves each parameter against the slope of the cost. On a classical computer the slope comes from calculus. On a quantum device you cannot look inside the circuit, but you can run it at shifted parameter values.
The rule
For a gate of the form e^(−iθP/2), where P is a Pauli operator, the slope is exact and needs only two evaluations. For the RY rotations in this lab:
∂E/∂θ = [ E(θ + π/2) − E(θ − π/2) ] / 2
The lab’s test compares this rule with a finite-difference estimate for two different models and ansatz depths. The two agree to better than one part in a million.
What it costs
Every gradient needs two circuit evaluations per parameter. A four-qubit circuit with three layers has 16 parameters, so each optimiser step costs 32 evaluations plus one to record the energy. With 150 steps that is thousands of runs. On hardware every run itself means many shots.
Alternatives
Derivative-free methods, such as the Nelder-Mead search used for QAOA in this lab, need no gradients but take more steps as the number of parameters grows. The parameter-shift rule is usually credited to Mitarai et al. and Schuld et al.; check the originals for the exact conditions.
Try it
Questions
Is the parameter-shift rule an approximation?
No. For gates of this form it is exact. Only the finite number of measurement shots adds noise.
Why π/2?
The shift is tied to the gate’s eigenvalue structure. Other gates need other shifts or more terms.
Can I use finite differences on hardware?
You can, but with shot noise a small step makes the estimate very noisy.
Read next
Sources and further reading
- E. Farhi, J. Goldstone and S. Gutmann, “A Quantum Approximate Optimization Algorithm” (2014)
- A. Peruzzo et al., “A variational eigenvalue solver on a photonic quantum processor” (2014)
- A. Kandala et al., “Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets” (2017)
- J. McClean et al., “Barren plateaus in quantum neural network training landscapes” (2018)
- J. Preskill, “Quantum computing in the NISQ era and beyond” (2018)
- K. Mitarai et al. (2018) and M. Schuld et al. (2019) on analytic gradients of quantum circuits
Check the original sources for exact citations.