Quantum Computation & Cryptography · Lecture 24

Lecture 24
Near-Term Algorithms and Honest Advantage

Week 13  |  simulation, variational algorithms, what they can and cannot do yet, and how to read a quantum-advantage claim  |  reading: IBM Quantum Learning, "Variational algorithm design", lessons 1–2; de Wolf Ch. 9

Cartoon: the valleyA stick figure stands on a wide, flat plain that stretches to the horizon, holding a spirit level. Far away there is a narrow valley. A speech bubble says: the gradient here is zero to six decimal places. Which way is down? the gradient here is zeroto six decimal places.Which way is down?
a barren plateau: for large random circuits, the energy landscape is almost perfectly flat almost everywhere, and the minimum hides in a tiny region
In this lecture
  1. Simulating quantum systems
  2. The variational principle and VQE
  3. Gradients and optimizers
  4. What it costs to measure an energy
  5. QAOA for MaxCut
  6. Barren plateaus
  7. Quantum machine learning: what is known
  8. Utility, advantage, and how to read a claim
  9. Try it in code
  10. Where to go next, and the course in one page
  11. Summary and exercises

The algorithms of Block II need error-corrected machines. This lecture asks what can be done before then, and how to tell a real result from a press release. By the end you should be able to estimate the number of Trotter steps a simulation needs, explain why the variational principle makes VQE an upper-bound method, compute a gradient by the parameter-shift rule, estimate the number of shots an energy measurement costs, set up QAOA for MaxCut and read its landscape, explain barren plateaus, and apply a checklist to a quantum-advantage claim.

1 — Simulating quantum systems

Feynman's original argument for quantum computers (1982) was simulation: a classical description of \(n\) interacting quantum particles needs \(2^n\) numbers, but a quantum computer could imitate the system directly. The task is to apply the time-evolution operator \(e^{-iHt}\) of a Hamiltonian \(H\), a Hermitian matrix whose eigenvalues are the system's energy levels. Physical Hamiltonians are sums of local terms, each acting on a few particles, and each term's exponential is a small circuit. The terms do not commute, so \(e^{-i(A+B)t}\ne e^{-iAt}e^{-iBt}\) in general; the fix is to alternate in small steps.

definition 24.1 — Trotter–Suzuki formulas

For \(H=A+B\), time \(t\) and \(r\) steps, the first-order Trotter formula is \(S_1=\big(e^{-iAt/r}e^{-iBt/r}\big)^r\), and the second-order (symmetric) formula is \(S_2=\big(e^{-iAt/2r}e^{-iBt/r}e^{-iAt/2r}\big)^r\).

proposition 24.1 — the first-order Trotter error

\(\big\|e^{-i(A+B)t}-S_1\big\|\le\dfrac{t^2}{2r}\,\big\|[A,B]\big\|\), where \(\|\cdot\|\) is the operator norm and \([A,B]=AB-BA\).

Proof. One step first, with \(\delta=t/r\). Let \(U(s)=e^{-i(A+B)s}\) and \(W(s)=e^{-iAs}e^{-iBs}\). Since \(W(0)=U(0)=I\), \(W(\delta)-U(\delta)=\int_0^\delta\frac{d}{ds}\big[U(\delta-s)W(s)\big]\,ds=\int_0^\delta U(\delta-s)\big(W'(s)+i(A+B)W(s)\big)ds.\) Now \(W'(s)=-iAW(s)-ie^{-iAs}Be^{-iBs}\), so \(W'(s)+i(A+B)W(s)=i\,[B,e^{-iAs}]\,e^{-iBs}\). Writing \([e^{-iAs},B]=-i\int_0^se^{-iAu}[A,B]e^{-iA(s-u)}du\) shows \(\|[B,e^{-iAs}]\|\le s\|[A,B]\|\). Unitaries have norm 1, so \(\|W(\delta)-U(\delta)\|\le\int_0^\delta s\,\|[A,B]\|\,ds=\tfrac{\delta^2}{2}\|[A,B]\|\). For \(r\) steps, telescope: \(W^r-U^r=\sum_{j=0}^{r-1}W^{j}(W-U)U^{r-1-j}\), so \(\|W^r-U^r\|\le r\,\|W-U\|\le r\cdot\frac{t^2}{2r^2}\|[A,B]\|\).

So the error falls like \(1/r\), and a target accuracy \(\epsilon\) needs \(r\approx t^2\|[A,B]\|/(2\epsilon)\) steps. The second-order formula cancels the leading error term by symmetry and its error falls like \(1/r^2\); higher orders exist, as do methods with even better scaling (qubitization, linear combinations of unitaries), which are beyond this course.

For some splitting \(H=A+B\), \(\|[A,B]\|=4\). How many first-order Trotter steps does Proposition 24.1 require to simulate time \(t=3\) with error at most \(0.02\)?

Set the bound \(t^2\|[A,B]\|/(2r)\) equal to the target error and solve for \(r\).
\(r=t^2\|[A,B]\|/(2\epsilon)=9\cdot4/0.04=900\). The step count grows like \(t^2\): simulating three times longer costs nine times as many steps.
example 24.1 — Trotter steps for a two-qubit Hamiltonian

Take \(H=Z_0+Z_1+\tfrac12X_0X_1\) (used throughout this lecture), split as \(A=Z_0+Z_1\), \(B=\tfrac12X_0X_1\), and \(t=1\). Compute \(\|[A,B]\|\), the number of first-order steps the bound requires for error \(0.01\), and compare with the actual errors.

\([Z_0,X_0]=2iY_0\), so \([A,B]=\tfrac12\big([Z_0,X_0]X_1+X_0[Z_1,X_1]\big)=i\,(Y_0X_1+X_0Y_1)\). The two terms commute (they differ at two positions), so the eigenvalues of \(Y_0X_1+X_0Y_1\) are sums of \(\pm1\)'s: \(\pm2\) and \(0\). Hence \(\|[A,B]\|=2\), and the bound asks for \(r\ge t^2\cdot2/(2\cdot0.01)=100\) steps. The actual errors (verify_L24.py, exact matrix exponentials):

steps \(r\)first orderbound \(t^2\|[A,B]\|/2r\)second order
10.61310.292
40.1090.250.0113
160.02680.06250.00069
320.01340.03130.00017

The first-order error halves when \(r\) doubles, as the bound predicts, but sits a factor of about 2.3 below it: 43 steps already give error \(0.01\). The second-order error falls by 4 per doubling. Bounds like Proposition 24.1 are worst-case over all states; resource estimates that use them are conservative.

Simulation of molecules and materials is the most widely expected source of useful quantum advantage. The honest caveat is the same as for Shor: the interesting instances (for example, catalysts with dozens of strongly correlated electrons) need millions to billions of gates, which means error correction.

2 — The variational principle and VQE

Many questions about a quantum system reduce to its ground-state energy \(E_0\), the smallest eigenvalue of \(H\): chemical reaction energies are differences of ground-state energies. Phase estimation (Lecture 14) can find \(E_0\), but needs long coherent circuits. Variational methods trade that for many short circuits and a classical optimizer.

proposition 24.2 — the variational principle

For every state \(|\psi\rangle\), \(\langle\psi|H|\psi\rangle\ge E_0\), with equality exactly when \(|\psi\rangle\) is a ground state.

Proof. Expand in an orthonormal eigenbasis, \(|\psi\rangle=\sum_kc_k|E_k\rangle\) with \(\sum|c_k|^2=1\) (spectral theorem, Lecture 2). Then \(\langle\psi|H|\psi\rangle=\sum_k|c_k|^2E_k\ge\sum_k|c_k|^2E_0=E_0\), with equality iff all the weight sits on eigenvalue \(E_0\).

A Hamiltonian has eigenvalues \(-3\), \(-1\) and \(2\). A state puts weights \(|c_k|^2=0.5,\ 0.25,\ 0.25\) on the three eigenvectors, in that order. What is \(\langle\psi|H|\psi\rangle\)?

The expectation is the weighted average of the eigenvalues, with weights \(|c_k|^2\).
\(0.5(-3)+0.25(-1)+0.25(2)=-1.25\), which is above \(E_0=-3\), as the variational principle demands: any weight off the ground state raises the average.

The variational quantum eigensolver (VQE) (Peruzzo et al., 2014) runs a loop: a parametrized circuit, the ansatz \(U(\theta)\), prepares \(|\psi(\theta)\rangle=U(\theta)|0\cdots0\rangle\); the quantum computer estimates \(E(\theta)=\langle\psi(\theta)|H|\psi(\theta)\rangle\) from measurements; a classical optimizer chooses new parameters; repeat. By Proposition 24.2, every value it reports is an upper bound on \(E_0\). Whether it gets close depends on three things: whether the ansatz can represent a state near the ground state, whether the optimizer finds the best parameters, and whether the energy estimates are accurate enough.

example 24.2 — two ansatze for one Hamiltonian

For \(H=Z_0+Z_1+\tfrac12X_0X_1\): (a) find \(E_0\). (b) Use the product ansatz \(R_y(\theta)\otimes R_y(\theta)\) on \(|00\rangle\) and find its best energy. (c) Use the entangling ansatz "\(R_y(\theta)\) on qubit 0, then a CNOT from qubit 0 to qubit 1" and find its best energy.

(a) \(H\) maps \(\mathrm{span}\{|00\rangle,|11\rangle\}\) to itself, where it is \(\begin{pmatrix}2&\tfrac12\\ \tfrac12&-2\end{pmatrix}\), with eigenvalues \(\pm\sqrt{4.25}\); on \(\mathrm{span}\{|01\rangle,|10\rangle\}\) it is \(\begin{pmatrix}0&\tfrac12\\ \tfrac12&0\end{pmatrix}\), eigenvalues \(\pm\tfrac12\). So \(E_0=-\sqrt{4.25}=-2.0616\), and the ground state lies in \(\mathrm{span}\{|00\rangle,|11\rangle\}\): it is entangled.

(b) Each qubit is in \(\cos\tfrac\theta2|0\rangle+\sin\tfrac\theta2|1\rangle\), with \(\langle Z\rangle=\cos\theta\) and \(\langle X\rangle=\sin\theta\); for a product state expectations multiply, so \(E(\theta)=2\cos\theta+\tfrac12\sin^2\theta\). The minimum is \(-2\) at \(\theta=\pi\), the state \(|11\rangle\). Even with two independent angles the best product state has energy \(-2\) (verify_L24.py checks this numerically).

(c) The circuit gives \(\cos\tfrac\theta2|00\rangle+\sin\tfrac\theta2|11\rangle\). Then \(\langle Z_0+Z_1\rangle=2\cos^2\tfrac\theta2-2\sin^2\tfrac\theta2=2\cos\theta\) and \(\langle X_0X_1\rangle=2\cos\tfrac\theta2\sin\tfrac\theta2=\sin\theta\), so \(E(\theta)=2\cos\theta+\tfrac12\sin\theta\). This is \(R\cos(\theta-\phi)\) with \(R=\sqrt{4+\tfrac14}\), so its minimum is \(-\sqrt{4.25}=E_0\), reached at \(\theta=\pi+\arctan\tfrac14=3.3866\). The entangling ansatz is exact.

Energy landscapes of two ansatzeEnergy against the angle theta from 0 to 2 pi for H = Z0 + Z1 + 0.5 X0 X1. The product ansatz (Ry(theta) on both qubits) gives 2 cos theta + 0.5 sin squared theta, with minimum -2 at theta = pi. The entangling ansatz (Ry(theta) on qubit 0, then a CNOT) gives 2 cos theta + 0.5 sin theta, with minimum -2.0616 at theta = 3.3866, which equals the exact ground energy, drawn as a dashed line.-2-10120pi/2pi3pi/22piansatz angle thetaenergy product ansatzmin -2entanglingmin -2.0616exact E0= -2.0616H = Z0 + Z1 + 0.5 X0 X1
Energy landscapes of the two ansatzes of Example 24.2 for \(H=Z_0+Z_1+\tfrac12X_0X_1\) (verify_L24.py). The product ansatz bottoms out at \(-2\); the entangling ansatz reaches the exact ground energy (dashed line).

The product ansatz misses by \(0.0616\), about 3%, even though its best state \(|11\rangle\) has 98.5% overlap with the ground state. In chemistry, errors are measured against "chemical accuracy", about \(1.6\times10^{-3}\) hartree: small energy differences decide what reacts. The ansatz must be expressive enough to reach the answer, but (Section 6) not so expressive that the optimizer gets lost.

Is VQE guaranteed to find the ground state?

Look again at part (b) of Example 24.2, and list everything the loop depends on.
Three separate things can fail: the ansatz may not contain the ground state (part (b)), the optimizer may stop in a local minimum or on a plateau, and every energy is estimated from a finite number of noisy shots. VQE always returns an upper bound on \(E_0\) (up to statistical error), never a certificate that it found \(E_0\).

3 — Gradients and optimizers

Classical optimizers need gradients or many function values. On a quantum computer, a finite difference \(\big(E(\theta+h)-E(\theta)\big)/h\) is a bad idea: each \(E\) carries shot noise of size \(\sigma/\sqrt N\), and dividing by a small \(h\) amplifies it. For the gates used in most ansatze there is an exact alternative.

proposition 24.3 — the parameter-shift rule

If \(\theta\) enters the circuit through a single gate \(e^{-i\theta P/2}\) with \(P\) a Pauli (for example \(R_y(\theta)=e^{-i\theta Y/2}\)), then $$\frac{dE}{d\theta}=\frac{E(\theta+\tfrac\pi2)-E(\theta-\tfrac\pi2)}{2}.$$

Proof. Since \(P^2=I\), \(e^{-i\theta P/2}=\cos\tfrac\theta2\,I-i\sin\tfrac\theta2\,P\). The energy is quadratic in the gate's entries, so it is a combination of \(\cos^2\tfrac\theta2\), \(\sin^2\tfrac\theta2\) and \(\cos\tfrac\theta2\sin\tfrac\theta2\), that is, \(E(\theta)=a+b\cos\theta+c\sin\theta\). For such a function, \(E(\theta+\tfrac\pi2)-E(\theta-\tfrac\pi2)=-2b\sin\theta+2c\cos\theta=2E'(\theta)\).

A circuit has one \(R_y(\theta)\) gate. At the current angle \(\theta_0\) the shifted circuits give \(E(\theta_0+\tfrac\pi2)=0.42\) and \(E(\theta_0-\tfrac\pi2)=-0.18\). What is \(E'(\theta_0)\)?

Proposition 24.3: half the difference of the two shifted energies. No small step \(h\) is involved.
\(\big(0.42-(-0.18)\big)/2=0.3\). The rule is exact, not a finite-difference approximation, because \(E\) has the form \(a+b\cos\theta+c\sin\theta\).

Both shifted energies are measured on the same hardware as \(E\) itself, with a shift large enough that shot noise is not amplified. A circuit with \(m\) parameters needs \(2m\) energy estimates per gradient. For example 24.2(c), starting at \(\theta=1\) with step size \(0.4\), gradient descent \(\theta\leftarrow\theta-0.4\,E'(\theta)\) visits \(\theta=1,\ 1.565,\ 2.364,\ 3.068,\ 3.326,\ 3.376\), with energies \(1.501,\ 0.511,\ -1.074,\ -1.958,\ -2.058,\ -2.061\): five steps reach \(E_0\) to three decimals. Try it below, then switch on shot noise.

VQE by gradient descent

The curve is \(E(\theta)\) for the chosen ansatz and \(H=Z_0+Z_1+\tfrac12X_0X_1\); the dashed line is the exact \(E_0\). Each step measures \(E(\theta\pm\tfrac\pi2)\), forms the parameter-shift gradient and moves downhill. With finite shots the energies, and so the steps, are noisy. Which ansatz can reach the dashed line? What step size makes the descent overshoot?

Real VQE runs use optimizers designed for noisy function values (SPSA, COBYLA, natural-gradient methods) and spend most of their budget on the energy estimates themselves, which is the next section's subject.

4 — What it costs to measure an energy

A quantum computer measures in the computational basis. To estimate \(\langle H\rangle\) for \(H=\sum_jc_jP_j\), we rotate each qubit so that a Pauli string becomes diagonal (Lecture 4: \(H\) before measuring turns \(X\) into \(Z\)) and average the \(\pm1\) outcomes. Strings that agree on every qubit where both are non-identity (qubit-wise commuting) can be measured together from the same shots. Our \(H\) needs two groups: \(\{Z_0,Z_1\}\), measured directly, and \(\{X_0X_1\}\), measured after Hadamards.

\(Z_0X_1\) and \(Z_0\) be measured from the same shots. \(X_0X_1\) and \(Z_0Z_1\) be measured from the same shots by rotating each qubit separately.

Qubit-wise commuting means: on every qubit where both strings act, they have the same letter.
\(Z_0X_1\) and \(Z_0\) agree on qubit 0, so measuring qubit 0 in Z and qubit 1 in X serves both. \(X_0X_1\) and \(Z_0Z_1\) commute (two clashes) but clash on every qubit, so single-qubit rotations cannot diagonalize both.
proposition 24.4 — shot cost of an energy estimate

If the groups \(G_1,\dots,G_m\) are measured with \(N_1,\dots,N_m\) shots, the estimate \(\hat E=\sum_i\overline{G_i}\) is unbiased with standard error \(\sqrt{\sum_i\operatorname{Var}(G_i)/N_i}\), where \(\operatorname{Var}(G_i)=\langle G_i^2\rangle-\langle G_i\rangle^2\). For a total budget \(N\), the error is smallest when \(N_i\propto\sqrt{\operatorname{Var}(G_i)}\), and then a standard error \(\epsilon\) needs $$N=\frac{\big(\sum_i\sqrt{\operatorname{Var}(G_i)}\big)^2}{\epsilon^2}\ \text{shots.}$$

Proof. Independent sample means have variances \(\operatorname{Var}(G_i)/N_i\), which add. Minimizing \(\sum_i v_i/N_i\) subject to \(\sum N_i=N\) with a Lagrange multiplier gives \(v_i/N_i^2=\lambda\), so \(N_i\propto\sqrt{v_i}\), and the minimum is \((\sum\sqrt{v_i})^2/N\).

An energy is measured in two groups with \(\operatorname{Var}(G_1)=0.36\) and \(\operatorname{Var}(G_2)=0.04\). With the best allocation of shots, how many shots in total give a standard error of \(0.02\)?

Add the standard deviations, not the variances: \(N=\big(\sqrt{v_1}+\sqrt{v_2}\big)^2/\epsilon^2\).
\((0.6+0.2)^2/0.02^2=0.64/0.0004=1600\), split \(3:1\) between the groups (\(N_i\propto\sqrt{v_i}\)): 1200 and 400 shots.
example 24.3 — shots for one energy

At the optimum of example 24.2(c), find the variance of each group and the number of shots for a standard error of \(0.01\).

At \(\theta^*=3.3866\) the state is \(\cos\tfrac{\theta^*}2|00\rangle+\sin\tfrac{\theta^*}2|11\rangle\). \(G_1=Z_0+Z_1\) is \(+2\) or \(-2\) with probabilities \(\cos^2\tfrac{\theta^*}2\) and \(\sin^2\tfrac{\theta^*}2\), so \(\operatorname{Var}(G_1)=4-4\cos^2\theta^*=4\sin^2\theta^*=0.2353\). \(G_2=\tfrac12X_0X_1\) is \(\pm\tfrac12\) with mean \(\tfrac12\sin\theta^*\), so \(\operatorname{Var}(G_2)=\tfrac14\cos^2\theta^*=0.2353\) as well. (Not a coincidence: the state is an eigenvector of \(H=G_1+G_2\), so \(\operatorname{Var}(G_1+G_2)=0\), which forces the two variances to be equal.) Then \(N=(2\sqrt{0.2353})^2/0.01^2=9{,}412\) shots. The ground state has zero energy variance, but because \(H\) is measured in two pieces, each piece fluctuates.

Since \(N\propto1/\epsilon^2\), each extra decimal digit costs 100 times more shots. Chemical accuracy for a molecule whose Hamiltonian has thousands of Pauli terms can need \(10^8\) or more shots per energy, and an optimization needs many energies. Reducing this cost (better grouping, classical shadows, smarter estimators) is a large part of current research.

5 — QAOA for MaxCut

MaxCut: given a graph, split the vertices into two sides to cut as many edges as possible. It is NP-hard in general. Encode a split as a bit string \(z\), with one bit per vertex; edge \((i,j)\) is cut when \(z_i\ne z_j\). As an operator, the number of cut edges is $$C=\sum_{(i,j)\in E}\tfrac12\big(I-Z_iZ_j\big),$$ diagonal in the computational basis with \(C|z\rangle=\mathrm{cut}(z)|z\rangle\).

The star graph has a centre vertex 0 joined to three leaves 1, 2, 3 (and no other edges). Find the maximum cut, and the expected cut of a uniformly random bit string.

Put the centre on one side and see where the leaves should go. For the average, each edge is cut with probability \(\tfrac12\).
Centre on one side, all leaves on the other: all 3 edges are cut (strings 0111 and 1000 in the order \(z_0z_1z_2z_3\)). A random string cuts each edge with probability \(\tfrac12\): \(3/2=1.5\) on average.
definition 24.2 — QAOA

The quantum approximate optimization algorithm with \(p\) layers (Farhi, Goldstone and Gutmann, 2014) prepares $$|\gamma,\beta\rangle=e^{-i\beta_pB}e^{-i\gamma_pC}\cdots e^{-i\beta_1B}e^{-i\gamma_1C}\,|+\rangle^{\otimes n},\qquad B=\sum_jX_j,$$ estimates \(F(\gamma,\beta)=\langle\gamma,\beta|C|\gamma,\beta\rangle\), and maximizes it over the \(2p\) angles. Sampling the final state gives candidate cuts.

The cost layer \(e^{-i\gamma C}\) is a product of two-qubit \(ZZ\) rotations, one per edge, which puts phases on the bit strings according to their cut values; the mixer \(e^{-i\beta B}\) is an \(R_x\) on every qubit, which lets amplitude flow between strings that differ in one bit. Like Grover (Lecture 11), QAOA alternates a phase oracle with a diffusion-like step, but with tunable angles. As \(p\to\infty\) it can reach the optimum (it approximates adiabatic evolution); for small \(p\) it is a heuristic.

example 24.4 — QAOA with one layer on the 4-cycle

For the 4-cycle 0–1–2–3–0, find the maximum cut, the expected cut of a uniformly random string, and the best \(p=1\) QAOA value.

The alternating strings 0101 and 1010 cut all 4 edges. Each edge is cut by a random string with probability \(\tfrac12\), so a random guess cuts 2 on average; this is also \(F(0,0)\), since \(|+\rangle^{\otimes4}\) is the uniform distribution. A direct computation (on a grid, in verify_L24.py) gives the \(p=1\) landscape \(F(\gamma,\beta)=2+\sin4\beta\,\sin2\gamma\). Its maximum is \(3\), at \(\gamma=\pi/4\), \(\beta=\pi/8\): an approximation ratio \(F/C_{\max}=3/4\). At that point the probability of measuring a maximum cut is \(0.531\) (against \(2/16=0.125\) for random guessing), a cut of 2 has probability \(0.4375\), and a cut of 0 has probability \(0.031\).

QAOA p = 1 landscape for MaxCut on the 4-cycleHeat map of the expected cut value F(gamma, beta) for gamma from 0 to pi (horizontal) and beta from 0 to pi/2 (vertical). Cells above 2 (better than random guessing) are blue, below 2 are red, with stronger colour further from 2. The maximum F = 3.0 is at gamma = pi/4, beta = pi/8; the minimum 1 at gamma = pi/4, beta = 3 pi/8. The pattern follows F = 2 + sin(4 beta) sin(2 gamma).0pi/4pi/23pi/4pi0pi/8pi/43pi/8pi/2cost angle gammamixer angle betamax F = 3F = 3 (best)F = 2.4F = 2 (random)F = 1 (worst)maximum cut = 4(0101 and 1010)p = 1 ratio:3/4 = 0.75
The \(p=1\) QAOA landscape \(F(\gamma,\beta)\) for MaxCut on the 4-cycle, computed on a grid in verify_L24.py. Blue cells beat a random guess (\(F\gt2\)), red cells do worse.

QAOA explorer: one layer on the 4-cycle

Choose the angles; the bars show the probability of each bit string (\(q_3q_2q_1q_0\)), coloured by its cut value. Sampling a few shots and keeping the best cut is how QAOA is used in practice. Where in the landscape does QAOA do worse than random guessing, and why can that never happen at the optimum?

How good is this? For MaxCut, the classical Goemans–Williamson algorithm (1995) guarantees a ratio of at least \(0.878\) on every graph, in polynomial time, and on a 4-cycle a classical computer finds the optimum instantly. Farhi et al. proved that \(p=1\) QAOA achieves at least \(0.6924\) on every 3-regular graph. Larger \(p\) does better, but no proof or experiment so far shows QAOA beating the best classical methods on a problem of practical size. It remains a useful laboratory for studying optimization on quantum hardware, and a popular final project.

6 — Barren plateaus

Why not use a large, generic ansatz that can represent anything? Because of the cartoon at the top. McClean et al. (2018) showed that for circuits deep enough to be "random" (formally, unitary 2-designs), the gradient of the energy with respect to any parameter has mean zero and a variance that decreases exponentially in the number of qubits. The landscape is a barren plateau: flat almost everywhere. Resolving a gradient of size \(\sigma\) needs about \(1/\sigma^2\) shots (Proposition 24.4), so the cost of even one optimization step grows exponentially.

Suppose the gradient variance is proportional to \(2^{-n}\), and the typical gradient size is its square root. Going from 10 to 20 qubits multiplies the shots needed to resolve one gradient component by about .

Shots \(\approx1/\sigma^2=1/\operatorname{Var}\). How does \(2^{-n}\) change from \(n=10\) to \(n=20\)?
\(\operatorname{Var}\) falls by \(2^{10}=1024\), so the shots rise by about a thousand. Each further 10 qubits costs another factor of a thousand: that is the barren plateau.
Barren plateaus: gradient variance against qubit numberVariance of one gradient component over random parameters, log scale, against the number of qubits from 2 to 10, for a hardware-efficient ansatz. Deep circuits (2n layers) with a global cost Z on every qubit: the variance halves with every added qubit, following 2 to the minus n. Deep circuits with a local cost Z0 Z1: it decays more slowly. Shallow circuits (2 layers) with the local cost: it stays near 0.13.1e-41e-31e-21e-112345678910number of qubits nVar[dE/d theta]shallow, local costdeep, local costdeep, global costslope 2^-ndeep = 2n layersshallow = 2 layers400 random draws
Variance of one gradient component over random parameters, for a hardware-efficient ansatz with 2 to 10 qubits (bp_data.py, exact statevector gradients). Deep circuits with a global cost follow \(2^{-n}\); a local cost decays more slowly; a shallow circuit with a local cost does not decay.

The figure measures this for a hardware-efficient ansatz (layers of \(R_y\), \(R_z\) and a line of CZ gates; bp_data.py). With \(2n\) layers and a global cost (\(Z\) on every qubit) the variance halves with every added qubit, matching \(2^{-n}\). With a local cost (\(Z_0Z_1\)) it decays more slowly at these sizes, and with a shallow circuit (2 layers) and a local cost it does not decay at all. This is the "cost-function-dependent" picture of Cerezo et al. (2021): shallow circuits and local costs avoid plateaus. The catch, studied by Cerezo et al. (Nature Communications, 2025), is that many of the architectures provably free of barren plateaus have enough structure to be simulated efficiently on a classical computer. Trainability and quantum advantage pull in opposite directions, and finding variational algorithms that have both is an open problem.

7 — Quantum machine learning: what is known

Quantum machine learning attracts more hype per result than any other area. A sober summary of the main ideas:

The statistical-learning half of this story (generalization, sample complexity, inference) is the subject of courses in statistical learning and data science.

8 — Utility, advantage, and how to read a claim

Three terms are used, not always carefully:

A noisy device samples from random circuits far faster than the best known classical method, but the samples answer no question anyone needed answered. Which term fits the claim?

Which of the three definitions explicitly says that the task need not be useful?
A well-defined task done faster than the best known classical method is an advantage claim, useful or not. Sycamore's 2019 experiment was this kind of claim.

The history so far is a back-and-forth. In 2019, Google's 53-qubit Sycamore sampled from random circuits in about 200 seconds, and the team estimated that a supercomputer would need 10,000 years (Arute et al., Nature 574, 505). In 2022, Pan, Chen and Zhang produced comparable samples with tensor networks in about 15 hours on 512 GPUs, and later work shortened that further; newer, larger random-circuit experiments restored the gap. IBM's 2023 utility experiment was reproduced classically within weeks (Lecture 19). In October 2025, Google reported in Nature a "verifiable" advantage on its Willow chip, measuring an out-of-time-order correlator ("Quantum Echoes") about 13,000 times faster than its estimate for the best classical supercomputer algorithm, and, in a companion preprint, a proof-of-principle application to molecular structure from NMR data. In July 2026 IBM and its partners (the University of Chicago, Algorithmiq and Qedma) released three preprints from its 156-qubit Heron processors, using up to 74 qubits, that claim verifiable advantage or results beyond current classical simulation; outside experts called them good science but cautioned that two of the three do not yet show a clear advantage, and none had been peer reviewed (IEEE Spectrum, July 2026). Whether such claims survive is decided over the following months by classical algorithm designers. Use the checklist below on them.

checklist — reading a quantum-computing claim
  1. What is the task? Is it useful, or a benchmark designed to be hard classically? Is the output a number someone wants?
  2. Compared with what? The best classical method, or a brute-force simulation? Have classical experts had time to respond?
  3. Can the answer be checked? By a classical computation, another quantum device, or an experiment?
  4. How was noise handled? Raw, mitigated (Lecture 19), postselected (how many runs discarded?), or error-corrected (Lecture 23)?
  5. "Logical qubits": what distance, what logical error rate per cycle, memory only or computation, how many rounds (Lecture 23)?
  6. Full cost: wall-clock time including repetitions, classical pre- and post-processing, calibration.
  7. Who says so? Peer-reviewed paper, preprint, or press release? Independent reproduction?
crypto connection — what to watch for

Near-term algorithms do not threaten cryptography: VQE, QAOA and quantum ML have no known attack on RSA, ECC or AES. The threat is Shor on fault-tolerant hardware (Lecture 17), and the milestones that matter are the ones in the checklist's items 4–5: physical error rates near \(10^{-3}\), suppression factors \(\Lambda\) well above 2 sustained to large distances, logical operations with magic states, and machines with of order a million physical qubits. Track those, not qubit counts or advantage headlines, when advising on migration timelines. The migration itself (NIST's ML-KEM and ML-DSA, Lecture 17) should not wait for them.

9 — Try it in code

tool — energies with the Estimator primitive (qiskit 2.x)
import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import StatevectorEstimator

H = SparsePauliOp.from_list([("IZ", 1.0), ("ZI", 1.0), ("XX", 0.5)])   # Z0 + Z1 + 0.5 X0X1 (rightmost = q0)
th = Parameter("theta")
ansatz = QuantumCircuit(2); ansatz.ry(th, 0); ansatz.cx(0, 1)            # cos(th/2)|00> + sin(th/2)|11>

thetas = [0.0, np.pi / 2, np.pi, np.pi + np.arctan(0.25)]
job = StatevectorEstimator().run([(ansatz, H, thetas)])                  # one PUB: circuit, observable, parameter values
for t, e in zip(thetas, job.result()[0].data.evs):
    print(f"theta = {t:.4f}:  <H> = {float(e):+.4f}")
print("exact ground energy:", round(float(np.linalg.eigvalsh(H.to_matrix())[0]), 4))
print("measurement groups:", [list(g.paulis.to_labels()) for g in H.group_commuting(qubit_wise=True)])
theta = 0.0000:  <H> = +2.0000
theta = 1.5708:  <H> = +0.5000
theta = 3.1416:  <H> = -2.0000
theta = 3.3866:  <H> = -2.0616
exact ground energy: -2.0616
measurement groups: [['XX'], ['IZ', 'ZI']]

A SparsePauliOp holds \(H\) (labels are written \(q_1q_0\), as always). One PUB (circuit, observable, list of parameter values) returns all the energies at once; on hardware the same call goes to an IBM EstimatorV2, which does the grouping and basis changes of Section 4 for you. group_commuting(qubit_wise=True) shows the two groups.

tool — QAOA for the 4-cycle, sampled
import numpy as np
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler

edges = [(0, 1), (1, 2), (2, 3), (3, 0)]                     # the 4-cycle
def qaoa_circuit(gamma, beta, n=4):
    qc = QuantumCircuit(n); qc.h(range(n))
    for i, j in edges: qc.rzz(-gamma, i, j)               # exp(-i gamma (1 - Z_i Z_j)/2), up to a global phase
    qc.rx(2 * beta, range(n))                             # exp(-i beta X) on every qubit
    qc.measure_all(); return qc

cut = lambda s: sum(s[3 - i] != s[3 - j] for i, j in edges)     # bit strings are printed q3 q2 q1 q0
counts = StatevectorSampler(seed=24).run([qaoa_circuit(np.pi / 4, np.pi / 8)], shots=4000).result()[0].data.meas.get_counts()
F = sum(cut(s) * c for s, c in counts.items()) / 4000
print("expected cut from 4000 shots:", round(F, 3))
for s, c in sorted(counts.items(), key=lambda kv: -kv[1])[:4]: print(s, "cut", cut(s), "count", c)
expected cut from 4000 shots: 3.04
1010 cut 4 count 1110
0101 cut 4 count 1079
1100 cut 2 count 315
1001 cut 2 count 312

Each edge's cost factor \(e^{-i\gamma(I-Z_iZ_j)/2}\) is, up to a global phase, rzz(-gamma), since rzz(t) is \(e^{-itZZ/2}\). At the optimal angles, 4,000 shots give an average cut of about 3, and the two maximum cuts are by far the most frequent strings.

10 — Where to go next, and the course in one page

The course in one page. We began with probabilistic bits and asked what changes when probabilities become amplitudes (Lectures 1–8): superposition, measurement, entanglement, no-cloning, teleportation. Interference turned into algorithms (Lectures 9–16): query separations, Grover's quadratic speedup, the Fourier transform, phase estimation, and Shor, which breaks RSA and elliptic-curve cryptography. Lecture 17 turned that into resource estimates and a migration plan. Then we faced reality: noise and density matrices (18–19), key distribution whose security rests on physics (20), and error correction, from three-bit codes to surface codes running below threshold (21–23). This lecture closed the loop: what noisy machines can do now, and how to judge the claims.

Where to go next. Programs change each year, so check current dates and eligibility:

11 — Summary and exercises

summary

Next: the project workshop (S1) and final-project presentations (S2). HW12 (Lectures 23–24) is due at the start of Week 14; the Lab 7 report is due at the end of Week 14.

exercises 24
  1. For the one-qubit Hamiltonian \(H=X+Z\) split as \(A=X\), \(B=Z\), bound the first-order Trotter error at \(t=1\) with \(r=10\) steps. How many steps does the bound require for error \(10^{-3}\)?
  2. A VQE run on \(H=Z_0+Z_1+\tfrac12X_0X_1\) reports \(\langle H\rangle=-2.000\) exactly. Using the spectrum \(\{-2.0616,-0.5,0.5,2.0616\}\), find a lower bound on the state's overlap \(|\langle E_0|\psi\rangle|^2\) with the ground state.
  3. Check the parameter-shift rule for \(E(\theta)=2\cos\theta+\tfrac12\sin\theta\) at \(\theta=0\), against the derivative computed directly.
  4. Example 24.3 needed 9,412 shots for a standard error of \(0.01\). How many for \(0.001\)? If each shot takes \(200\ \mu\)s on hardware, how long is that?
  5. For MaxCut on a triangle: what is the maximum cut, and why can no split cut all three edges? What does random guessing give on average?
  6. A company announces "the first 100 logical qubits". Write three questions from the checklist you would ask before believing it matters for RSA.
  1. \([X,Z]=-2iY\), so \(\|[A,B]\|=2\) and the bound is \(1\cdot2/(2\cdot10)=0.1\). For \(10^{-3}\): \(r\ge2/(2\cdot10^{-3})=1{,}000\).
  2. Let \(p_0=|\langle E_0|\psi\rangle|^2\). All other eigenvalues are at least \(-0.5\), so \(-2\ge p_0(-2.0616)+(1-p_0)(-0.5)\), which gives \(p_0\ge1.5/1.5616=0.9606\). (The state \(|11\rangle\) achieves \(-2\) with overlap \(0.985\).)
  3. \(E(\tfrac\pi2)=0.5\), \(E(-\tfrac\pi2)=-0.5\), so the rule gives \(0.5\); directly, \(E'(\theta)=-2\sin\theta+\tfrac12\cos\theta\), and \(E'(0)=0.5\).
  4. \(N\propto1/\epsilon^2\): \(100\times9{,}412=941{,}200\) shots, about \(188\) seconds at \(200\ \mu\)s per shot, for one energy.
  5. Any split puts two of the three vertices on the same side, and the edge between them is not cut; so the maximum is 2 (a triangle is an odd cycle, which cannot be 2-coloured). Each edge is cut with probability \(\tfrac12\) by a random split, so the average is \(1.5\). (Numerically, \(p=1\) QAOA reaches \(F=2\) on the triangle, at \(\gamma=0.6155\), \(\beta=0.3077\).)
  6. For example: What is the code distance and the logical error rate per cycle, and does it fall as the distance grows? Are these memory experiments, or are logical gates (including non-Clifford gates via magic states) performed, and at what error rate? Were runs postselected? How many physical qubits per logical qubit, and how does that extrapolate to the roughly thousand logical qubits and billions of operations of Lecture 17?

Reading and sources

all numbers and figures in these notes are computed in python (verify_L24.py, bp_data.py) and follow the page theme