L7-02 · Variational circuits and parameter-shift gradients
Derive an exact gradient for a single Pauli-generated rotation.
Learn¶
A variational circuit contains adjustable gate parameters. A classical optimizer updates them using an estimated loss or gradient. The circuit expectation is a smooth mathematical function in the ideal model. Hardware estimates add finite-sample uncertainty and possible device bias.
For one gate exp(-i theta P/2), with P squared equal to identity, an expectation has only the relevant sine and cosine dependence on that parameter. Two shifted circuit evaluations therefore give its exact derivative. This is an analytic identity, not a small-step finite difference.
The simple two-shift rule assumes one occurrence of the parameter in the stated gate form. A shared parameter at several gates requires summing gate contributions or a suitable generalized rule. A nonlinear loss needs the chain rule. Noisy estimates still carry measurement variance.
Practice¶
Solution
The gradient is -sqrt(3)/2. The squared-loss derivative is 2(f-y) f prime. The parameter-shift rule supplies f prime; the loss itself also needs the classical chain rule.
Check your understanding¶
What is the basic two-shift rule for the stated gate?
A. A finite difference with an arbitrary tiny step
B. An exact expectation derivative under its generator assumptions
C. A zero-variance hardware estimator
Show the answer
B. An exact expectation derivative under its generator assumptions
The fixed shifts follow from the two-eigenvalue generator. The identity is exact for expectations, while finite-shot estimates still have uncertainty.
Sources¶
This lesson draws on Mitarai et al., 2018Schuld et al., 2019.
Next: L7-03 · Quantum kernels and data access
- Mitarai, K., Negoro, M., Kitagawa, M., & Fujii, K. (2018). Quantum Circuit Learning. Physical Review A, 98(3). 10.1103/PhysRevA.98.032309
- Schuld, M., Bergholm, V., Gogolin, C., Izaac, J., & Killoran, N. (2019). Evaluating analytic gradients on quantum hardware. Physical Review A, 99(3). 10.1103/PhysRevA.99.032331
- Bareinboim, E. (2025). Causal Artificial Intelligence: A Roadmap for Building Causally Intelligent Systems. https://causalai-book.net/