Parameter-shift gradients
Exact derivative identities for expectation values whose parameterized gates have an appropriate generator spectrum.
Also called parameter shift rule
On this page
Definition and significance
A parameter-shift rule obtains a derivative from circuit expectation values evaluated at finite parameter offsets. For certain generators it is exact, unlike a small-step finite-difference approximation. It is useful in variational optimization because quantum devices naturally supply expectation estimates rather than differentiable internal state arrays.
The rule depends on the generator's eigenvalues and on how a parameter occurs in the circuit. A familiar two-evaluation identity cannot be applied indiscriminately to every parameterized operation or to a parameter reused in several gates.
Mechanism and mathematical treatment
For a gate exp(-i theta P/2) with P^2=I and a parameter appearing only in that gate, the expectation f(theta) has the form a+b cos(theta)+c sin(theta). Differentiating gives -b sin(theta)+c cos(theta). Evaluating the shifted difference gives [f(theta+pi/2)-f(theta-pi/2)]/2, exactly the same expression.
If one parameter controls multiple gates, the product rule sums contributions from each occurrence unless a valid global-frequency rule is used. More general generator spectra produce more frequencies and require generalized shift rules. Finite shots add statistical uncertainty even when the analytic identity is exact.
Fully worked reference example
For R_Y(theta)|0> and observable Z, f(theta)=cos(theta). At theta=pi/3, the true derivative is -sqrt(3)/2. The shifted values are cos(5pi/6)=-sqrt(3)/2 and cos(-pi/6)=sqrt(3)/2. Their half-difference is -sqrt(3)/2 exactly.
If each shifted expectation is independently estimated with N shots, the gradient variance is [Var(f_plus)+Var(f_minus)]/4. For this example each Z variance is 1-3/4=1/4, giving gradient-estimator variance 1/(8N). The derivative identity has no truncation error, but its measured estimate is still noisy.
Limitations and common misconceptions
A small true gradient may require many shots to resolve. Exact shift formulas do not cure barren plateaus, a poor ansatz or optimizer instability. Gradients of noisy hardware behavior can differ from gradients of the ideal circuit objective, especially when noise depends on the parameter.
Scientific relationships
Suitable circuit parameters can be differentiated through shifted expectation evaluations.
Supported gradients can be evaluated through shifted circuits.
A two-parameter gradient with complete shifted values
Prepare R_Y(theta)|0> on q0, apply CNOT q0->q1, and then apply R_Y(phi) on q1. For the observable X0X1, conjugating the final rotation gives an expectation f(theta,phi)=sin(theta)cos(phi). The two derivatives are cos(theta)cos(phi) and -sin(theta)sin(phi). Each parameter occurs in one Pauli-generated rotation, so the ordinary two-point shift rule applies separately to each occurrence.
At theta=pi/3 and phi=pi/4, f=sqrt(6)/4. Shifting theta by plus and minus pi/2 gives sqrt(2)/4 and -sqrt(2)/4, so the half-difference is sqrt(2)/4. Shifting phi gives -sqrt(6)/4 and sqrt(6)/4, so the half-difference is -sqrt(6)/4. These are the exact analytic derivatives. No small displacement or finite-difference limit is involved.
If each shifted Pauli expectation uses N independent shots, the theta-gradient variance is [7/8+7/8]/(4N)=7/(16N). The phi-gradient variance is [5/8+5/8]/(4N)=5/(16N). Thus two gradient components can have different measurement uncertainty even though they use the same number of circuits and the same shift size. A gradient vector should not be assigned one undifferentiated error bar without its component variances and any correlations.
A reused parameter invalidates a naive global shift
Consider R_Y(theta)R_Y(theta)|0>, measured with Z. The two rotations combine to R_Y(2theta), giving f(theta)=cos(2theta). Its derivative is -2sin(2theta). Applying the usual half-difference with global shifts plus and minus pi/2 gives zero, because both shifted values equal -cos(2theta). The failure comes from treating two parameter occurrences as if they were one generator with the original frequency.
One correct approach assigns independent formal parameters theta1 and theta2, computes the derivative with respect to each occurrence, and then sets both equal to theta. Each partial derivative is -sin(theta1+theta2), so their sum is -2sin(2theta). The occurrence-specific shift changes only one gate at a time. This method follows the ordinary chain rule and does not require guessing the global Fourier spectrum.
For this simple merged circuit, a valid global rule also exists: f'(theta)=f(theta+pi/4)-f(theta-pi/4). Its coefficient is one because the frequency is two. At theta=pi/12 the shifted values are -1/2 and +1/2, giving derivative -1. This agrees with -2sin(pi/6). The example illustrates that an exact finite shift is determined jointly by generator scaling, parameter reuse and the resulting frequency content.
Classical postprocessing needs its own chain rule
Suppose a loss is L(theta,phi)=f(theta,phi)^2. Then its derivatives are 2f times the corresponding derivatives of f. At the worked point, the theta derivative is sqrt(3)/4 and the phi derivative is -3/4. Applying the same two-point Pauli shift directly to L can fail because squaring f introduces new Fourier frequencies. The quantum expectation and the classical loss are different functions.
An estimator formed by multiplying a noisy f estimate and a noisy gradient estimate has additional statistical properties. If the two estimates are independent and individually unbiased, their product is unbiased for the product of means. If they reuse correlated data, the product expectation includes their covariance. The variance also contains terms from both factors. Exactness of the underlying shift identity does not automatically make an arbitrary hybrid loss estimator unbiased.
For a general gate exp(-i theta G) with two eigenvalues separated by frequency omega, the expectation has a constant plus sine and cosine terms at omega. A shift s with sin(omega s) nonzero gives derivative omega[f(theta+s)-f(theta-s)]/[2sin(omega s)]. Choosing s=pi/(2omega) gives the maximal denominator magnitude. Additional generator eigenvalue differences introduce additional frequencies and require a rule that resolves them.
Noise and reference semantics
If a parameter-independent quantum channel follows the parameterized gate, the expectation can retain the same sinusoidal form because the channel is linear and independent of theta. A shift identity may then differentiate the noisy expectation exactly. If the noise itself changes with the gate parameter, shifted circuits sample different channels, and the ideal-generator proof no longer captures the entire derivative. The physical objective being differentiated must be specified.
The complete reference procedure is to identify each parameter occurrence, inspect its generator spectrum, construct the permitted shifted circuits, evaluate their expectations, combine them with the correct coefficients, and apply any classical chain rule. For these small examples, direct matrix differentiation and ordinary trigonometric differentiation provide independent checks. They do not require a quantum SDK.
A cheaper gradient can spend its savings on an omitted direction
A variational routine may require many expectation-value measurements to estimate a gradient. Measuring only a subset of parameters appears to reduce the work, but the omitted directions can contribute a systematic error to the update. The fair comparison asks how both choices meet the same gradient-error target. The model uses a standard two-shift estimator where each derivative is half the difference of two independent sample means. Summing the coordinate variances gives an expected squared Euclidean sampling error. A subset estimator receives an additional squared-error contribution from the known synthetic gradient components it omits. If that contribution already exceeds the target, no number of extra shots on the retained coordinates can repair the estimate. The omitted norm is supplied by construction, which is a major advantage unavailable in most real optimization runs. The calculation belongs alongside a discussion of screening, pilot estimates or structural assumptions used to select parameters. It explains what a claimed measurement saving must preserve, while avoiding the claim that an actual algorithm can discover harmless omissions without paying for information.
Model: Derivative estimate = (mean_plus - mean_minus)/2; Per-coordinate variance with n shots per shift = v/(2n); Full expected squared gradient error = parameters × v/(2n); Subset total = omitted squared norm + active_parameters × v/(2n) Assumptions: The gate supports the stated parameter-shift rule. Shifted measurements and coordinates are independently estimated. Omitted-gradient norm is known only in this synthetic example.
Measuring fewer coordinates can reduce work or consume the error budget through omitted directions. The omitted-gradient norm is provided by construction here; an actual optimizer normally does not know it for free. Parameter-shift identities require an appropriate gate generator and shift rule. Correlations within or between the two shifted sample means can change each coordinate variance; cross-coordinate covariance alone does not change the trace-based squared-error sum.
Limitations: A small gradient error does not guarantee an optimizer converges. An omitted norm cannot normally be assumed known without a measurement or structural model.
| Quantity | Value |
|---|---|
| Total parameters | 12 |
| Active subset parameters | 4 |
| Per-shift shot variance | 0.4 |
| Squared gradient-error target | 0.01 |
| Squared norm of omitted gradient | 0.001 |
| Shot time, milliseconds | 0.1 |
| Calculated quantity | Synthetic result |
|---|---|
| Shots per shift, full gradient | 240 |
| Total full-gradient shots | 5760 |
| Full-gradient acquisition, seconds | 0.576 |
| Subset remaining squared-error budget | 0.009 |
| Total subset-gradient shots | 712 |
| Subset acquisition, seconds | 0.0712 |
A derivative experiment still has a sampling budget
For f(theta) = cos(theta), with theta in radians, f'(theta) = [f(theta + pi/2) - f(theta - pi/2)]/2. At theta = pi/6 the derivative is -0.5. Each shifted expectation is estimated using 1,000 independent {-1,+1} outcomes, with the two batches also independent. Their true expectations are -0.5 and +0.5; each individual outcome has variance 1 - 0.5^2 = 0.75. Therefore the derivative estimator has variance (0.75/1000 + 0.75/1000)/4 = 0.000375 and standard deviation 0.019365. This uses 2,000 outcomes. Individual estimates fluctuate around the true derivative.
Sources
Verification scope
Recorded source check ·
Full official API page retrieved, 554 lines; shift recipes and generator frequencies inspected.
Formal or reference-semantic source anchor only; no SDK execution, hardware run, or empirical advantage is asserted. Original worked examples are independent mathematical constructions.
Verification scope
Selected source text checked ·
Formal or reference-semantic source anchor only; no SDK execution, hardware run, or empirical advantage is asserted. Original worked examples are independent mathematical constructions.
Verification scope
Evaluating analytic gradients on quantum hardware
Maria Schuld, Ville Bergholm, Christian Gogolin, Josh Izaac, Nathan Killoran · · Research paper · Publication status unspecified · arXiv · DOI 10.1103/PhysRevA.99.032331Full-text source check ·
Full8-page PDF indexed; generator-spectrum condition for two-point shift inspected.
Exact expectation identities do not remove finite-shot variance; generators with more frequencies require appropriate generalized rules.
Evaluating analytic gradients on quantum hardware
Reference · arXivCitation identity checked ·
This check establishes the source title and link. Scientific claim review is separate.
Verification scope
Citation identity checked ·
This check establishes the source title and link. Scientific claim review is separate.