40 min read

Part VI opens on the area of quantum computing with the widest gap between claims and measurements.

Prerequisites

  • 16
  • 24

Learning Objectives

  • Encode classical data into quantum states and price each encoding.
  • Train a variational classifier and compare it to a tuned classical baseline.
  • Measure gradient variance against qubit count and observe barren plateaus.
  • State the input problem precisely and explain why it bounds QML.

Chapter 32: Quantum Machine Learning Fundamentals

Part VI opens on the area of quantum computing with the widest gap between claims and measurements.

That is not an insult to the field. It is a structural fact: machine learning is where the money is, quantum computing needs applications, and the intersection has been funded accordingly. The result is a large literature, a great many demonstrations, and — as this chapter measures — an unresolved question about whether any of it beats sklearn.

Everything Part V established applies here at once, and this chapter's job is to show them arriving together. Chapter 24's shot budget, multiplied by a training loop. Chapter 16's barren plateaus, in the classifier setting. Chapter 29's circuit shape. And one problem that is specific to QML and arguably fatal: getting classical data into a quantum computer costs more than the computation.

The headline measurement: a variational quantum classifier and a logistic regression, on the same data, reaching the same test accuracy. The logistic regression took 2.2 milliseconds. The quantum classifier took 50.2 seconds on an exact simulator — roughly 20,000× slower, with no shots and no noise — and would take 2.38 QPU-days on hardware.


32.1 What the claim is

The hope is straightforward and worth stating fairly.

A quantum circuit of $n$ qubits acts on a $2^n$-dimensional Hilbert space. A parameterized circuit is therefore a function class over an exponentially large space, and — the argument goes — such a class might represent patterns that classical models of comparable size cannot, or might find them faster.

This is the same reasoning that motivates every variational algorithm in Chapter 24, applied to supervised learning. The structure is identical: encode, evolve, measure, optimize classically, repeat.

The difference is that Chapter 24's VQE had a well-posed target — the ground-state energy of a Hamiltonian, defined independently of the algorithm, verifiable by diagonalization at small sizes. Machine learning has no such anchor. A model is judged by test accuracy against alternatives, and the alternatives are very good.

Three claims wearing the same word

"Quantum advantage in machine learning" is three separate assertions, and they are almost never distinguished. They carry different burdens of proof and fail in different ways, and a demonstration supporting one is routinely quoted as supporting the others.

Sample complexity. The quantum model needs fewer training examples to reach a given accuracy. This is a statement about the learning problem rather than about the hardware, and it survives even if every circuit runs slowly. It has the strongest theoretical backing — the proven separations in §32.6 are mostly of this kind — and it is the hardest to demonstrate empirically, because showing it requires a learning curve on both models rather than a single accuracy number.

Time complexity. The quantum model reaches the same accuracy in less wall clock, or fewer operations. This is the claim the publicity makes and the one this chapter measures directly. It is also the claim the input problem attacks head-on, because $\mathcal{O}(N)$ loading per sample is already the classical cost of reading the data.

Expressibility. The quantum model represents a function class that classical models of comparable size cannot. This is a statement about the hypothesis space, and it says nothing about whether the function you need lives in that space, or whether training will find it. A circuit that can represent everything and can be trained to nothing is the barren-plateau situation of §32.5, exactly.

The three come apart cleanly, and the chapters ahead separate them one at a time. A model can be more expressive and less trainable (§32.5). It can be competitive on accuracy and unusable on cost (Chapter 33 §33.6's inference bill). It can match a baseline on both and mean nothing, because the baseline was already perfect (§32.3).

Test accuracy on one split measures none of the three. It measures one draw from one model's error distribution on one dataset — which Chapter 33 §33.3 demonstrates by watching a $+0.1313$ single-split gap collapse to $+0.0202 \pm 0.0170$ across ten splits, and disappear.

📊 What the Numbers Say: an accuracy comparison answers a narrower question than it appears to.

Two models, one dataset, one split, two accuracies. What actually follows?

If the quantum model scores lower, that is informative. It rules out advantage on this dataset, with this encoding, this ansatz and this optimizer. A negative result on a fair test is a real result, and Part VI produces several.

If it scores higher, the difference has to clear the noise on the estimate before it means anything — and §32.3 works out how large that noise is on a 30-sample test set.

If it ties at 1.0000, nothing follows in any direction, because the comparison had no room to express a difference.

The asymmetry is worth internalizing. A tie on a saturated dataset is not weak evidence of equivalence; it is the absence of a measurement. That is this book's third recurring failure — a measurement that cannot detect the thing being asked about — and Part V catalogued six instances of it before Part VI added this one.


32.2 The input problem

Before any of the interesting parts: how does classical data get into the circuit?

Three standard answers, with different costs:

   encoding             qubits for N features    gate cost      what you spend
   basis (binary)       N x bits per feature     O(N)           one qubit per BIT
   angle (1 per qubit)  N                        O(1) depth     one qubit per FEATURE
   amplitude            log2(N)                  O(N) gates     exponential qubits saved,
                                                                exponential gates spent

Angle encoding is what most demonstrations use: one rotation per feature, one qubit per feature, constant depth. Simple, shallow, and it caps your feature count at your qubit count. A 64-feature dataset needs 64 qubits, which is most of a current device before any computation happens.

Basis encoding, priced in full

The first row of that table is the one nobody uses, and it is worth pricing anyway, because the price is what makes the trade-off visible.

Basis encoding writes each feature as a bit string and puts one bit on one qubit. A feature quantized to 8 bits takes 8 qubits. Preparing the state is trivial: apply an $X$ wherever the bit is 1. The cost is at most one single-qubit gate per qubit and exactly zero two-qubit gates — no entanglement, no rotation synthesis, no approximation, nothing for a transpiler to route.

   dataset    features   basis @ 8 bits    angle    amplitude
   iris              4         32 qubits        4     2 qubits
   digits           64        512 qubits       64     6 qubits

512 qubits to hold a 64-feature image at 8-bit precision, on a device with 127 — and that is before a single gate of the model.

So basis encoding is the cheapest possible loading circuit sitting on top of the most expensive possible register. It is what oracle constructions use, which is why Chapter 19 quoted its 8-bit oracle in T gates rather than in state preparations: the input was already there, in the computational basis, for free. It is essentially never what a classifier uses, because the qubit bill is fatal at any precision worth having.

Notice what the three rows have in common. Each is cheap in exactly one resource and expensive in another, and there is no fourth row that is cheap in both:

   basis        cheap in GATES,   ruinous in QUBITS
   angle        cheap in DEPTH,   linear  in QUBITS
   amplitude    cheap in QUBITS,  linear  in GATES

That is not a gap in the literature waiting to be filled. $N$ numbers carry $N$ numbers' worth of information, and an encoding only chooses which register pays for them. The information does not compress just because the storage does — which is the same sentence as the ⚛️ callout below, arrived at from the other direction.

The angle-encoding ceiling is a modelling constraint, not only a hardware one

The obvious cost of angle encoding is the qubit count. The less obvious cost is what it does to the model.

One qubit per feature means the width of the circuit is the width of the data. Every architectural choice you would like to make — how many entangling layers, which topology, how many parameters — is made on a register whose size you do not control. On iris that is 4 qubits, which is why this chapter's classifier is 4 qubits and not 5. On digits it is 64, which is not a decision anybody made.

And the encoding is periodic. qml.AngleEmbedding applies a rotation through angle $x_i$, and $R_X(x)$ and $R_X(x + 2\pi)$ prepare the same state. A feature whose range exceeds $2\pi$ is therefore aliased: two genuinely different inputs land on the same quantum state, and nothing downstream can separate them again.

⚠️ Common Pitfall: feeding raw features into an angle encoding.

This is why example-02-vqc-versus-sklearn.py calls StandardScaler().fit(Xtr) before anything quantum happens — and why the scaler is fit on the training split only and then applied to test. Fitting it on the full dataset leaks test statistics into training, which is an ordinary classical mistake that a quantum wrapper does nothing to prevent and rather effectively hides.

Standardizing puts almost all values within roughly $\pm 3$, comfortably inside one period. It is not optional preprocessing. With an angle encoding it is part of the model definition, because a different scaling is a different function.

The failure is silent. An aliased feature raises no exception, produces no NaNs, and does not stall the optimizer. It produces a model that has quietly lost the ability to tell some of its inputs apart, and the only symptom is accuracy that will not improve no matter how many layers you add.

Amplitude encoding is the one that gets quoted in the claims, because $N$ features fit in $\log_2 N$ qubits — an exponential compression. Measured:

    N features   qubits   prep 2q gates   transpiled ecr
             4        2               1                1
             8        3               4                5
            16        4              11               19
            32        5              26               41
            64        6              57              100
           128        7             120              227

Seven qubits for 128 features — and 227 two-qubit gates to load them.

The logical gate counts are not merely $\mathcal{O}(N)$; they fit an exact formula. Qiskit's StatePreparation produces

$$\text{two-qubit gates} = N - \log_2 N - 1$$

which reproduces every row above exactly: 1, 4, 11, 26, 57, 120. The gate count grows linearly in $N$ — which is exactly the classical cost of reading the data.

📐 Math Aside: where $N - \log_2 N - 1$ comes from.

A formula that reproduces six measured integers exactly is not a fit. It is the structure of the algorithm showing through, and the structure is what tells you the cost cannot be negotiated down.

The construction is a binary tree. To prepare an arbitrary state on $n = \log_2 N$ qubits, work backwards: undo the last qubit's rotation conditioned on the first $n-1$, then the next, and so on until nothing is left. Each stage is a uniformly-controlled rotation — one rotation on one qubit whose angle depends on the classical bit pattern of its controls. Stage $k$ has $k$ controls and therefore $2^k$ distinct angles to write.

The standard Gray-code decomposition of a $k$-controlled uniform rotation is $2^k$ single-qubit rotations interleaved with $2^k$ CNOTs — and the last CNOT of each block commutes out and cancels against its neighbour, leaving $2^k - 1$. Summing over the $n$ stages:

$$\sum_{k=0}^{n-1}\left(2^k - 1\right) \;=\; \left(2^n - 1\right) - n \;=\; N - \log_2 N - 1$$

Decomposing Qiskit's StatePreparation one stage at a time shows exactly that cascade:

text N = 128, n = 7 multiplexer stages found: 7 stage (controlled qubits) 1 2 3 4 5 6 7 measured CNOTs 0 1 3 7 15 31 63 total 120 predicted 2^k - 1 0 1 3 7 15 31 63 total 120

The $N-1$ tree nodes are visible in the same decomposition: it reports 127 single-qubit unitaries alongside those 120 CNOTs at $N = 128$, and 15 unitaries with 11 CNOTs at $N = 16$. One rotation per tree node, one CNOT saved per level.

And the linear scaling is forced, not merely chosen. Count parameters. A general complex $N$-dimensional unit vector has $2N - 2$ free real numbers once normalization and global phase are removed. A circuit carrying $G$ two-qubit gates can express at most a bounded number of continuous parameters per gate — at most two arbitrary single-qubit gates, six real angles, follow each one — so

$$6G + 3n \;\ge\; 2N - 2 \qquad\Longrightarrow\qquad G \;\ge\; \frac{2N - 2 - 3n}{6}$$

At $N = 128$ that is $G \ge 39$. The measured 120 is 3.1× a bound that no synthesizer can beat. A cleverer state-preparation routine might close that factor of three. Nothing can remove the $N$.

At Chapter 12's measured error rate of 0.0075, those 227 gates survive with probability $(1-0.0075)^{227} \approx 0.18$. Before the model has done anything.

⚙️ Under the Transpiler: the logical column is not the one you pay.

The measured table has two gate columns, and the gap between them widens with $N$:

text N features qubits logical 2q transpiled ecr ratio 4 2 1 1 1.00 8 3 4 5 1.25 16 4 11 19 1.73 32 5 26 41 1.58 64 6 57 100 1.75 128 7 120 227 1.89

The ratio climbs from 1.00 to 1.89. Two effects produce it, and only one of them is negotiable.

Basis translation is nearly free. FakeSherbrooke's native two-qubit gate is ecr, and a CNOT between adjacent qubits becomes one ecr plus single-qubit gates. That is why $N = 4$ costs exactly 1: on two qubits every pair is adjacent, so there is nothing to route and the ratio is unity.

Routing is not free. The cascade derived above is all-to-all — stage $k$ entangles one target with $k$ arbitrary controls. Heavy-hex connectivity gives each physical qubit two or three neighbours, so most of those pairs are not adjacent and the transpiler inserts SWAPs at three two-qubit gates each. At 2 qubits there is nothing to swap. At 7 qubits the widest stage wants six controls on a lattice where no qubit has six neighbours.

This is Chapter 29's result arriving on a circuit that has not computed anything yet. There, a hardware-aware layout at optimization level 1 scored 0.9116 against a naive level-3 layout's 0.7720 — a 0.1397 swing decided entirely by which physical qubits the circuit landed on. The same lever applies here, and it is worth pulling before declaring amplitude encoding hopeless on a given device. It moves the 1.89. It does not touch the $N$ underneath it.

⚛️ The Physics Underneath: amplitude encoding compresses the register, not the work.

An arbitrary $N$-dimensional state vector has $N$ independent real parameters. Preparing it requires specifying all of them, and no circuit can do that in fewer than $\mathcal{O}(N)$ gates — the information has to get in somehow.

The $\log_2 N$ is a statement about storage, and the $\mathcal{O}(N)$ is a statement about loading. Quoting the first without the second is the single most common error in QML exposition.

The standard escape is QRAM — a hypothetical device loading a classical vector in $\mathcal{O}(\log N)$ time. It would resolve this completely. It does not exist, no credible proposal exists for building one at scale, and several analyses argue that a QRAM robust enough to be useful would itself require error correction, at which point its cost dominates again.

📉 Noise Report: 0.18 is the optimistic number.

That survival probability uses Chapter 12's median two-qubit error rate, 0.0075. Chapter 30 §30.3 measured what a median conceals: on a single chip, the quoted two-qubit error ran from 0.00750 to 0.07205 — a factor of 9.6 between the best link and the worst.

Applied to the same 227-gate loading circuit:

text two-qubit error survival of the 227-gate encoding 0.00750 0.1811 0.07205 4.247e-08

Four orders of magnitude, and a ratio of 4.3 million between the two ends — for the identical circuit on the identical chip, differing only in which physical qubits the transpiler happened to choose. Chapter 29 §29.4's hand-picked chain scored 0.6790 where a calibration-picked one scored 0.9764; this is the same phenomenon with a much longer circuit to amplify it.

The practical consequence is not "amplitude encoding fails at 128 features." It is that the failure is layout-dependent and therefore irreproducible. A pipeline that works on Monday and fails on Thursday has not changed; the calibration has. Chapter 30 §30.4's rule carries over intact: read the calibration data at submission time, not the datasheet.

🐛 Debug This: decompose() reported zero two-qubit gates.

This measurement is easy to get wrong in a direction that flatters the encoding, and the wrong answer looks entirely reasonable on the page.

StatePreparation is a high-level instruction. QuantumCircuit.decompose() unwraps one level by default, and one level is nowhere near enough:

text N = 128, decompose(reps=1) two-qubit gates: 0 ops: {'isometry_to_uncompute_dg': 1} N = 128, decompose(reps=2) two-qubit gates: 0 ops: {'multiplexer_dg': 7} N = 128, decompose(reps=3) two-qubit gates: 120 ops: {'unitary': 127, 'cx': 120} N = 128, decompose(reps=6) two-qubit gates: 120 ops: {'u': 127, 'cx': 120}

At the default depth, the encoding costs nothing. The circuit is one opaque instruction and count_ops() faithfully reports that it contains no cx — which is true, and completely wrong as an answer to the question "what does this cost?"

That is why example-01-the-input-problem.py passes reps=6, and why the number worth quoting is the transpiled one rather than either decomposition. transpile(qc, backend) cannot hand back an opaque instruction, because the backend has no such gate to run.

The other framework hides it differently. PennyLane's resource counter, asked about the same 16-feature load, returns:

text qml.specs(circuit)()["resources"].gate_types -> {'AmplitudeEmbedding': 1}

One gate. Not because PennyLane is wrong, but because a resource count is taken at the level the circuit was written at.

The general rule generalizes well past this chapter: a resource count is only meaningful at the abstraction level the hardware executes. Anything above that is counting your own notation. It is the same trap as Chapter 19's oracle, where an 8-bit condition expressed as one multi-controlled gate looked free and expanded to 26,978 T gates without ancillas.

And it is per sample

The genuinely awkward part:

   iris       150 samples x  4 features   -> amplitude: 2 qubits, ~4 gates PER SAMPLE
   digits    1797 samples x 64 features   -> amplitude: 6 qubits, ~64 gates PER SAMPLE

Encoding happens once per sample, per forward pass, per epoch. The exponential compression compresses one vector, and training uses thousands of them thousands of times.

A 1,797-sample dataset at 60 optimizer steps requires 107,820 state preparations, each costing $\mathcal{O}(N)$ gates. That is not a constant factor on the quantum advantage; it is the dominant term.


32.3 A classifier, trained

Enough theory. Build one.

Iris, restricted to two classes — 70 training samples, 30 test, 4 features, standardized. Angle encoding on 4 qubits, two StronglyEntanglingLayers, 24 parameters, mean-squared-error loss, Adam.

The classical baselines first, as Chapters 21 and 24 both insist:

   model                      train s    test accuracy
   LogisticRegression          0.0022           1.0000
   SVC (rbf)                   0.0006           1.0000
   RandomForest                0.0608           1.0000

All three get 100%. That is worth pausing on before reading any quantum result — the problem is linearly separable, and it is the dataset most QML demonstrations use.

Now the quantum classifier, trained on an exact simulator with no shots and no noise:

   model                        train time   train acc   test acc
   LogisticRegression               2.2 ms      1.0000     1.0000
   VQC (4q, 2 layers, exact)        50.2 s      0.9714     1.0000

Same test accuracy, and roughly 20,000× slower — on a simulator, in the most favourable possible conditions. (The exact ratio moves between runs because the denominator is a two-millisecond measurement; repeated runs gave 20,391× and 22,642×. The order of magnitude is the point.)

🔬 Honest Assessment: matching a baseline is not evidence of anything.

Both models get 100% because the problem is easy. The result demonstrates that a parameterized quantum circuit can express a linear boundary — which was never in doubt — and nothing about whether it can express something a classical model cannot.

A demonstration on a dataset the baseline solves perfectly cannot distinguish the two methods. It can only fail to.

What makes a dataset a fair test

"Pick a harder dataset" is easy advice and hard to act on. It is worth making precise, because the criterion is checkable in one line before any quantum code is written.

A dataset is a fair test when the classical baselines disagree with each other by more than the noise on the estimate. That is the whole rule, and it has two halves that fail independently.

The spread has to exist. Chapter 33 §33.1 screens candidates on exactly this basis:

   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
   circles (noise 0.20)     0.465   0.859   0.808   0.828   YES

Moons at noise 0.30 spans 0.768 to 0.949 — an 0.18 gap between a linear model and a local one. That gap is the thing a quantum model would have to close to mean anything. Iris-binary's gap is 0.0000, which is why nothing measured on it can carry information.

And the spread has to be resolvable. This is the half that gets forgotten, and it is a property of the test set size, not of the models.

📊 What the Numbers Say: a 30-sample test set has a resolution of 3.3 percentage points.

This chapter's split is 70 train / 30 test. An accuracy computed on 30 samples can only take the values $0/30, 1/30, 2/30, \ldots$ — so the finest difference the measurement can express is $1/30 = 0.0333$. Two models differing by two percentage points return identical numbers on this test set, necessarily, whatever is true about them.

The sampling noise is larger still. The standard error on an accuracy estimate from $n$ test samples is $\sqrt{p(1-p)/n}$:

text test samples quantization SE at p=0.95 SE at p=0.85 30 0.0333 0.0398 0.0652 99 0.0101 0.0219 0.0359

A 30-sample test set cannot resolve anything below about four points, and Chapter 33 uses 99 test samples across ten independent splits for exactly this reason.

So the iris tie is uninformative twice over: the baseline had no headroom, and the instrument had no resolution. Either one alone would be enough to void the comparison. Report the test-set size next to the accuracy, always — an accuracy without a denominator is a number without an error bar. Chapter 27 §27.5 made the same point about distributions and put a figure on it: the shot-noise floor on a total variation distance scales as $1/\sqrt{N}$ — measured mean 0.01313 and max 0.03700 at 1,000 shots on GHZ(3) — and a test written to a tighter tolerance than that fails on correct code. An accuracy comparison finer than $1/n_{\text{test}}$ is that mistake with a different denominator.

The training accuracy that was lower than the test accuracy

One number in that table is easy to skim past, and it is the most interesting one:

   VQC (4q, 2 layers, exact)        50.2 s      0.9714     1.0000

The quantum model scores lower on the data it trained on than on the data it did not. That should prompt a question, and the arithmetic answers it immediately. On 70 training samples, $0.9714$ is exactly $68/70$ — two misclassified points, and no other fraction with a 70 denominator rounds to it. On 30 test samples it got all 30.

Is that a model that generalizes unusually well? Almost certainly not. Take the training accuracy at face value as an estimate of the true error rate and ask how often such a model sweeps a 30-sample test set:

$$P(\text{30 of 30 correct} \mid p = 0.9714) = 0.9714^{30} = 0.4191$$

A model that is genuinely 97.1% accurate scores a perfect 30/30 about 42% of the time. The perfect test score is not evidence that the model is perfect; it is the most likely single outcome of a 30-draw experiment on a good-but-imperfect model. For comparison, even a 90%-accurate model clears 30/30 with probability 0.0424 — one run in twenty-four.

This cuts both ways, and it is worth saying so. The classical baselines' 1.0000 is exposed to exactly the same argument. Nothing in this chapter establishes that logistic regression is perfect on iris-binary either. What it establishes is that on a 30-sample test set, four models are indistinguishable — which is the finding, and it is a finding about the experiment rather than about any of the models.

🔀 In Another Framework: the same classifier, three toolchains, one unchanged bill.

This chapter's VQC is PennyLane, because Chapter 16 built the differentiation machinery it needs: qml.AngleEmbedding + qml.StronglyEntanglingLayers inside a @qml.qnode, optimized by qml.AdamOptimizer over qml.grad.

In Qiskit the pieces have different names and live in a separate package, qiskit-machine-learning, which is not part of this book's environment. There the encoding is a feature-map circuit (zz_feature_map and friends), the ansatz is real_amplitudes, and the pair is wrapped in an EstimatorQNN that supplies gradients to a NeuralNetworkClassifier. The layering differs; the circuit does not.

In Cirq there is no equivalent layer at all. Cirq gives you the circuit and the simulator, and the optimizer is yours to bring — which is why Chapter 14 positioned it as the framework for explicit control rather than for variational work, and why Chapter 16 §16.8 recommends PennyLane as a differentiation layer on top of another framework rather than as a replacement for one.

What does not change in any of them: the $N - \log_2 N - 1$ loading cost, the per-sample multiplier, the $(2n+1)$ gradient rule, and §32.4's shot budget. Those are properties of the circuit and the estimator, not of the API. Switching frameworks changes how the experiment is written and nothing about whether it can run — which is the useful thing to know before spending a week porting.


32.4 The training shot budget

The 50.2 seconds was a simulator. What does training cost on hardware?

Chapter 24 §24.3 established the arithmetic for a single variational optimization: a parameter-shift gradient costs $2n+1$ circuit evaluations, and each evaluation needs enough shots for the precision you want. Training adds two more multipliers: samples, and steps.

   parameters                  24
   parameter-shift evals/grad  2n+1 = 49          (Ch. 16 Sec 16.4)
   training samples            70
   optimizer steps             60
   shots per circuit           10,000             (Ch. 27 Sec 27.5's floor)

   TOTAL = (2n+1) x samples x steps x shots
         = 49 x 70 x 60 x 10,000
         = 2,058,000,000 shots

   at 10,000 shots/second: 57.2 QPU HOURS = 2.38 DAYS

Two billion shots, and 2.38 days of continuous QPU time, to match a model that trained in 2.2 milliseconds.

Compare Chapter 24's VQE bill: $3.9 \times 10^9$ shots for one molecule at one geometry. This is the same order of magnitude for a 70-sample toy dataset, because the training loop multiplies Chapter 24's budget by the number of samples.

📌 The number that is almost never reported. QML papers quote qubit counts, circuit depths, accuracies, and sometimes iteration counts. Total shots is the quantity that determines whether the experiment is possible, it is a one-line calculation, and it is usually absent — exactly as Chapter 24 §24.3 found for VQE.

Where the $2n+1$ comes from, and why there is no cheaper option

The first factor in that product is the one people assume can be optimized away, so it is worth knowing why it cannot.

You cannot take a finite difference on hardware. Every circuit evaluation costs thousands of shots and returns a noisy number, so a finite difference divides a small noisy quantity by a small quantity. Chapter 16 §16.3 measured what that does even on a noiseless simulator:

  h=1e-01:  error 1.07e-03
  h=1e-03:  error 1.07e-07
  h=1e-05:  error 1.98e-11
  h=1e-07:  error 2.91e-10        <- worse again

Finite differences have a sweet spot and degrade on both sides of it — truncation error above, floating-point cancellation below. On hardware the shot-noise floor moves that sweet spot somewhere far worse, and there is no step size that recovers.

The parameter-shift rule has no step size. For a gate $e^{-i\theta P/2}$ with $P$ a Pauli, the expectation value is exactly $A\cos\theta + B\sin\theta$, and a sinusoid's derivative is recoverable from two samples a quarter period apart:

$$\frac{\partial f}{\partial\theta} = \frac{f(\theta + \tfrac{\pi}{2}) - f(\theta - \tfrac{\pi}{2})}{2}$$

This is exact, not approximate, and the shift is $\pi/2$ — a large displacement, which is precisely why it survives on noisy hardware where a $10^{-5}$ step could not.

The cost follows directly. Two shifted evaluations per parameter, plus one forward pass for the loss value itself:

$$\text{evaluations per gradient} = 2n + 1$$

At 24 parameters that is 49, and Chapter 16 §16.4 confirmed the count exactly by instrumenting the executions. Of those 49, forty-eight are gradient and one is the answer — 98% of every step's bill is spent finding out which way to move.

So the $2n+1$ is not overhead to be engineered away. It is the price of a derivative that is exact on a device where nothing else is.

Every lever on the budget, and what each one actually buys

Two billion shots is not a verdict, it is a starting point, and there are three real levers. Pull them all and the arithmetic changes a great deal:

   change                              total shots        QPU time      factor
   baseline (49 x 70 x 60 x 10,000)  2,058,000,000        57.2 h            1x
   mini-batch of 8 instead of 70       235,200,000         6.53 h         8.75x
   SPSA: 2 evaluations, not 49          84,000,000         2.33 h         24.5x
   1,000 shots instead of 10,000       205,800,000         5.72 h           10x

   ALL THREE TOGETHER                      960,000    96 SECONDS         2,144x

Ninety-six seconds of QPU time. The 2.38-day figure is real, and it is also the figure for the least optimized version of the experiment. A practitioner who mini-batches, uses a gradient-free optimizer, and drops to 1,000 shots is looking at a coffee break.

Three honest caveats, each of which eats part of that:

SPSA's two evaluations buy a stochastic gradient, not the real one, so it typically needs substantially more iterations to converge — some of the 24.5× goes straight back. Mini-batching likewise needs more steps for the same number of epochs. And 1,000 shots is below Chapter 27 §27.5's floor for anything with a tight tolerance; §32.5 works out precisely when it stops being enough.

But here is the part that matters, and it is the reason this section exists rather than ending at "2.38 days":

   the same 2,144x, applied to the 20-qubit budget below

     6.63e+12 shots  /  2,144  =  3.09e+09 shots  =  85.9 QPU hours  =  3.58 DAYS

Every lever pulled at once, and a 20-qubit model on a 70-sample toy dataset still costs longer than the unoptimized 4-qubit run did. The levers are constant factors. The thing they are being applied to is an exponential. This is the book's fifth recurring theme in its cleanest form — every remedy is denominated in the currency of the disease — and §32.5 supplies the exponent.

💰 Cost and Queue: what the training run costs in money and in waiting.

Chapter 39 measured that the same job has three completely different prices depending on the billing model. Applied to this chapter's 2.058-billion-shot training run, at the rates Chapter 33 §33.6 used:

text per-minute model @ $96/min -> $ 329,280 per-shot model @ $0.00035 -> $ 720,300 trapped ion @ $0.01/shot -> $20,580,000

A factor of 62 between the cheapest and dearest, for identical work — to match a model that trained in 2.2 milliseconds on a laptop.

And then the queue, which is worse than the compute. The budget decomposes into $49 \times 70 \times 60 = 205{,}800$ distinct circuit evaluations. Submitted one job at a time against Chapter 39's five-minute queue:

text 205,800 jobs x 5 min = 715 days = 2.0 YEARS of queue batched 100 circuits per job = 2,058 jobs = 171.5 h = 7.1 days of queue actual compute = 57.2 hours

Even perfectly batched, you wait three times longer than you compute. Chapter 39 measured this as a utilization of $2.31\times10^{-5}$ on a Bell-state job and found the same 120-iteration VQE taking 10 hours as separate jobs against 5 minutes inside a session. Sessions and batching are not performance tuning here; they are the difference between an experiment and a two-year queue.


32.5 And the plateaus arrive too

The shot budget assumes you can resolve the gradient. Chapter 16 §16.6 measured gradient variance collapsing exponentially with qubit count for randomly-initialized hardware-efficient ansätze. The same measurement, on this classifier:

    qubits   params    var(grad)   ratio to previous    used   excluded
         2       12    1.033e-01                   -     420        300
         4       24    2.819e-02               3.67x     720        720
         6       36    1.410e-02               2.00x    1200        960
         8       48    1.951e-03               7.23x    1680       1200
        10       60    1.169e-03               1.67x    2160       1440

An 88× collapse across eight qubits, with the usual scatter. Chapter 16's barren plateau, arriving in the QML setting exactly as it did in the chemistry setting.

📐 Math Aside: why the variance vanishes exponentially in width.

The barren plateau is usually stated and rarely derived, which makes it sound like an empirical misfortune that better engineering might fix. It is not. It is concentration of measure, and the exponent falls out of one standard integral.

Setup. Write the circuit as $U(\theta) = U_+ \, e^{-i\theta_k P_k/2} \, U_-$, splitting it at the parameter being differentiated. The loss is $f = \langle 0 | U^\dagger Z_0 U | 0\rangle$, and the derivative is

$$\partial_k f \;=\; \left\langle \psi_- \middle|\; > \tfrac{i}{2}\big[P_k,\, U_+^\dagger Z_0 U_+\big] \;\middle| \psi_- \right\rangle, > \qquad |\psi_-\rangle = U_-|0\rangle$$

— the expectation of one Hermitian operator in one state, both of which depend on the random parameters.

Step one: the mean is zero. If the ansatz is expressive enough that $U_+$ is as likely as $U_+ e^{i\pi P_k/2}$ — a 1-design, which random hardware-efficient circuits approach quickly — then for every parameter draw producing $+g$ there is an equally likely draw producing $-g$. So $\mathbb{E}[\partial_k f] = 0$, and therefore

$$\mathrm{Var}[\partial_k f] = \mathbb{E}\!\left[(\partial_k f)^2\right]$$

This is why the chapter measures a variance and not a mean. The mean is zero by symmetry at every qubit count and carries no information at all.

Step two: the second moment. For a Haar-random state $|\psi\rangle$ in dimension $d = 2^n$ and a traceless observable $O$ — which $\frac{i}{2}[P_k, \cdot]$ is, being a commutator —

$$\mathbb{E}\big[\langle\psi|O|\psi\rangle^2\big] \;=\; \frac{\mathrm{Tr}(O^2) + \mathrm{Tr}(O)^2}{d(d+1)} > \;=\; \frac{\mathrm{Tr}(O^2)}{d(d+1)}$$

For a Pauli-like operator, $\mathrm{Tr}(O^2)$ is proportional to $d$, so the whole thing collapses to

$$\mathrm{Var}[\partial_k f] \;\sim\; \frac{1}{d+1} \;\approx\; 2^{-n}$$

The variance halves with every qubit added. Not with every gate, not with every layer — with every qubit. Depth enters only by determining how quickly the circuit becomes random enough for the integral to apply.

Step three: check it against both measurements. Over 2 → 10 qubits, $2^{-8} = 1/256$ predicts a 256× collapse. What was measured:

text ansatz Var(2q) Var(10q) collapse per qubit Ch.32, StronglyEntangling x2 1.033e-01 1.169e-03 88x 0.571 Ch.16, StronglyEntangling x6 1.0431e-01 4.6517e-04 224x 0.508 Haar-random prediction - - 256x 0.500

Chapter 16's six-layer ansatz lands within 13% of the prediction. This chapter's two-layer ansatz falls 2.9× short of it. That is not a discrepancy — it is the derivation working. Two layers on ten qubits is not deep enough to scramble the state into anything resembling Haar-random, so the concentration integral does not yet apply at full strength and the collapse is slower than asymptotic.

Which produces the result that governs the whole field: the ansatz that is expressive enough to be interesting is the ansatz that is random enough to be flat. Expressibility and trainability are the same knob turned in opposite directions. Chapter 16 §16.6 confirmed the other half of this by measuring one, two and six layers and finding that shallower circuits raise the overall variance by a constant and leave the decay with width untouched. You buy a constant factor and the wall stays where it is.

And the physical reading is the honest one. A Haar-random state spreads its amplitude across all $2^n$ basis states, so any local observable concentrates on its average with fluctuations of order $2^{-n/2}$. The landscape is not rough or badly conditioned. It is flat — genuinely, nearly everywhere — with the structure confined to an exponentially small region the optimizer has no way to find.

📌 The exclusion count is reported because Chapter 16 §16.6 learned to. Gradients below $10^{-14}$ are dropped before computing the variance, and roughly 40% of them are dropped at every size — those are parameters that are structurally unable to affect a $\langle Z_0 \rangle$ measurement, mostly final-layer rotations on other qubits.

Chapter 16's version of this mistake produced a beautiful exponential fit to an artifact, 18 orders of magnitude off, because a systematically-zero gradient was left in the sample. A filtered statistic whose exclusion count is not reported is not a statistic.

What the 1,440 excluded gradients actually are

Reporting the exclusion count is the minimum. Explaining it is better, and the explanation is short enough to be worth having, because it settles whether the filter is removing an artifact or removing part of the answer.

Divide each excluded count by the 60 parameter draws and you get the number of parameters that are zero on every draw:

    qubits   params   excluded   / 60 draws   2n + 4   excluded fraction
         2       12        300            5        -              41.7%
         4       24        720           12       12              50.0%
         6       36        960           16       16              44.4%
         8       48       1200           20       20              41.7%
        10       60       1440           24       24              40.0%

The same parameters are zero every time, and the count fits $2n + 4$ exactly at every size where the entangling ring is well defined. This is not a plateau artifact and not a sampling accident; it is a fixed set of parameters that cannot influence $\langle Z_0 \rangle$ at all.

Inspecting which ones, by accumulating $|\partial_k f|$ over eight independent random draws at each size, gives a clean structural picture:

    n = 10, StronglyEntanglingLayers(2 layers), 60 parameters

    layer 0, phi  (RZ)   0 of 10 wires zero
    layer 0, theta(RY)   0 of 10 wires zero
    layer 0, omega(RZ)   2 of 10 wires zero      wires 0, 1
    layer 1, phi  (RZ)   6 of 10 wires zero      wires 0,1,3,5,7,9
    layer 1, theta(RY)   6 of 10 wires zero      wires 0,1,3,5,7,9
    layer 1, omega(RZ)  10 of 10 wires zero      every wire
                        ----
                          24 = 2n + 4

The final layer's omega rotations are zero on every wire, and that one is derivable. Rot's last operation is an $R_Z$; after it comes only the entangling ring and the $\langle Z_0\rangle$ measurement. Conjugating $Z_0$ backwards through CNOTs keeps it inside the group generated by $Z$ operators, and $R_Z$ commutes with every element of that group. The derivative is identically zero — for all inputs, all parameter values, and all qubit counts. Ten of the 24 exclusions at $n=10$ are that single fact.

Two consequences worth carrying forward:

The filter is removing an artifact, not part of the signal. These parameters are not small; they are structurally absent. Leaving them in would drag the variance down by roughly the exclusion fraction, which declines from 50% toward $(2n+4)/6n \to 1/3$ — a size-dependent bias, exactly the shape that mimics a plateau. Chapter 16 §16.7's 18-orders-of-magnitude false plateau was this mechanism running unchecked.

And the data encoding changed which parameters are dead. Chapter 16 §16.7 found the first $R_Z$ of the first Rot to be structurally zero, because it acts on $|0\rangle$ and contributes only a global phase. Here layer 0's phi is zero on no wire — because AngleEmbedding rotates the state away from $|0\rangle$ before the first layer runs. The encoding removed one structural zero and the measurement created others. Which is the practical lesson: the dead-parameter set is a property of the whole circuit, encoding and observable included, and it must be re-derived whenever any of them changes rather than carried over from a previous experiment.

Two plateaus, and the measurement only sees one

The table above was produced on default.qubit — an exact simulator, no shots, no noise. That is the right choice for isolating the width effect, and it means the numbers understate the problem on hardware in two distinct ways.

Shot noise puts a floor under the gradient. A parameter-shift derivative is the scaled difference of two independent expectation estimates, so from $N$ shots each its standard error is about $\sigma_g \approx 1/\sqrt{2N}$. Compare that against the measured gradient magnitudes $|g| \approx \sqrt{\mathrm{Var}}$:

    qubits   measured var   typical |grad|   |grad|/sigma at 1,000    at 10,000
         4      2.819e-02           0.1679                  7.5x         23.7x
        10      1.169e-03           0.0342                  1.5x          4.8x

At ten qubits and 1,000 shots the typical gradient is 1.5 standard errors above the noise. It is not resolvable, and no optimizer can follow it. That is the arithmetic behind Chapter 27 §27.5's floor of 10,000 shots being adopted in §32.4 rather than something cheaper — and it is the caveat that ate part of the 10× lever above. The effective plateau, the one that stops a real experiment, arrives several qubits earlier than the exact one.

And gate noise shrinks the gradient multiplicatively. Every two-qubit gate damps $\langle Z_0\rangle$ toward zero, and the derivative damps with it. A two-layer StronglyEntanglingLayers carries two entangling rings, so $2n$ CNOTs:

    qubits   2q gates   survival @ 0.0075   effect on variance
         4          8              0.9416               0.887
        10         20              0.8602               0.740
        20         40              0.7400               0.548
        50        100              0.4710               0.222
    50 qubits, 6 layers    300     0.1045               0.011

A 1% effect at four qubits, a 26% effect at twenty, and a further 90× suppression of the variance for a six-layer circuit at fifty qubits — on top of the $2^{-n}$ that is already there. The literature calls this a noise-induced barren plateau, and it is worth naming separately because it has a different cure: error mitigation (Chapter 13) touches this one and does nothing whatever to the concentration-of-measure plateau derived above.

And the two constraints are not independent. Resolving a gradient of size $g$ needs $\mathcal{O}(1/g^2)$ shots (Chapter 24 §24.3). So a flatter landscape costs more shots per parameter — while the parameter count is simultaneously growing:

    qubits   typical |grad|   shots to resolve   total training shots
         4         1.00e-01                100               2.06e+07
         8         2.50e-02              1,600               6.52e+08
        12         6.25e-03             25,600               1.56e+10
        20         3.91e-04          6,553,600               6.63e+12

Six times ten to the twelve shots at 20 qubits, for a 70-sample problem, extrapolating the measured trend.

🔬 Honest Assessment: these are not separate problems that might be solved separately.

More qubits means a flatter landscape and more parameters and more shots per parameter. The bill is a product, and every term grows the wrong way.

Chapter 24 §24.7 listed three barriers to VQE in order: shot budget, barren plateaus, hardware noise. QML has all three, multiplied by the dataset.


32.6 Is there any demonstrated advantage?

The honest state of the field, as carefully as it can be stated.

There are proven separations, on constructed problems. Results exist showing learning tasks a quantum learner can solve efficiently and a classical one cannot, under standard complexity assumptions. These are real theorems. They are also, without exception so far, about problems constructed to exhibit the separation — typically involving data generated by a quantum process, or built on discrete-log-like structure. They establish that the question is not trivially closed. They do not establish that anything you would want to classify is in that class.

There is no demonstrated advantage on a natural dataset. Not on any benchmark, at any scale, against a tuned classical baseline. Where careful comparisons have been run, quantum models have generally matched or underperformed — and several results initially presented as advantages were subsequently reproduced classically, sometimes by the "dequantization" techniques that grew out of Ewin Tang's work on recommendation systems.

And the input problem may be decisive. If loading $N$ classical numbers costs $\mathcal{O}(N)$, then any quantum speedup on classical data must beat that cost, which rules out the exponential speedups that motivate the field. The cases where the argument survives are those where the data is already quantum — states produced by a physical process, or by another quantum computation — and there the input problem does not arise.

The strongest honest version of the QML case: it is a promising research direction with proven separations on constructed problems, no demonstrated advantage on natural data, and a structural input-loading obstacle that is unsolved.

That is a defensible thing to work on. It is not what most QML publicity says.

Chapter 21 §21.7 held Grover to this standard and found the crossover astronomically distant. Chapter 24 §24.5 held QAOA to it and found it below a 1995 classical guarantee at executable depth. Chapter 23 found the one algorithm in this book that clears the bar. The standard is not being applied to QML more harshly than to anything else.

Where this would flip

A conclusion is more useful when you can state the conditions that would reverse it. Four of them follow directly from the measurements above, and each is checkable in advance.

1. The loading cost has to vanish, which means the data has to already be quantum. Every argument in §32.2 is about getting classical numbers into a register. If the input is a state produced by a physical process, there is no state preparation, no $N - \log_2 N - 1$, no per-sample multiplier — and the exponential register saving becomes pure gain rather than an accounting trick. This is the single condition that changes the most calculations at once. Chapter 35 §35.2 tests it directly.

2. The baseline has to have headroom. Any comparison run on a dataset the classical models solve returns nothing, in either direction. The screening test is one line of sklearn and it belongs before the quantum code, not after — Chapter 33 §33.1 is that test, done properly.

3. The shot budget has to fit. §32.4's levers bring a 4-qubit toy problem down to 96 QPU-seconds, so small experiments are genuinely feasible today. The question is whether the interesting size fits, and 20 qubits did not, even with every lever pulled.

4. The plateau has to be avoided, not merely mitigated. The $2^{-n}$ derived above is a property of random parameters on an expressive ansatz. A problem-informed ansatz, warm-started initialization, or a local cost function each move the constant. None of them removes the exponent, and each of them requires knowing something about the problem in advance — which is exactly the resource a learning algorithm is supposed to save you.

Part VI's honest answer is that it looked for the flip in all four places, and it did not find it.

   where the flip was looked for                     result
   Ch.33  headroom (moons 0.30), 10 splits      -0.0626 +/- 0.0067 vs kNN
   Ch.33  same, against LogisticRegression      +0.0202 +/- 0.0170  not significant
   Ch.34  a quantum kernel, tuned               0.8313 +/- 0.0381 vs SVC(rbf) 0.8889
   Ch.35  data that is ALREADY QUANTUM          0.6429 vs SVC(rbf) 0.7857

The fourth line is the one to sit with. Condition 1 — the strongest surviving case for QML, the one this section just named as decisive — was tested on quantum data, and the classical model still won by 0.1428. That does not refute the argument; a single dataset never does, and the theoretical case for quantum data remains the best one available. But it is what was measured, and Chapter 40's tally of six head-to-head comparisons across the whole book records zero quantum wins.

🗝️ Version Note: the QML API surface is the least stable in the book.

Verified against this book's environment — Qiskit 2.5.1, PennyLane 0.45.1:

qiskit.extensions no longer exists. State preparation moved to qiskit.circuit.library.StatePreparation; older tutorials importing Initialize from qiskit.extensions fail with ModuleNotFoundError, not a deprecation warning. Initialize is still available from qiskit.circuit.library.

The class-based circuit library is on its way out. Constructing ZZFeatureMap(2) in Qiskit 2.5.1 emits four deprecation warnings at once — for ZZFeatureMap, PauliFeatureMap, NLocal and BlueprintCircuit, all "deprecated as of Qiskit 2.1". The replacements are functions: zz_feature_map(...), real_amplitudes(...). Feature maps and ansätze are the two objects a QML script is built out of, so this refactor touches essentially every QML tutorial written before 2.1.

qiskit.pulse is gone entirely, removed in Qiskit 2.0 along with add_calibration, .calibrations, backend.defaults and instruction_schedule_map — which is Chapter 31's subject and its §31.6 explains why.

And qiskit-machine-learning is a separate package, not installed here, which is why this chapter's classifier is PennyLane. That is a real decision point rather than a detail: the two ecosystems have different release cadences, and a QML project pins whichever one it builds on.

The stable parts are the ones this chapter is actually about. $N - \log_2 N - 1$, $(2n+1)$, and $2^{-n}$ do not have a deprecation schedule.


32.7 What Part VI is for, given that

Three reasons to keep reading, and they are not consolation prizes.

The techniques are genuinely interesting and transferable. Quantum kernels (Chapter 34) have a clean mathematical story: a feature map into Hilbert space, with the kernel computable by a circuit whose classical evaluation may be hard. That is a well-posed idea with real content, whatever its practical standing.

The negative results are load-bearing. Barren plateaus, the input problem, and dequantization are among the most useful things quantum computing has learned in the last decade, and they were learned by people trying to make QML work. A field that produces sharp impossibility results is doing science.

And the quantum-data case is real. When the input is already a quantum state — a molecular ground state from Chapter 24, a state from a physics experiment, output from another quantum computation — the loading cost vanishes and the argument changes completely. Chapter 35 returns to this.


32.8 How to read a QML paper

Assembling everything, the checklist Part V's chapters have been building toward:

   1. WHAT IS THE CLASSICAL BASELINE, and is it tuned? If the paper reports
      only its own model's accuracy, that is not a comparison.

   2. IS THE DATASET ONE CLASSICAL METHODS SOLVE PERFECTLY? Iris, moons, and
      circles all do. A tie on an easy problem distinguishes nothing.

   3. HOW WAS THE DATA ENCODED, and what did it cost? Amplitude encoding's
      log2(N) qubits comes with O(N) gates, PER SAMPLE.

   4. WHAT IS THE TOTAL SHOT COUNT? (2n+1) x samples x steps x shots. It is
      one line, it is almost never reported, and it decides feasibility.

   5. WAS IT RUN ON HARDWARE, or on an exact simulator? Chapter 27 Sec 27.5
      measured what shot noise does; an exact simulator hides all of it.

   6. HOW DOES IT SCALE? Gradient variance, and whether the authors measured
      it (Chapter 16 Sec 16.6) or assumed it.

   7. IS THE DATA CLASSICAL? If so, the input problem applies and no
      exponential speedup survives it.

The checklist, applied to this chapter

A checklist you will not turn on your own work is a rhetorical device. So:

   1. BASELINE?          Three, run before the quantum model. NOT tuned --
                         no grid search on SVC. FAILS its own standard,
                         and Exercise 32.14 is the fix.
   2. SATURATED?         Yes. All three baselines at 1.0000. The comparison
                         is void, and §32.3 says so in place of a verdict.
   3. ENCODING COST?     Angle, 4 features on 4 qubits, zero two-qubit
                         gates. Reported. The cheap case.
   4. TOTAL SHOTS?       2.06e9, computed. Not spent -- see item 5.
   5. HARDWARE?          NO. Exact simulator, no shots, no noise. The most
                         favourable possible conditions, stated every time
                         the 50.2 s is quoted.
   6. SCALING MEASURED?  Yes, 2 to 10 qubits, with the exclusion count.
                         Only to 10 qubits; 20 is extrapolation and is
                         labelled as such.
   7. DATA CLASSICAL?    Yes. The input problem applies in full.

Four of the seven are answered honestly and unfavourably; one is failed outright. The classical baseline in §32.3 is untuned — SVC() at defaults, LogisticRegression() at defaults — which happens not to matter here only because they already reach 1.0000 and cannot be improved. On any dataset with headroom it would matter a great deal, and a result reported against an untuned baseline is the failure this chapter's Case Study 1 is about.

That is the useful thing about running the checklist on yourself: it finds the item you would have excused.

🧪 Run It: three experiments that change a number in this chapter.

Each takes minutes and each tests a claim made above rather than reproducing one.

1. Make the plateau steeper by making the ansatz better. The Math Aside in §32.5 predicts that depth drives the collapse toward $2^{-n}$. Edit LAYERS = 2 to LAYERS = 6 in example-03-the-constraints-multiply.py and re-run. The prediction is that the 88× collapse moves toward Chapter 16's 224× — the more expressive circuit should be the less trainable one. If it does not, the prediction was wrong and that is the more interesting outcome.

2. Break the encoding on purpose. Delete the StandardScaler from load_data() in example-02-vqc-versus-sklearn.py and re-run. Iris's raw features are on different scales, so the angle encoding sees them at different effective resolutions. Watch what happens to the VQC's accuracy while all three classical baselines — which are scale-tolerant in ways the encoding is not — barely move.

3. Find out where the tie becomes informative. Replace load_iris with make_moons(n_samples=300, noise=0.30) and re-run everything. The four classical models should separate (Chapter 33 §33.1 measured 0.768 to 0.949 on exactly this), which means the comparison starts carrying information for the first time. This is Chapter 33's opening move, and doing it yourself first is the best possible preparation for it.

One rule for all three: write the number down before you run it. A prediction recorded in advance is the only version of a prediction that can be wrong, and this book's seven documented corrections all came from numbers that disagreed with what their author expected.


What we measured

  • Amplitude encoding: 128 features in 7 qubits, and 227 transpiled two-qubit gates to load them. Gate count grows linearly in $N$; at Chapter 12's error rate the loading alone survives with probability 0.18.
  • Encoding is per sample. A 1,797-sample dataset at 60 steps needs 107,820 state preparations.
  • ★ On iris-binary, LogisticRegression, SVC and RandomForest all reach 100% test accuracy, in 0.6–61 ms.
  • ★★ A 4-qubit, 24-parameter VQC reaches the same 100% test accuracy in 50.2 s on an exact simulator~20,000× slower than logistic regression, with no shots and no noise.
  • Amplitude-encoding gate counts follow exactly $N - \log_2 N - 1$: 1, 4, 11, 26, 57, 120.
  • ★★ Training on hardware: $(2n+1) \times \text{samples} \times \text{steps} \times \text{shots} = 49 \times 70 \times 60 \times 10{,}000 =$ 2.06 billion shots = 57.2 QPU hours = 2.38 days — to match a 2.2 ms model.
  • ★ Gradient variance falls 1.03e-01 → 1.17e-03 across 2 to 10 qubits (88×) — Chapter 16's barren plateau in the QML setting.
  • ★★ The constraints multiply: extrapolating the measured trend, a 20-qubit model needs 6.63e+12 shots for the same 70-sample problem.

The theme: getting classical data into a quantum computer costs more than the computation — and matching a baseline on a problem the baseline solves perfectly distinguishes nothing.