Hands-on lab · 2 steps
Global versus local costs on a barren plateau
Quantify the barren plateau of the exactly solvable product model on . First compute the exact gradient variances of the global cost and the local cost at ; then estimate them by Monte Carlo from a black-box cost function, using the parameter-shift rule with exactly two circuit evaluations per random parameter vector.
Step 1: Exact gradient variances at n = 6
The product ansatz with acts on , and the angles are independent and uniform on . The two costs are
For give
(a) , the variance of the derivative of the global cost with respect to ;
(b) , the same for the local cost.
Enter two real numbers in this order. A decimal answer is accepted within a relative error of (plus an absolute ); an exact expression such as (1/8)*(3/8)^5 or 1/288 must be correct to within .
Step 2: Monte-Carlo gradient variance from a black-box cost
Complete the TypeScript function
gradientVariance(evaluate: (params: number[]) => number, n: number, samples: number, seed: number): number
What evaluate does. evaluate(p) runs the product circuit on and returns the exact cost , which is either or of the previous step (the tests use both; your code does not need to know which). p must be an array of exactly finite numbers; p[j-1] is the angle of qubit . Internally the cost is the expectation value of a Pauli operator whose all-identity term carries the constant: and . Every call is counted, as each would be one circuit execution on hardware.
What to compute. Create rng = mulberry32(seed) (import it with import { mulberry32 } from 'quantumcore';). For with samples:
- draw a fresh parameter vector
rng()for , in this order; - compute with the parameter-shift rule , where only the first entry is shifted: exactly two calls of
evaluateper sample, in total.
Return the unbiased sample variance with .
Tests. Each test calls gradientVariance(evaluate, n, 4000, seed). The values check compares your result with the exact variance from the lesson, (global) or (local), with a relative tolerance of . The calls check runs the same problems again (tests calls-…) and also requires exactly calls.
- global-n2 (visible): on qubits, seed , exact value .
- local-n2, global-n4, local-n4 (hidden): on qubits, on qubits and on qubits. Only their arguments are sent to your browser.
Why . A Monte-Carlo variance is itself random. Because , the relative standard error of the sample variance is with . For the global cost , which is at : the heavy tail of (rare samples where every factor is close to ) makes the estimate noisy, about at . The tolerance is five such standard errors; a missing factor in the shift rule is off by .