Chapter 32 ended with a checklist for reading a QML paper. This chapter builds classifiers against it.
Prerequisites
- 32
Learning Objectives
- Implement data re-uploading and explain the universality result.
- Compare a quantum classifier across many splits, not one.
- Price inference in QPU hours per million predictions.
- State what a deployable accuracy claim requires.
In This Chapter
- 33.1 A dataset that can distinguish anything
- 33.2 Data re-uploading: one qubit as a universal classifier
- 33.3 One qubit against four
- 33.4 The classical bar
- 33.5 The decision rule, and the boundary
- 33.5b The optimizer is part of the model
- 33.6 The inference bill
- 33.7 What is actually established
- What we measured
Chapter 33: Quantum Classifiers
Chapter 32 ended with a checklist for reading a QML paper. This chapter builds classifiers against it.
The first item on that checklist is the one that changes everything: is the dataset one classical methods already solve perfectly? Chapter 32's iris was, which is why the comparison there could only fail to distinguish anything. So this chapter starts by finding a problem with room in it, and every measurement that follows is on that problem.
Two results, and the second corrects the first.
Data re-uploading works, and it is startling. A single qubit with six parameters classifies a non-linearly-separable dataset at 0.9091 test accuracy — beating a four-qubit, 24-parameter variational classifier that reached 0.7778 on the same split.
And then, across ten independent splits, that gap collapses to $+0.0202 \pm 0.0170$ — not significant. The single split was a lucky draw. The chapter keeps both numbers, because the difference between them is the most useful thing in it.
33.1 A dataset that can distinguish anything
Chapter 32 §32.3 measured LogisticRegression, SVC and RandomForest all reaching 1.0000 on iris-binary. On that dataset no model can be shown better than any other.
So: find one with room.
dataset LogReg SVC RF kNN informative?
moons (noise 0.10) 0.859 0.990 0.990 1.000 no (all perfect)
moons (noise 0.30) 0.768 0.879 0.919 0.949 YES
moons (noise 0.40) 0.768 0.828 0.869 0.869 YES
circles (noise 0.20) 0.465 0.859 0.808 0.828 YES
circles (noise 0.30) 0.495 0.747 0.727 0.717 YES
Moons at noise 0.30 is the one this chapter uses: 201 training samples, 99 test, two features, and a spread of 0.768 to 0.949 across four classical models.
That spread is what makes the dataset useful. LogisticRegression is linear and moons is not, so it underperforms by 0.18 — and that gap is the thing a quantum model would have to close to mean anything.
⚠️ Choose the dataset before you build the model, and check the baseline first. A dataset your baseline solves is a dataset where your result cannot be distinguished from the baseline's. Chapter 32 Case Study 1 is the version of this that gets published.
33.2 Data re-uploading: one qubit as a universal classifier
The most interesting construction in quantum classification, and it is genuinely surprising.
A standard variational classifier encodes the data once and then applies trainable layers. Data re-uploading (Pérez-Salinas et al., 2020) injects the data again between every trainable layer:
@qml.qnode(dev) # ONE qubit
def reupload(x, w):
for layer in w:
qml.RY(x[..., 0], wires=0) # inject feature 0
qml.RZ(x[..., 1], wires=0) # inject feature 1
qml.Rot(layer[0], layer[1], layer[2], wires=0) # trainable
return qml.expval(qml.PauliZ(0))
Six parameters. One qubit.
⚛️ The Physics Underneath: why re-uploading buys expressibility on one qubit.
A single encode-then-rotate circuit applies one fixed function of $x$ followed by a fixed rotation — the composition is a simple function of the data, and no amount of trainable rotation afterwards changes that.
Re-injecting the data interleaves it with the trainable operations, so the circuit computes a nested composition $R(\theta_L)\,U(x)\,R(\theta_{L-1})\,U(x)\cdots$. That nesting is what a neural network's alternating linear-and-nonlinear layers do, and it is the reason a single qubit can represent a non-linear decision boundary at all.
The original paper proves a universality result: with enough layers, one qubit approximates any bounded continuous function on the data. The circuit's width is not what limits expressibility — its depth is.
📐 Math Aside: a re-uploading circuit is a truncated Fourier series.
This is the cleanest way to see what re-uploading buys, and it turns a vague claim about "expressibility" into something you can count.
Take a single qubit and one layer: encode $x$ as a rotation $R_y(x)$, then apply a trainable $R_y(\theta)$. The resulting expectation $\langle Z \rangle$ is a linear combination of $\cos x$ and $\sin x$ — a Fourier series with a single frequency.
Now add a second layer. The circuit becomes
$$U(\theta_2)\, S(x)\, U(\theta_1)\, S(x)\, |0\rangle$$
and because the two data encodings are separated by a trainable unitary, the products of their amplitudes generate terms in $e^{i2x}$ as well as $e^{ix}$. Each additional layer adds one accessible frequency. With $L$ layers the model can represent
$$f(x) = \sum_{n=-L}^{L} c_n e^{inx}$$
where the trainable parameters control the coefficients $c_n$ — not all of them independently, which is the part the headline result glosses over, but enough of them to approximate any bounded periodic function as $L$ grows.
That is the universality theorem, and it is a statement about depth, not width. Schuld, Sweke, and Meyer (2021) make the argument rigorously; Pérez-Salinas et al. (2020) is where the construction comes from.
Two consequences worth stating, because they explain §33.3's measurements before you see them:
- More layers should help until they do not. Once $L$ exceeds the number of frequencies the data actually contains, additional layers add parameters that fit noise. §33.3 measures 2, 4, and 8 layers and the improvement stops after 4.
- A four-qubit VQC that encodes once has exactly one frequency available per feature, no matter how many entangling layers follow. Entanglement adds correlations between features; it does not add frequencies. That is the structural reason the one-qubit model competes with it at all.
What the encoding actually costs
The frequency count is free in the sense that nothing is entangled, and expensive in the sense that each layer is a fresh data-dependent rotation. On a simulator that is invisible. On hardware it is not:
layers trainable params data encodings 1q gates circuit depth
2 6 2 8 8
4 12 4 16 16
8 24 8 32 32
Depth scales linearly with expressibility, and Chapter 31 measured what depth costs against $T_2$. A 32-gate single-qubit circuit is still trivially shallow — this is one of the rare places in the book where the quantum resource requirement is genuinely modest.
⚙️ Under the Transpiler: the single-qubit model transpiles to almost nothing.
Every gate acts on one qubit, so there is no routing, no SWAPs, and no coupling-map constraint. The transpiler's entire job is to rewrite $R_y$ rotations into the device's native $R_z$–$\sqrt{X}$–$R_z$ decomposition, and Chapter 31 measured $R_z$ at 0.0 ns.
A 4-layer re-uploading circuit is 16 logical gates. Transpiled to
rz/sx/xit is 16 $\sqrt{X}$ pulses while the parameters are symbolic, and just 2 once they are bound — because binding lets the transpiler collapse the whole thing into a single $2\times2$ matrix. At Chapter 39's measured 32–64 ns persx, that is 0.5–1.0 µs symbolic and about 0.1 µs bound. Compare Chapter 39's QFT-8 at 10.55 µs.(An earlier draft of this box guessed "roughly 8 pulses, under half a microsecond." Both halves were wrong, and the measured answer is more interesting: the count depends on whether the parameters are bound, and the subsection below works through why.)
This model is about as hardware-friendly as a quantum model gets, which makes §33.6's inference bill all the more striking: the cost is not the circuit, it is the shots.
Counting the coefficients
The Math Aside above said the trainable parameters control the coefficients $c_n$ "not all of them independently." That clause is doing a lot of work, and it is worth making it countable — because the count is the whole story.
This chapter's circuit encodes two features, so the function it computes is doubly periodic:
$$f(x_0, x_1) = \sum_{n=-L}^{L}\ \sum_{m=-L}^{L} c_{nm}\, e^{i(n x_0 + m x_1)}$$
A two-dimensional FFT of $\langle Z\rangle$ over the torus $[0,2\pi)^2$ measures which $c_{nm}$ are actually nonzero, on a $32\times32$ grid that resolves frequencies well past the ones the theory allows:
layers L params 3L lattice (2L+1)^2 nonzero coefficients max |n|, |m|
1 3 9 6 1, 1
2 6 25 25 2, 2
3 9 49 49 3, 3
4 12 81 81 4, 4
The frequency support is exactly the lattice the theory predicts — nothing outside $|n|,|m|\le L$ survives to $10^{-9}$ — and from two layers onward every slot on that lattice is occupied. One layer is the exception: three of its nine slots are identically zero, because the final $R_z$ of the last layer commutes with the $Z$ being measured and simply does not appear in the answer.
Now put the two columns side by side. The parameters grow as $3L$; the coefficients grow as $(2L+1)^2$. At two layers that is six knobs on twenty-five coefficients. At twelve layers — the deepest model §33.5b measured — it is 36 knobs on 625 coefficients.
The universality theorem is not violated by this. It says the frequencies are present and that enough of the coefficient space is reachable to approximate any bounded function as $L$ grows. It does not say the coefficient vector is yours to choose, and the arithmetic says it cannot be: a $3L$-dimensional parameter manifold cannot cover a $(2L+1)^2$-dimensional coefficient space for any $L \ge 2$.
📐 Math Aside: the spectrum has a fixed power budget, and a layer does not enlarge it.
There is a second constraint, and it is stronger than the dimension count because it is an exact bound rather than an inequality about manifolds.
$f$ is the expectation of a Pauli operator, so $|f(x)| \le 1$ everywhere. Parseval's identity on the torus then gives
$$\sum_{n,m} |c_{nm}|^2 \;=\; \frac{1}{(2\pi)^2}\iint_{[0,2\pi)^2} |f(x_0,x_1)|^2\,dx_0\,dx_1 \;\le\; 1$$
Adding a layer adds frequencies. It does not add power. Every new coefficient has to be paid for out of the same budget of one, which is why "more layers" is not the same lever as "more parameters" in a classical network, where the output is unbounded and each new weight genuinely adds range.
Sampling 20,000 uniform random parameter vectors at $L=2$ measures how much of the budget is actually reachable:
```text sum |c|^2 over 20,000 draws: min 0.1413 mean 0.3474 max 0.5625
largest magnitude reached by an individual coefficient: |c(0,0)| 0.5000 |c(1,1)| 0.2492 |c(1,0)| 0.2494 |c(2,0)| 0.2500 |c(0,1)| 0.2500 |c(0,2)| 0.1250 ```
Not one draw in twenty thousand exceeded 0.5625 of the available power, and the individual coefficients cap out at values suspiciously close to $\tfrac12$, $\tfrac14$ and $\tfrac18$.
And the coefficients compete. Conditioning on draws where the second harmonic is large:
text max |c(1,0)| over all 20,000 draws 0.2494 max |c(1,0)| among draws with |c(2,0)|>0.20 0.1719 (5,839 such draws)Demanding a strong second harmonic costs 31% of the achievable first harmonic. That is what "not independently controllable" means in practice, and it is not a small effect.
What the trained model actually put its power into
The same FFT, applied to the two-layer model §33.3 trains to 0.9091, says what the six parameters chose to do with their budget:
(n0, n1) |c| share of total power
(1,-1) 0.2209 14.6%
(-1,1) 0.2209 14.6%
(1,1) 0.2209 14.6%
(-1,-1) 0.2209 14.6%
(2,0) 0.1248 4.7%
(1,0) 0.1157 4.0%
total spectral power 0.3332 over 25 nonzero coefficients
Nearly three-fifths of the model's power — 58.4% — sits in the four cross terms $(\pm 1, \pm 1)$. Those are the coefficients that multiply $e^{i(\pm x_0 \pm x_1)}$: they encode an interaction between the two features, not a response to either one alone.
That is a satisfying result, because a feature interaction is exactly what a linear model cannot represent — and it makes §33.4's headline sharper rather than softer. The quantum model is using its non-linearity. It spends most of its capacity on precisely the thing logistic regression cannot do, and still does not beat logistic regression.
🔀 In Another Framework: the same classifier in Qiskit, and the one-line trap that breaks it.
Re-uploading is a PennyLane-shaped construction — the batch axis, the autodiff, and
requires_gradall make it four lines. Qiskit expresses it too, with twoParameterVectors andEstimatorV2:
python xv, th = ParameterVector("x", 2), ParameterVector("t", 6) qc = QuantumCircuit(1) for l in range(2): qc.ry(xv[0], 0); qc.rz(xv[1], 0) qc.rz(th[3*l], 0); qc.ry(th[3*l+1], 0); qc.rz(th[3*l+2], 0) job = StatevectorEstimator().run([(qc, SparsePauliOp("Z"), values)])Feeding it the weights PennyLane trained reproduces the chapter's number exactly:
text PennyLane test accuracy 0.9091 Qiskit test accuracy 0.9091 max |<Z>_pennylane - <Z>_qiskit| 7.216e-16And the first attempt scored 0.2525.
qc.parametersreturns parameters sorted by name, so a circuit built withxbeforethands yout[0]...t[5], x[0], x[1]— and a positionally-built value array silently binds the data to the weights and the weights to the data. Nothing raises. The shapes are right. You get a trained model that classifies at worse than chance and no indication why.Bind by name, or assert the order. PennyLane's decorator signature makes this class of bug impossible, which is a real reason to prototype QML there even when the production target is Qiskit (Chapter 18 §18.5 on interoperability).
The circuit is one 2×2 matrix, and the transpiler knows it
One more consequence of "every gate acts on one qubit," and it is the sharpest thing in this section.
A product of single-qubit unitaries is a single-qubit unitary. For any fixed data point, the
entire $L$-layer re-uploading circuit collapses to one $2\times2$ matrix, which the Euler decomposition
writes with exactly two $\sqrt{X}$ pulses. Transpiling to rz/sx/x at optimization level 3
measures both halves of that:
layers symbolic: sx depth bound: sx depth
1 4 11 2 5
2 8 22 2 5
4 16 44 2 5
6 24 66 2 5
8 32 88 2 5
12 48 132 2 5
While the parameters are symbolic, cost grows linearly with depth. The moment they are bound to numbers, every circuit in the table is the same five-gate circuit. The transpiler cannot fuse rotations it cannot evaluate — a general fact about parameterized circuits, and the reason a depth figure measured on an unbound template is not the depth you will run.
The ⚙️ Under the Transpiler note earlier in this section estimated "roughly 8 physical $\sqrt{X}$
pulses" for the four-layer circuit. The measurement puts it at 16 symbolic and 2 bound — the
estimate landed between the two regimes rather than in either. Its conclusion survives either way: 16
$\sqrt{X}$ pulses at Chapter 39's measured sx durations of 32–64 ns is 0.5–1.0 µs, still an order of
magnitude under Chapter 39's QFT-8 at 10.55 µs.
And the second column has a consequence the first hides, which §33.6 returns to with a stopwatch: a circuit that reduces to one $2\times2$ matrix is a circuit you can evaluate with one $2\times2$ matrix.
33.3 One qubit against four
Trained on moons at noise 0.30, batched over the whole training set, 60 Adam steps:
model params train s train test
data re-uploading, 1 QUBIT, 2 layers 6 0.3 0.8657 0.9091
data re-uploading, 1 QUBIT, 4 layers 12 0.4 0.9204 0.8990
data re-uploading, 1 QUBIT, 8 layers 24 0.7 0.9104 0.9091
VQC, 4 qubits, 2 layers 24 0.8 0.8060 0.7778
VQC, 4 qubits, 4 layers 48 1.5 0.9005 0.8788
A single qubit with six parameters reaches 0.9091. Four qubits with twenty-four reach 0.7778.
That is a striking result, and it is the kind that gets written up. It also fits the theory: the four-qubit VQC encodes the data once and then entangles, while the single-qubit model re-injects at every layer.
And then, across ten splits
The test set has 99 samples. A difference of 0.13 is thirteen samples. Chapter 27 §27.5 and Chapter 28 §28.3 both established what to do here — run it again, on independent draws, and report an error bar.
Ten independently generated datasets, ten independent splits:
model mean std min max
kNN 0.8970 0.0377 0.8283 0.9495
SVC 0.8889 0.0310 0.8283 0.9394
LogReg 0.8414 0.0463 0.7677 0.9091
1-qubit reupload (2L) 0.8343 0.0407 0.7677 0.9091
4-qubit VQC (2L) 0.8141 0.0336 0.7778 0.8889
1-qubit - 4-qubit VQC = +0.0202 +/- 0.0170 NOT SIGNIFICANT at 2 sigma
The 0.13 gap becomes $+0.0202 \pm 0.0170$. The single split was a lucky draw — the single-qubit model's best split (0.9091) and the four-qubit model's worst (0.7778) happened to be the same split.
🔬 Honest Assessment: the single-qubit model is not significantly better. It is significantly cheaper.
Six parameters against twenty-four, one qubit against four, and statistically indistinguishable accuracy. That is a real and useful result — it is just not the result the single split suggested.
This is the third time in this book that a conclusion drawn from one or two samples did not survive replication: Chapter 27's 2/200 estimating a 0.15% rate, Chapter 28's two circuits agreeing on optimization levels, and now this. The fix each time was the same: run it again.
Why the single split was so misleading
It is worth looking at exactly how a 0.13 gap collapses to 0.02, because the mechanism is not "noise averaged out" — it is more specific than that.
The test set has 99 samples, so one sample is 0.0101 of accuracy. The observed single-split gap of 0.13 is thirteen samples. Across the ten splits:
split 1-qubit 4-qubit VQC gap
0 0.9091 0.7778 +0.1313 <- the split the first run drew
1 0.8283 0.8283 0.0000
2 0.8384 0.8384 0.0000
3 0.7677 0.7980 -0.0303
4 0.8586 0.8283 +0.0303
5 0.8384 0.8081 +0.0303
6 0.8081 0.7879 +0.0202
7 0.8788 0.8384 +0.0404
8 0.8283 0.8081 +0.0202
9 0.7879 0.8283 -0.0404
Split 0 is simultaneously the one-qubit model's best result and the four-qubit model's worst. The two events are not independent — a split whose test set happens to contain more of the easily-separated region flatters whichever model is better at that region — but drawing the joint maximum on the first try is exactly the kind of luck that produces a paper.
Note also that the gap is negative on two splits. A protocol that stopped after any one of those would have concluded the four-qubit model was better, with equal confidence and equal wrongness.
🐛 Debug This: the run that took ten minutes and should have taken six seconds.
The first version of this chapter's training loop looked reasonable:
python for x, y in zip(X_train, y_train): loss += (circuit(params, x) - y) ** 2 # one QNode call per sampleOn 200 training samples × 60 Adam steps × 5 models, that is 60,000 separate circuit evaluations, and it timed out at ten minutes.
The fix is one line:
python preds = circuit(params, X_train) # X_train has a leading batch axis loss = np.mean((preds - y_train) ** 2)PennyLane broadcasts over a leading batch dimension and evaluates the whole batch in one pass — roughly 100× faster, and the numbers in §33.3 come from the batched version.
What makes this worth a callout rather than a footnote: the slow version is not wrong. It produces identical results. A student who writes it will conclude that quantum machine learning is impractically slow, and the conclusion will be about their loop rather than about quantum computing. Chapter 39 §39.3 has the same shape at platform scale — submitting 100 circuits as 100 jobs instead of one batch costs ~99× wall clock, and neither is a quantum effect.
33.4 The classical bar
Now the comparison the chapter exists for:
kNN - 1-qubit reupload = +0.0626 +/- 0.0067 SIGNIFICANT
kNN wins, decisively — nine standard errors, on a dataset chosen specifically to leave room.
And there is a sharper reading available. Compare the quantum model against the weakest classical baseline:
LogReg 0.8414 +/- 0.0463
1-qubit reupload (2L) 0.8343 +/- 0.0407
The "universal classifier" is statistically indistinguishable from logistic regression — a linear model, on a dataset that is not linearly separable, which is why LogReg underperforms kNN by 0.056.
The quantum model has the theoretical capacity for a non-linear boundary and does not, in practice, exploit it better than the linear model does. The universality theorem is about what is representable with enough layers, not about what sixty Adam steps finds.
Expressibility is necessary and not sufficient. Chapter 16 §16.6 made the same point from the trainability side, and Chapter 29 §29.6 from the hardware side. A model class that can represent the answer is not a model that finds it.
Six quantum parameters against six classical ones
The comparison above is against whatever the classical model happens to have. LogisticRegression
on two features has three parameters; kNN has none in the parametric sense and stores the whole
training set instead. Neither is matched to the quantum model's six, and "six parameters" is the
quantum model's entire headline.
So build a classical model with exactly six. LogisticRegression on degree-2 polynomial features has
coefficients on $x_0$, $x_1$, $x_0^2$, $x_0x_1$ and $x_1^2$, plus an intercept — six. Same ten
splits, same test sets, same protocol:
model params mean std min max
1-qubit reupload (2L) 6 0.8343 0.0407 0.7677 0.9091
LogReg + degree-2 features 6 0.8374 0.0483 0.7576 0.9192
LogReg (linear) 3 0.8414 0.0463 0.7677 0.9091
kNN (none) 0.8970 0.0377 0.8283 0.9495
LogReg + degree-2 - 1-qubit = +0.0030 +/- 0.0188 NOT SIGNIFICANT (0.2 SE)
Six classical parameters and six quantum parameters are indistinguishable at 0.2 standard errors.
And they are, in a precise sense, the same six. §33.2's spectrum showed the trained quantum model
putting 58.4% of its power into the $(\pm1,\pm1)$ cross terms — a feature interaction. The polynomial
model's extra parameters are the coefficients on $x_0^2$, $x_1^2$ and $x_0x_1$: the same interaction,
written down explicitly rather than discovered. The quantum model spends sixty Adam steps learning by
gradient descent what a PolynomialFeatures(2) call supplies by construction, and arrives at the same
place.
The classical version fits in 0.0064 seconds, averaged over the ten splits.
⚠️ Common Pitfall: treating a parameter count as a complexity measure.
"Six parameters" sounds like a strong claim because in deep learning parameter counts are the currency — a model with a thousandth of the parameters at the same accuracy is a real result.
It does not transfer. A quantum circuit's parameters are angles inside a fixed-dimension state space, and §33.2 measured what that does to them: six parameters steering twenty-five Fourier coefficients that share a total power budget of at most one. The parameters are not fewer knobs on the same kind of model; they are a differently-shaped constraint.
The honest framing is resource cost, not parameter count. One qubit and no two-qubit gates is a genuine claim about scarce hardware (Chapters 12, 29, 31). "Six parameters" invites a comparison the table above shows the model does not win.
What more training data does
Every number so far is at 201 training samples. That is small, and both directions of the argument depend on it: a capacity-limited model looks better on little data, and a non-parametric method like kNN looks worse.
Ten splits at each size, one initialization each, the same Adam protocol:
n total n train 1-qubit 2L 1-qubit 6L kNN LogReg kNN - 6L
150 100 0.7980 0.8760 0.8960 0.8600 +0.0200 +/- 0.0098
300 201 0.8343 0.8899 0.8970 0.8414 +0.0071 +/- 0.0055
600 402 0.8343 0.9096 0.9025 0.8631 -0.0071 +/- 0.0074
1,200 804 0.8356 0.8962 0.9096 0.8571 +0.0134 +/- 0.0057
2,400 1,608 0.8254 0.8968 0.9044 0.8535 +0.0076 +/- 0.0038
Three readings, and the third is the one that changes the chapter's headline.
The two-layer model does not learn from more data. 0.8343 at 201 samples, 0.8356 at 804, 0.8254 at
1,608. Eight times the data buys nothing measurable. That is the signature of a model that is
underfitting rather than overfitting, and §33.2's frequency count says exactly why: two layers is two
accessible frequencies per feature, and no quantity of data adds a third. LogisticRegression is flat
for the same reason one order lower — 0.8414, 0.8571, 0.8535 — which is why the two tie.
Six layers behaves like a model with capacity. It climbs from 0.8760 at 100 training samples to 0.9096 at 402 and then flattens near 0.90. (§33.5b's layer sweep measured 0.8848 at this dataset size; this run's 0.8899 sits well inside that table's 0.0240 standard deviation.)
★ And the nine-standard-error defeat in §33.4 is a property of the two-layer model, not of data re-uploading. At six layers, on the chapter's own dataset size, the paired gap to kNN is $+0.0071 \pm 0.0055$ — 1.3 standard errors, not significant. At 402 training samples it reverses to $-0.0071 \pm 0.0074$, with the quantum model nominally ahead. At 804 and 1,608 kNN edges back in front by 2.4 and 2.0 standard errors. The sign is not stable and the magnitude never exceeds 0.02, against $0.0626 \pm 0.0067$ for the two-layer model.
🔬 Honest Assessment: this narrows the gap and does not close it.
A six-layer re-uploading model is competitive with kNN on this problem. That is a stronger statement than §33.4 supports for two layers, and it belongs in the chapter.
It is also not a quantum win, for three reasons that have nothing to do with accuracy. Six layers is three times the parameters and three times the depth. §33.6's inference bill is unchanged — the shots are per prediction regardless of depth. And §33.2 measured the thing that settles it: the six-layer circuit, like the two-layer one, is a product of single-qubit unitaries, which is $2\times2$ matrix algebra on a laptop.
The correct summary is not "quantum ties kNN." It is "a six-parameter-per-layer trigonometric model with the right depth ties kNN, and running it on a QPU is a deployment choice with a 32,000× cost multiplier and no accuracy benefit." §33.6 measures that multiplier.
33.5 The decision rule, and the boundary
Everything above used exact expectation values. The rule is $\text{sign}\langle Z\rangle$, and on hardware $\langle Z\rangle$ is estimated from shots.
A sample whose $\langle Z\rangle$ is near zero is one shot-noise fluctuation from being classified the other way. So the relevant question is how many test points sit near the boundary:
|<Z>| over the 99 test points:
p0 0.0159 p50 0.6281
p10 0.1589 p75 0.7984
p25 0.3504 p100 0.9891
points with |<Z>| < 0.05: 1 of 99
points with |<Z>| < 0.10: 2 of 99
Most points are far from the boundary — the median margin is 0.63. Measured:
shots mean acc std worst flips vs exact
100 0.9051 0.0112 0.8788 1.8
1,000 0.9101 0.0044 0.8990 0.2
10,000 0.9091 0.0000 0.9091 0.0
100,000 0.9091 0.0000 0.9091 0.0
exact 0.9091 0.0000 0.9091 0.0
One thousand shots per prediction is enough here, and even 100 shots costs only 0.4% accuracy on average — though its worst run lost 3%.
⚠️ That conclusion is a property of this data, not of the method. The penalty scales with how many points sit near the boundary, and a harder or more balanced problem puts more of them there. Measure the margin distribution before choosing a shot count — it is one line, and it turns the choice from a guess into arithmetic.
Note also what the table does not show: any benefit from more shots beyond 10,000. Chapter 27 §27.6's lesson applies in reverse here — the fix for a noisy decision is more shots, and it saturates once every point is on the correct side of zero.
📐 Math Aside: the flip count is derivable, and the derivation explains a number the table leaves as an oddity.
The "flips vs exact" column was measured by sampling twenty times at each shot count. It can also be derived, and the derivation is short enough to do for a single point in your head.
A shot returns $\pm1$. For a test point with exact expectation $z$, the probability of a $+1$ is $p = (1+z)/2$; over $N$ shots the count $k \sim \mathrm{Binomial}(N, p)$ and the estimate is $\hat z = (2k-N)/N$. The label flips when $\hat z$ lands on the wrong side of zero — for a point with $z > 0$, when $k \le N/2$:
$$P(\text{flip}) \;=\; F_{\mathrm{Bin}}\!\left(\left\lfloor N/2 \right\rfloor;\, N,\, \tfrac{1+|z|}{2}\right)$$
Summing that over the 99 test points gives the expected flip count with no sampling at all:
text shots E[flips] DERIVED measured above 100 1.76 1.8 1,000 0.31 0.2 10,000 0.05 0.0 100,000 0.00 0.0The derivation reproduces the measurement. Which means the same machinery can answer a question the table raises and does not settle: why does 1,000 shots score 0.9101, above the exact 0.9091?
Because a flip is not automatically a loss. If a point was already on the wrong side of zero — one of the nine the exact model gets wrong — flipping it repairs the prediction. Separating the two sums:
$$\mathbb{E}[\Delta \text{acc}] \;=\; \frac{1}{99}\left(\sum_{i \,\in\, \text{wrong}} P_i(\text{flip}) \;-\; \sum_{i \,\in\, \text{right}} P_i(\text{flip})\right)$$
text shots E[accuracy change] 100 -0.0057 1,000 +0.0028 10,000 +0.0006 100,000 +0.0000At 1,000 shots the expected change is positive, and the measured table's $0.9101 - 0.9091 = +0.0010$ is that effect, not a rounding artefact. Shot noise is slightly helping, because points near the boundary are disproportionately the ones the model gets wrong. At 100 shots the noise reaches the confident points too and the sign reverses: derived $-0.0057$ against a measured $0.9051 - 0.9091 = -0.0040$.
Deriving the shot count instead of tabulating it
Inverting the same formula answers the deployment question directly. How many shots does a point of margin $m$ need before its flip probability falls below 1%?
margin m N exact (binomial) Gaussian z^2 (1 - m^2) / m^2
0.0159 21,529 21,402
0.1589 223 209
0.3504 47 39
0.6281 13 8
0.7984 7 3
with $z_{0.01} = 2.3263$. The Gaussian form $N \approx z_\alpha^2 (1-m^2)/m^2$ comes straight from the shot-noise variance $\mathrm{Var}[\hat z] = (1-z^2)/N$, is within 6% of the exact binomial at the smallest margin, and is the version worth remembering. Shot cost scales as $1/m^2$: halving the margin quadruples the bill.
That resolves the apparent paradox in the table above. The closest test point needs 21,529 shots, and the table saturates at 10,000 — so even the chapter's largest shot count never resolves that point reliably. It does not matter, because one point of ninety-nine is 0.0101 of accuracy and, by the calculation in the Math Aside, it is one the exact model gets wrong anyway.
The right question is never "how many shots does the model need." It is "how many shots do the points I cannot afford to be wrong about need" — and on a problem whose margins cluster near zero those two answers differ by orders of magnitude. Chapter 34 §34.7 runs the same $1/\epsilon^2$ arithmetic on Gram-matrix entries, where the count is multiplied by $O(n^2)$ kernel evaluations rather than $O(n)$ predictions.
🗝️ Version Note:
shotsmoved off the device.The measurements above use
qml.set_shots(circuit, shots=N). Older tutorials and most of the pre-2025 QML literature writeqml.device("default.qubit", wires=1, shots=N)instead.In PennyLane 0.45.1 that still constructs, and emits:
text PennyLaneDeprecationWarning: Setting shots on device is deprecated. Please use the `set_shots` transform on the respective QNode instead.The transform is strictly better for this chapter's purpose: a device-level shot count forces one device per shot budget, whereas
set_shotsproduces a new QNode from the same circuit, so the 100/1,000/10,000/100,000 sweep is a loop over one model rather than four devices that must be kept in sync. Chapter 16 §16.1 covers the QNode-as-transform-target model this belongs to.🧪 Run It: measure your own margin distribution before you pick a shot count.
Train any classifier from this chapter, then — on the training set, because the test set is not available at deployment time — do this:
python m = np.abs(np.array(circuit(X_train, weights))) print(np.percentile(m, [0, 1, 5, 10, 25, 50])) N = lambda mm: 5.4119 * (1 - mm**2) / mm**2 # 1% flip probability print("shots for the 5th-percentile margin:", int(N(np.percentile(m, 5))))Three things to look for. A p0 close to zero is normal and usually harmless — it is one point. A p10 below 0.15 is expensive: it means a tenth of your traffic needs 223 shots or more, and the bill in §33.6 is set by that tail, not by the median. A margin distribution that shifts between training and production is the failure mode nobody instruments, and it is cheap to catch: log $|\langle Z\rangle|$ with every prediction and alert on the percentile, not on the accuracy, which you will not know until the labels arrive.
33.5b The optimizer is part of the model
Every accuracy in this chapter is the accuracy of a trained model, and training is a classical optimization over a landscape the circuit defines. That means a comparison between two quantum models is partly a comparison between two optimization problems — and the chapter has been quietly assuming the optimizer found the best each ansatz could do.
It did not, and the size of the gap is worth measuring.
The same model, twenty initializations
The one-qubit, two-layer model. Adam, learning rate 0.1, 60 steps, twenty random starts on a fixed dataset and a fixed split — so the only thing varying is where the optimizer began:
statistic train test
best 0.8615 0.8384
mean 0.8054 0.8162
median 0.7965 0.8283
worst 0.7706 0.7778
std 0.0260 0.0206
spread (best - worst) in TEST: 0.0606
Initialization alone moves test accuracy by 0.0606. Put that beside the two differences this chapter has already measured:
spread from initialization alone 0.0606
the single-split "gap" that started §33.3 0.1313
the TRUE model difference across 10 splits 0.0202 +/- 0.0170
The seed is worth three times the model difference. It is not worth the whole of §33.3's misleading 0.1313 — that took an unlucky split as well — but the two effects compound, and a protocol that fixes neither can produce almost any headline it likes.
There is a second reading, and it is the more useful one for anyone building on this. The mean over twenty starts (0.8162) sits below the 0.8343 §33.3 reported across ten splits, because §33.3 used one initialization per split rather than the best of twenty. Neither number is wrong; they are answering different questions, and the difference between "what this model achieves" and "what this model can be made to achieve" is exactly the ambiguity that makes QML comparisons hard to read.
⚠️ Common Pitfall: reporting the best of several training runs.
It is standard practice, it feels like tuning rather than cheating, and it inflates a reported accuracy by roughly the spread above. If you train twenty times and report the best, you have reported a statistic whose expectation depends on how many times you trained — and the paper you are compared against may have trained once.
Report the mean and the spread across initializations, and say how many you ran. If you want the best, say "best of 20" explicitly. The book's own
compare_modelsrefuses belowMIN_SPLITS = 5for the analogous reason on data splits.The classical baselines in this chapter have no equivalent knob:
kNNandLogisticRegressionare deterministic given the data. That asymmetry favours the quantum model in any comparison that reports a best run, and it is invisible unless you look for it.
And the classical baseline has a seed too
That last paragraph is true of kNN and LogisticRegression, and false the moment the baseline is a
neural network — which is exactly the baseline a "six parameters" claim invites (§33.4).
The identical protocol — fixed dataset, fixed split 0, twenty random starts — run on
MLPClassifier with one hidden unit, which has five parameters:
statistic 1-qubit reupload MLP, 1 hidden unit
(6 params) (5 params)
best 0.8384 0.7980
mean 0.8162 0.6732
median 0.8283 0.7374
worst 0.7778 0.4545
std 0.0206 0.1255
spread (best - worst) in TEST 0.0606 0.3434
starts that collapsed to chance 0 of 20 6 of 20
The classical network's initialization spread is 0.3434 — 5.7 times the quantum model's — and six of its twenty starts land at chance. Two hidden units (nine parameters) barely helps: the spread is again 0.3434, with three of twenty collapsed.
Across the ten splits, the protocol decision alone moves the reported number more than any model difference in this chapter:
MLP(1 hidden), random_state=0, one start per split 0.5010 +/- 0.0049
MLP(1 hidden), best of 20 selected on TRAIN fit 0.8424 +/- 0.0422
The same model, the same data, the same ten splits: 0.5010 or 0.8424 depending on a line of protocol. A difference of 0.3414, against a true model difference in this chapter of 0.0202.
🔬 Honest Assessment: I nearly published the 0.5010.
The first draft of §33.4's matched-parameter table had a row reading
MLP, 1 hidden unit — 5 params — 0.5010, and the sentence it implied wrote itself: a five-parameter classical network cannot learn this problem at all, while a six-parameter quantum model reaches 0.8343.That sentence is built from a real measurement and it is false. Sweeping the solver, learning rate and activation before believing it produced the table above — the network trains fine, from most starting points, in a tenth of a second.
This book documents seven earlier occasions where it drew a conclusion from too small a sample and corrected it in print. This is the eighth, and the first where the too-small sample flattered the quantum side.
The check that caught it is the one §33.5b already applies to the quantum model, applied instead to the baseline. If you run an initialization study on your own model and not on the one you are comparing against, you have measured your variance and assumed the baseline's is zero.
Four optimizers on the same landscape
This section is called the optimizer is part of the model and has so far varied everything except the optimizer. Same ten splits, same starting point on each split, the same two-layer model:
optimizer mean test std worst best
COBYLA, 120 evaluations 0.8394 0.0400 0.7778 0.9091
Adam(0.2), 60 steps 0.8343 0.0407 0.7677 0.9091
GradientDescent(0.2), 60 0.8121 0.0304 0.7374 0.8485
SPSA, 60 steps 0.6465 0.1093 0.4949 0.8283
COBYLA - Adam = +0.0051 +/- 0.0050 NOT SIGNIFICANT
GradientDescent - Adam = -0.0222 +/- 0.0154 NOT SIGNIFICANT
SPSA - Adam = -0.1879 +/- 0.0369 SIGNIFICANT (5 SE)
Two findings, and the first is a resource result rather than an accuracy one.
COBYLA matches Adam, and does it without gradients. On a simulator that is a curiosity, because the gradient is a backward pass. On hardware there is no backward pass: Chapter 16 §16.3's parameter-shift rule evaluates the circuit twice per parameter per gradient, and Chapter 16 §16.4 costs that out in general. For this model:
optimizer circuit-batch evaluations on HARDWARE
Adam / GradientDescent 60 x (1 + 2 x 6) = 780
SPSA 60 x 2 = 120
COBYLA measured nfev = 120
(406 to full convergence, same 0.8394)
COBYLA reaches Adam's accuracy for one-sixth of Adam's hardware cost, and the paired difference runs $+0.0051 \pm 0.0050$ in COBYLA's favour — a tie at 1 standard error. That is a structural fact about dimension, not a quirk of this dataset: parameter-shift costs $2P$ evaluations per gradient, so gradient-based methods lose ground to gradient-free ones as $P$ shrinks. At $P = 6$ the crossover has already happened.
SPSA loses 0.19 of accuracy and falls to chance on some splits. The test is fair in one sense — same
iteration budget, qml.SPSAOptimizer defaults — and unfair in another, since SPSA's gain schedule is
calibrated for hundreds of iterations rather than sixty. The defensible statement is narrow and still
useful: at the iteration budget the rest of this chapter uses, the standard hardware variational
optimizer is the worst of the four. Worth knowing precisely because Chapters 24 and 37 reach for SPSA
on landscapes where its gradient-free property is the whole point.
Now stack the levers this chapter has measured, largest first:
optimizer choice (COBYLA vs SPSA) 0.1929
the single-split "gap" that opened Sec 33.3 0.1313
initialization spread (20 starts, above) 0.0606
the TRUE model difference across 10 splits 0.0202 +/- 0.0170
The optimizer is the largest lever in this chapter, and it is the one QML comparisons hold fixed
without saying so. A paper reporting "Adam, 60 steps, lr 0.2" for its own model and citing a baseline
trained by whatever scikit-learn defaults to has not held anything constant — it has made one
arbitrary choice explicit and left the other implicit. Chapter 37 §37.4 found the same ordering in
QAOA, where seed variance grew with $p$ while the mean improved, and the reported number depended on
which of the two you led with.
Layers, and where the improvement stops
§33.2's Fourier argument predicted that additional layers help until the model has more frequencies than the data contains. Ten splits per depth, one initialization each, a three-parameter layer:
layers params mean test std train s
1 3 0.6020 0.0384 0.1
2 6 0.8131 0.0381 0.2
4 12 0.8747 0.0236 0.4
6 18 0.8848 0.0240 0.5
8 24 0.8838 0.0231 0.7
12 36 0.8838 0.0333 1.1
One layer is barely better than chance at 0.6020. With a single accessible frequency the model can only produce a decision boundary that is monotone in each feature, and the moons dataset was chosen precisely to defeat that — §33.4 measured logistic regression, which has the same limitation, at 0.8414.
The improvement is steep to four layers, essentially complete by six, and flat from six to twelve. That is the Fourier prediction holding: once the model has more frequencies than the data contains, additional ones have nothing left to fit.
Two things the prediction did not get right, and both are worth noting because they run against the usual story about overparameterization:
The mean does not degrade. Twelve layers scores the same 0.8838 as eight. There is no visible overfitting penalty at four times the necessary depth, on 231 training samples.
The variance falls and then rises. Standard deviation drops from 0.0384 at one layer to 0.0231 at eight, then climbs back to 0.0333 at twelve. The fall is the model becoming able to fit the data at all; the rise is the optimization landscape getting harder — the same mechanism Chapter 37 §37.4 measured in QAOA, where seed variance grew from 0.000 at $p=1$ to 0.021 at $p=4$ while the mean kept improving.
The practical reading: pick six layers here, and expect the variance rather than the mean to tell you when you have gone too deep.
📉 Noise Report: and none of the above included any noise at all.
Every number in this chapter so far came from
default.qubit— exact expectation values, no shot noise, no gate error, no decoherence. That is the right choice for isolating the model's behaviour, and it means these accuracies are upper bounds.Re-running the two-layer model on
default.mixedwith a depolarizing channel after each encoding and each trainable block, ten splits each:
text gate error mean test std vs exact 0 (exact) 0.8131 0.0381 0.0000 1e-04 0.8131 0.0381 0.0000 1e-03 0.8121 0.0386 -0.0010 1e-02 0.8081 0.0407 -0.0051 5e-02 0.8010 0.0419 -0.0121At 1e-4 the accuracy does not move at all — to four decimal places. At 1e-2, a hundred times worse than a real device's single-qubit error, it loses 0.0051.
Chapter 39 measured a median
sxerror of 2.44e-04 on a real 133-qubit device. This model would lose well under 0.001 of accuracy to single-qubit gate noise.That is a genuinely remarkable robustness result and it follows directly from §33.2's transpiler note: the circuit has no two-qubit gates. Two-qubit error rates on that same device ran from 1.79e-03 to 1.00 — three orders of magnitude worse than the single-qubit rates, with some links dead entirely.
This is the most hardware-robust model in Part VI, and it still loses to kNN by nine standard errors. Noise is not what is holding it back, which means better hardware will not fix it.
33.6 The inference bill
Chapter 32 §32.4 costed training. A deployed classifier pays per prediction, forever.
at 1,000 shots per prediction: 27.8 QPU hours per MILLION predictions
at 10,000 shots per prediction: 277.8 QPU hours per MILLION predictions
A model serving a million predictions — a modest production load — costs 27.8 hours of continuous QPU time at the shot count this data needs, and 277.8 hours at the count a harder problem would need.
The classical comparison is not close, and it is worth measuring rather than asserting:
kNN.predict on 1,000,000 points: 1.1 SECONDS on a laptop
quantum, at 1,000 shots each: 27.8 QPU HOURS
A factor of about ninety thousand, on top of a training cost that was already 2.38 QPU-days against 0.4 milliseconds.
🔬 Honest Assessment: training cost is the number QML papers omit; inference cost is the number nobody computes at all.
Chapter 32's 2.38 QPU-days was a one-time cost. This is a recurring one, and for any model that is actually deployed it dominates the total lifetime cost by orders of magnitude.
A quantum classifier is not a model you train once and then run cheaply. Every prediction is a circuit execution with a shot budget.
💰 Cost and Queue: and the QPU hours are the optimistic half.
The 27.8 QPU-hours figure counts device time only. Chapter 39 measured what surrounds it.
A single prediction at 1,000 shots on this circuit is roughly 0.4 ms of device time. At a five-minute queue, submitting predictions one at a time gives a utilization of about $1.3\times10^{-6}$ — you would wait roughly 760,000× longer than you compute.
Batching fixes the queue and not the shots. Even perfectly batched, at Chapter 39's measured rates:
text 1,000,000 predictions x 1,000 shots = 1e9 shots per-minute model @ $96/min -> $ 2,670 per-shot model @ $0.00035 -> $ 350,000 trapped ion @ $0.01/shot -> $10,000,000Against
kNN.predictat 1.1 seconds on a laptop.And note which model flatters the quantum result: the per-minute one, because this circuit is extraordinarily short. A team benchmarking on IBM's pricing and deploying on Braket's would be surprised by a factor of 131. Chapter 39 Case Study 39.1 is that surprise, in a pharmaceutical company, with an invoice.
The row the cost table was missing
§33.2 ended on an observation this table does not account for: a product of single-qubit unitaries is a single-qubit unitary. For any fixed input the entire $L$-layer circuit is one $2\times2$ complex matrix, and $\langle Z\rangle$ is $|\psi_0|^2 - |\psi_1|^2$ for $\psi = U|0\rangle$.
So evaluate it that way. No simulator, no QPU — $L$ batched $2\times2$ products per prediction:
U = np.broadcast_to(np.eye(2, dtype=complex), (n, 2, 2)).copy()
for a, b, c in weights:
U = RY(X[:, 0]) @ U; U = RZ(X[:, 1]) @ U
U = RZ(a) @ U; U = RY(b) @ U; U = RZ(c) @ U
psi = U[:, :, 0]
z = np.abs(psi[:, 0])**2 - np.abs(psi[:, 1])**2
It reproduces PennyLane's trained model exactly — same 0.9091 test accuracy, max |difference| =
7.772e-16 — and it runs on a million points:
a MILLION predictions from the SAME trained model
2x2 matrix algebra, 2 layers 3.11 s
2x2 matrix algebra, 6 layers 8.71 s
2x2 matrix algebra, 12 layers 16.76 s
kNN.predict (same run, same laptop) 1.97 s
QPU at 1,000 shots per prediction 27.8 HOURS
★★ 32,103×, for identical predictions to fifteen decimal places.
(The 1.1 s quoted for kNN.predict above came from a separate run; this one measured 1.97 s on the same
laptop. Wall-clock timings move by that much between runs, which is why the comparison is stated as
orders of magnitude rather than a precise factor.)
Two things this does not say. It is not a criticism of data re-uploading — the construction is
still elegant and the universality result still holds. And the classical evaluation is not free: at
3.11 s it is 1.6× slower than kNN.predict, so it does not win on speed either.
What it does say is narrow and decisive: a one-qubit model is classically simulable exactly, in $O(L)$ time per prediction, with a constant small enough to be measured in seconds on a laptop. The 27.8 QPU-hours buy nothing whatsoever — not accuracy, not fidelity, not a different answer. They are the cost of running on a QPU a computation that a QPU is not needed for.
Every remedy in this book has been denominated in the currency of its disease, and this is the purest case. The single-qubit model's great virtue — no entanglement, no two-qubit gates, no routing, immune to the noise §33.5b measured — is the same property that makes a quantum device unnecessary to evaluate it. Chapter 34's kernel methods entangle deliberately and pay the two-qubit-gate bill to escape this trap; Chapter 32 §32.2's input problem is where the bill lands instead.
Where inference cost would stop mattering
Three cases, and it is worth being precise because "quantum is too slow" is a lazier claim than the evidence supports:
1. If predictions are rare and valuable. A model consulted a hundred times a year on million-dollar decisions does not care about 0.4 ms versus 27.8 hours. The economics of batch scoring and high-stakes single decisions are completely different, and QML papers almost always implicitly assume the first.
2. If the shot count can be cut. §33.5 measured 100 shots costing only 0.4% mean accuracy on this data. A problem where 50 shots suffice is 20× cheaper than the table above.
3. If the model is a feature extractor rather than a classifier. Run the quantum circuit once per
input to produce a representation, then serve predictions classically from the stored representation.
This is the architecture Chapter 35 §35.4 examines — and there, SVC(rbf) on the measurement
probabilities beat the quantum model that produced them.
None of these three is a hardware problem, and none is solved by more qubits.
What a fair comparison would have required
The chapter's comparison is fair, and it is worth writing down what that took — because the list is longer than most published QML comparisons satisfy, and every item on it changed a number.
1. A dataset the baseline does not saturate. Chapter 32 used iris-binary and three classical methods
reached 100%, making the quantum tie uninformative. This chapter used moons at noise 0.30, where
LogisticRegression scores 0.8414 — structurally limited, because the boundary is not linear — and
kNN scores 0.8970. That leaves room for a quantum model to win, and it did not.
2. More than one classical baseline. Against LogisticRegression alone, the quantum model is
statistically indistinguishable and the honest headline would be "matches the classical baseline."
Against kNN it loses by nine standard errors. Which baseline you pick decides the story, and picking
one is the most common way a comparison misleads without containing a false statement.
3. Enough splits to have error bars. Ten. One split gave 0.1313 where the truth is $0.0202 \pm 0.0170$.
4. Fixed initialization protocol. One initialization per split, stated. §33.5b measured what best-of-twenty would have added: up to 0.0606, on a model whose true advantage is 0.0202.
5. The same evaluation for both sides. Same splits, same metric, same test sets. Obvious, and worth stating because a comparison against published numbers rather than a re-run baseline silently violates it.
6. Cost reported. Training and inference. §33.6's 27.8 QPU-hours per million predictions against kNN's 1.1 seconds is not a tiebreaker; it is most of the decision.
📊 What the Numbers Say: the comparison that would have been easy to publish.
Take the single split from §33.3, compare only against
LogisticRegression, report the best of several training runs, and omit cost. Every individual step is defensible and none is fabrication.The result: "a single qubit with six parameters matches logistic regression and outperforms a four-qubit variational classifier by 0.13 accuracy."
That sentence is constructible entirely from true measurements, and the chapter's actual finding is that the quantum model loses to kNN by nine standard errors and costs 90,000× more to run.
This is why Chapter 40 §40.4's checklist has eight questions rather than one. No single check catches the sentence above — it fails on baseline choice, sample size, initialization protocol, and cost simultaneously, and passes anything that only asks whether the numbers are real.
33.7 What is actually established
Stated carefully, because the results point in several directions at once.
Data re-uploading is a real and elegant technique. One qubit, six parameters, and a non-linear decision boundary. The universality result is proven, the construction is simple, and it is genuinely surprising that circuit width is not what limits expressibility.
It is significantly cheaper than the multi-qubit alternative — a quarter of the parameters, a quarter of the qubits, statistically indistinguishable accuracy. On a device where qubits and two-qubit gates are the scarce resources (Chapters 12, 29, 31), that is the trade you want.
It does not beat classical methods. kNN wins by $+0.0626 \pm 0.0067$, and the quantum model is indistinguishable from logistic regression on a problem logistic regression is structurally wrong for.
And the costs are not comparable. Milliseconds against QPU-days for training; seconds against QPU hours-per-million for inference.
That is the state of quantum classification, and Chapter 34 turns to the technique with the cleanest mathematical story in the field — quantum kernels — where the argument is different and, in one specific respect, better.
What we measured
- Moons at noise 0.30 leaves room: classical accuracies from 0.768 (LogReg) to 0.949 (kNN). Chapter 32's iris did not.
- Data re-uploading on ONE qubit with SIX parameters reached 0.9091 on a single split, against 0.7778 for a four-qubit, 24-parameter VQC.
- ★★ Across ten independent splits that gap collapses to $+0.0202 \pm 0.0170$ — not significant. The single split was a lucky draw; it paired the 1-qubit model's best result with the 4-qubit model's worst.
- ★ The single-qubit model is significantly cheaper, not significantly better — a quarter of the parameters and qubits, indistinguishable accuracy.
- ★★ kNN beats it by $+0.0626 \pm 0.0067$ — significant at nine standard errors.
- The "universal classifier" is statistically indistinguishable from logistic regression ($0.8343 \pm 0.0407$ against $0.8414 \pm 0.0463$) on a problem that is not linearly separable.
- Only 1 of 99 test points has $|\langle Z\rangle| < 0.05$, so 1,000 shots per prediction suffices here: 0.9101 ± 0.0044 against an exact 0.9091.
- ★ Inference costs 27.8 QPU hours per million predictions at 1,000 shots, and 277.8 at 10,000 — a recurring cost Chapter 32's training budget did not include.
- Six quantum parameters tie six classical ones.
LogisticRegressionon degree-2 features has exactly six and scores $0.8374 \pm 0.0483$ against the quantum model's $0.8343 \pm 0.0407$ — $+0.0030 \pm 0.0188$, 0.2 standard errors — in 0.0064 s. - The frequency lattice is $(2L+1)^2$ and the parameters are only $3L$: six knobs on twenty-five coefficients at two layers, 36 on 625 at twelve, with total spectral power capped at 1 by Parseval. Demanding $|c_{2,0}| > 0.20$ costs 31% of the reachable $|c_{1,0}|$.
- The trained model spends 58.4% of its power on the four $(\pm1,\pm1)$ cross terms — a real feature interaction — and still only ties logistic regression.
- ★ At six layers the gap to kNN is not significant: $+0.0071 \pm 0.0055$ at 201 training samples, reversing to $-0.0071 \pm 0.0074$ at 402. The nine-standard-error defeat is a property of the two-layer model, which learns nothing from eight times the data (0.8343 → 0.8254).
- ★ The optimizer is the largest lever in the chapter: COBYLA 0.8394, Adam 0.8343, plain gradient descent 0.8121, SPSA 0.6465 — a spread of 0.1929 against a model difference of 0.0202. COBYLA ties Adam at 120 circuit evaluations against parameter-shift's 780.
- The classical baseline has an initialization knob too, and a bigger one:
MLP(1 hidden)spreads 0.3434 over twenty starts against the quantum model's 0.0606, with 6 of 20 collapsing to chance — 0.5010 single-seed or 0.8424 best-of-20 on identical data. - The flip count is derivable, not just measurable: 1.76 / 0.31 / 0.05 expected flips at 100 / 1,000 / 10,000 shots against 1.8 / 0.2 / 0.0 measured — and the derivation explains why 1,000 shots scores above exact. Per-point cost is $z_\alpha^2(1-m^2)/m^2$; the closest margin needs 21,529 shots.
- ★★ The whole model is $2\times2$ matrix algebra. Bound to numbers it transpiles to 2 $\sqrt{X}$ pulses at every depth from 1 to 12 layers, and a million predictions take 3.11 s in NumPy against 27.8 QPU-hours — 32,103×, for identical answers to $7.8\times10^{-16}$.
The theme: expressibility is necessary and not sufficient — and a result from one split is a draw from a distribution, not a measurement.
And a third, which this chapter is the cleanest instance of in the book: a model cheap enough to need no entanglement is a model cheap enough to need no quantum computer.