Case Study 1: The Barren Plateau That Was One Gate
The measurement
§16.6 needed to demonstrate barren plateaus, and the demonstration is straightforward: build a hardware-efficient ansatz, initialize it randomly many times, measure the gradient, and watch the variance shrink as qubits are added.
The natural implementation samples one parameter — the same index each time, so the sizes are comparable — across many random initializations.
grads = []
for _ in range(60):
w = pnp.array(rng.uniform(0, 2*np.pi, shape), requires_grad=True)
g = qml.grad(circuit)(w)
grads.append(float(np.asarray(g).flatten()[0])) # <- one parameter
The result was spectacular.
qubits layers Var[grad] |grad| mean
2 4 9.813e-33 7.937e-17
3 4 9.679e-33 7.997e-17
4 4 7.093e-33 6.582e-17
5 4 3.154e-33 4.777e-17
6 4 2.829e-33 4.278e-17
7 4 1.404e-33 2.823e-17
8 4 6.942e-34 2.050e-17
fit: Var[grad] ~ exp(-0.455 n) halving every 1.52 qubits
Var(2)/Var(8) = 14.1x
Monotonic. Exponential. A clean fit. And completely wrong.
The thing that did not add up
Gradients of $10^{-17}$ and variances of $10^{-33}$.
$10^{-17}$ is not "small." It is machine epsilon — the scale at which a float64 stops being able
to represent a difference at all. np.finfo(float).eps is about $2.2\times10^{-16}$.
A barren plateau is supposed to produce gradients that are small relative to the landscape — $10^{-3}$, $10^{-6}$, eventually $10^{-8}$ at fifty qubits. Getting $10^{-17}$ at two qubits is not a plateau. It is a zero that has picked up floating-point dust.
And the giveaway was in the very first row: at two qubits, on a four-layer ansatz with 36 parameters, a randomly-initialized circuit should have perfectly healthy gradients. There is nothing to be flat about. Two qubits is a trivially small landscape.
The investigation
Print the whole gradient array rather than one entry of it.
gradient array shape (4, 3, 3) (layers, wires, 3 Rot angles)
g[0,0,0] first RZ of the first Rot, acting on |0> = 9.714e-17
g[0,:,0] that same angle on every wire = [0. 0. 0.]
g[2,1,1] a middle-layer angle = -0.143103
max |gradient| over all 36 parameters = 0.495574
The real gradients are $\mathcal{O}(0.1)$. The sampled one is $10^{-17}$. They differ by sixteen orders of magnitude, and the measurement had been reporting the wrong one for every qubit count.
Why that specific parameter is exactly zero
qml.StronglyEntanglingLayers applies Rot(φ, θ, ω) to each wire, and PennyLane's Rot is
$$\text{Rot}(\phi, \theta, \omega) = R_Z(\omega)\,R_Y(\theta)\,R_Z(\phi)$$
so the first operation on each wire is an $R_Z$. In the first layer, that $R_Z$ acts on a qubit still in $|0\rangle$:
$$R_Z(\phi)\,|0\rangle = e^{-i\phi/2}\,|0\rangle$$
A global phase. Unobservable, by the argument Chapter 3 §3.5 made and Chapter 6's QASM round-trip made concrete. No expectation value can depend on $\phi$, so
$$\frac{\partial\langle O\rangle}{\partial\phi} = 0 \quad\text{identically}$$
Not approximately. Not on average. Exactly zero, for every input, at every qubit count, forever.
Index [0,0,0] is precisely that parameter, and g[0,:,0] = [0. 0. 0.] shows all three wires share
the property.
The residual $10^{-17}$ is floating-point noise in the parameter-shift subtraction of two nearly identical numbers.
Why the fake result looked so convincing
This is the part worth dwelling on, because the artifact did not merely produce a wrong number — it produced a wrong number with all the qualitative features of the right answer.
It was monotonic. Variance decreased at every step from 2 to 8 qubits.
It was exponential. A clean fit, $\exp(-0.455n)$, with no obvious outliers.
It had a plausible magnitude ordering. 14.1× over six qubits is the right kind of number.
And it decayed for a real reason — just not the advertised one. As qubit count grows, the parameter-shift evaluations involve larger state vectors, so the floating-point cancellation noise in computing an identically-zero derivative drifts downward. The artifact had its own physics, and that physics happened to be monotonic in $n$.
Had the investigation stopped at "the fit looks good," the chapter would have published a barren plateau eighteen orders of magnitude more severe than the real one, complete with a graph.
The correct measurement
Sample all parameters, and exclude the structurally-zero ones explicitly:
g = np.concatenate(all_gradients)
g = g[np.abs(g) > 1e-14] # drop structural zeros, and COUNT them
qubits params Var[grad] max|grad| samples excluded
2 36 1.0431e-01 0.8841 1200 240
6 108 8.0048e-03 0.3712 3760 560
10 180 4.6517e-04 0.0920 5400 1800
fit: Var[grad] ~ exp(-0.676 n) -> x0.5086 per qubit
halving every 1.03 qubits
Var(2)/Var(10) = 224.2x
×0.51 per qubit — within 2% of exactly one half, which is the textbook $\mathcal{O}(2^{-n})$ result. The real effect is stronger than the artifact suggested (halving every 1.03 qubits versus 1.52) and lives at a completely different magnitude.
Note the excluded column. The exclusions are reported, not silent. §16.7's whole lesson is that
a silent filter is how this goes wrong; a filter that announces "I dropped 1,800 values" invites the
question of what they were.
The three-way discriminator
The general fix, which vqelab.variational.classify_zero_gradient implements:
| Cause | Signature | Response |
|---|---|---|
| Structurally zero | exactly ~1e-17 at every parameter value and every size | fix the ansatz, or exclude and log |
| Disconnected from the observable | exactly zero; the parameter's gates are on unmeasured wires | ansatz bug (§16.4) |
| Barren plateau | small but nonzero, varying between draws, shrinking with width | the real problem |
The discriminator is one line: resample and look again. A structural zero stays at $10^{-17}$. A plateau gradient is a genuine random variable that happens to be small — nonzero, and differently sized on each draw.
The lessons
A value near machine epsilon is an artifact until proven otherwise. $10^{-17}$ is not a small number; it is the absence of a number. Any measurement landing there should be interrogated before it is plotted.
A convincing fit is not evidence of a correct measurement. Monotonic, exponential, well-fitted, and about the wrong quantity. The artifact was more internally consistent than the real signal, because floating-point noise is smoother than actual physics.
Sample the population, not a representative. One parameter was chosen because it made sizes comparable — a defensible reason — and it happened to be the single most pathological parameter in the ansatz. Averaging over all 36 would have been correct on the first attempt and cost nothing.
Know your ansatz's structure. Rot starting with $R_Z$ is documented, ordinary, and completely
harmless in use — it only matters when you are measuring gradients of it. The trap needed both the
ansatz's structure and the measurement's design to line up.
And the recurring one, now for the sixth time: a number can be precise, reproducible, and about something other than what you think. Chapter 11's phase damping, Chapter 12's averaged readout statistic, Chapter 13's inert DD pass, Chapter 14's symmetric Bell test, Chapter 15's logical-versus- physical qubit counts, and now this. The reproducibility of a wrong number is not evidence for it.
Reproduce it: code/example-05-barren-plateaus.py Part 0 demonstrates the artifact and Part 1 the
real measurement; classify_zero_gradient in code/project-checkpoint.py implements the
discriminator.