Chapter 34 — Key Takeaways (Quantum Kernels)

The cleanest mathematical story in Part VI, presented on its merits before it is costed.

The idea

$$K(x, x') = \big|\langle \phi(x) | \phi(x')\rangle\big|^2 = \big|\langle 0|U^\dagger(x)U(x')|0\rangle\big|^2$$

⚛️ That is exactly the probability of measuring $|0\dots0\rangle$ after running $U(x')$ then $U^\dagger(x)$. One circuit, one number — and the $2^n$-dimensional feature vector is never constructed, exactly as classical kernel methods never construct theirs.

@qml.qnode(dev)
def kernel_circuit(x1, x2):
    feature_map(x1)
    qml.adjoint(feature_map)(x2)
    return qml.probs(wires=range(n_qubits))

Measured: $K(x,x) = 1.000000$ exactly, symmetric to machine precision. Both are one line to check, and an SVM will fit a matrix that fails them.

Batching

   201 x 201 = 40,401 entries:   51.3 s looping   ->   0.11 s batched   (~500x)

PennyLane broadcasts over a leading batch axis. On a simulator this is the difference between a chapter that runs and one that times out; on hardware it is one job submission rather than 40,401.

★ Training is convex — the advantage that is real

   SVC(kernel='precomputed').fit  ->  1.2 ms       support vectors: 91 of 201
                        variational (Ch. 33)        kernel (Ch. 34)
   landscape            non-convex                  CONVEX
   initialization       random, matters             none
   learning rate        a hyperparameter            none
   barren plateaus      measured, 88x collapse      not applicable
   optimum              whatever 60 steps found     found exactly
   reproducibility      seed-dependent              deterministic

🔬 Every trainability problem Part VI has measured DISAPPEARS. The quantum circuit computes a fixed function; the learning is classical and solved.

The quantum part is no longer being optimized. It is being evaluated.

★ But the design problem moves, it does not vanish

    qubits  reps  scale   test acc
         2     1    1.0     0.8500     <- tuned
         2     1    2.0     0.6833
         2     2    1.0     0.6167
         3     2    2.0     0.5833
   (untuned first attempt: 0.6364)

0.6364 untuned to 0.8500 tuned — a larger swing than any method-to-method difference in this chapter.

⚠️ "No hyperparameters to train" is not "no hyperparameters." The learning rate and initialization are gone; the feature map's structure, depth, entangling pattern and input scaling replace them. A quantum kernel result without a feature-map sweep is a result about one arbitrary feature map.

★★ The comparison

Ten independent datasets and splits:

   model                        mean      std     min     max
   quantum kernel SVM         0.8313   0.0381  0.7778  0.9091
   SVC (rbf)                  0.8889   0.0310  0.8283  0.9394
   kNN                        0.8970   0.0377  0.8283  0.9495
   LogReg                     0.8414   0.0463  0.7677  0.9091

   SVC (rbf) - quantum = +0.0576 +/- 0.0083   SIGNIFICANT (7 sigma)
   kNN       - quantum = +0.0657 +/- 0.0137   SIGNIFICANT (5 sigma)
   LogReg    - quantum = +0.0101 +/- 0.0070   not significant

The classical RBF kernel wins, using the same SVM solver — the only difference between those rows is which kernel function was used.

And:

   quantum kernel SVM (Ch. 34)     0.8313 +/- 0.0381
   1-qubit variational (Ch. 33)    0.8343 +/- 0.0407      INDISTINGUISHABLE

The convexity advantage is real and it did not produce a better classifier. It removed the optimization problem, and the optimization was not what was limiting the result.

★★★ Kernel concentration — and a claim withdrawn

One independent feature per qubit:

    qubits   mean offdiag
         2        0.25147
         6        0.01497
        10        0.00088      <- several hundred fold collapse

I predicted this would cause memorization and chance-level generalization. Measured on the chapter's data:

    qubits   mean offdiag   train acc   test acc   support vecs      gap
         2        0.28387      0.8458     0.7778      91 / 201   0.0680
         8        0.04587      0.9552     0.8788     128 / 201   0.0764
        12        0.02531      0.9602     0.8889     144 / 201   0.0713

Test accuracy ROSE, 0.7778 → 0.8889. No memorization. Right mechanism, wrong regime:

    qubits   REDUNDANT (2 features)   INDEPENDENT (n features)
         2                  0.25346                    0.25147
        10                  0.02251                    0.00088

⚛️ Concentration is driven by the dimension of the data the map SEES, not by the qubit count. Re-encoding two features over ten qubits adds expressive depth without spreading the state — the extra qubits carry no new information about $x$, so they cannot make $\phi(x)$ and $\phi(x')$ more distinguishable.

The dangerous regime is high-dimensional data — exactly the regime kernel methods are for.

A failure mode's mechanism can be right while your judgement about whether it applies is wrong, and the second error is easier to make and harder to notice.

★★ The Gram bill

$n(n+1)/2$ entries, each a probability of size $K$ needing $\mathcal{O}(1/K^2)$ shots (Ch. 24 §24.3). Concentration and the shot budget multiply, as in Ch. 32 §32.5:

    qubits     mean K   shots/entry     total shots   QPU hours   QPU days
         2    0.25346            15       3.045e+05         0.0        0.0
         6    0.01494         4,480       9.095e+07         2.5        0.1
         8    0.00360        77,160       1.566e+09        43.5        1.8
        10    0.00078     1,643,655       3.337e+10       926.9       38.6

38.6 QPU-days for the Gram matrix alone, on 201 samples, for a kernel whose off-diagonal entries are 0.00078.

And the $n^2$ is the other half:

   training set   unique entries   vs n=201
            201           20,301         1x
          2,010        2,021,055       100x
         20,100      202,015,050     9,951x

🔬 Convexity removed the optimization. It did not remove the shots, and it introduced a quadratic. Ch. 33's cost was linear in the dataset; this is quadratic, with the constant set by concentration.

What the kernel argument establishes

  • The mathematics is clean and the structural advantage is real. A convex training problem is strictly better than a non-convex one, and a fixed similarity function is far easier to reason about than an optimization landscape.
  • There is a proven separation. Liu, Arunachalam and Temme (2021) construct a learning problem where a quantum kernel provably beats any classical learner. The kernel route is where QML's rigorous results live, and the fixed feature map is why the analysis is tractable.
  • On this data it loses by seven standard errors, using the same solver.
  • The costs are quadratic in the dataset and exponential in the concentration.

Quantum kernels are where the rigorous separations are, and where the optimization problems are not. They are also where the $n^2$ is, and where the feature map is doing all the work.

Common pitfalls

  • Not checking that the Gram matrix is a kernel (unit diagonal, symmetric, PSD).
  • Looping over pairs instead of batching (~500×).
  • Reporting one feature map as a method comparison.
  • Applying concentration results without checking the feature dimension.
  • Treating the removed training cost as a saving without costing the Gram matrix.
  • Evaluating the quadratic at demo size rather than production size.
  • Forgetting inference: every prediction needs a kernel against every support vector.

Project piece added this chapter

vqelab/kernels.pybatched_gram; validate_gram checking unit diagonal, symmetry and positive semi-definiteness; concentration_verdict, which requires n_features with no default and returns different verdicts for the same matrix under REDUNDANT, INDEPENDENT and OVERLOADED regimes; gram_shot_budget, which requires the measured concentration; and KernelReport, which is not a method comparison without a feature-map sweep, quoting the 0.6364 → 0.8500 swing. 19 tests pass, including test_validate_gram_rejects_a_matrix_that_is_not_a_kernel, test_concentration_verdict_REQUIRES_the_feature_dimension, test_the_redundant_regime_is_the_one_that_fooled_me, and test_concentration_and_the_shot_budget_MULTIPLY.