Part VI: Quantum Machine Learning

"A parameterized quantum circuit is a function from parameters to expectation values. If you can differentiate it, you can train it. Whether training it buys you anything is a separate and much harder question."

Quantum machine learning is the most exciting and the most oversold area in quantum computing, and this part tries to give you both facts at once.

The exciting part is real and it is elegant. A parameterized quantum circuit is a differentiable function. You can compute its gradients exactly — not by backpropagation, which would require observing intermediate states you are not allowed to observe, but by the parameter-shift rule, a genuinely clever identity that gets exact derivatives by running the circuit twice at shifted parameter values. That means a quantum circuit can be dropped into a PyTorch model as a layer and trained by the same optimizer that trains everything else. The engineering works. You will build it in Chapter 32 and have a trained quantum model by the end of Chapter 33.

The oversold part is also real. On today's hardware, for essentially every practical dataset, a classical model is faster, cheaper, and more accurate. Not marginally — overwhelmingly. Chapter 33 trains a quantum classifier on the Iris dataset and then trains a logistic regression on the same data, and the logistic regression wins on every axis including wall-clock time by several orders of magnitude. Chapter 34 examines the quantum kernel literature and finds demonstrated advantage on constructed datasets designed to exhibit it, and nothing convincing on natural data. These chapters report that plainly.

Both things are true simultaneously, and holding both is the professional posture. The architecture is worth learning now because it is not obvious, because it takes time to internalize, and because the people who understand it will be the ones who recognize the moment it starts working. What is not defensible is telling a stakeholder that quantum machine learning will improve their recommendation engine.

What You Will Learn

Chapter 32 — QML Fundamentals. Variational circuits as learnable models. The parameter-shift rule, derived and then implemented. QNodes as differentiable functions. Optimizers, cost landscapes, and a first trained quantum circuit. And a precise statement of what "quantum advantage in machine learning" would actually require — which is a more interesting question than it sounds.

Chapter 33 — Quantum Classifiers. Data encoding, which is where most of the design decisions live: basis, angle, amplitude, and IQP encodings, and their very different costs. Ansatz choices. Cost functions and the training loop. A complete classifier on the Iris dataset, trained and evaluated — followed immediately by the classical baseline, in full.

Chapter 34 — Quantum Kernels. The kernel trick, and why quantum feature maps are a natural fit for it. Computing a kernel matrix from circuit overlaps. Feeding it to a classical SVM. Projected quantum kernels. The quadratic scaling problem that nobody mentions in the abstracts. And a survey of what the evidence actually supports.

Chapter 35 — Hybrid Architectures. Quantum layers inside classical networks, in PyTorch. End-to-end training through both. Transfer learning with a quantum head. And the central practical problem of the field: barren plateaus — why gradients vanish exponentially with circuit width, how to detect it in your own model, and the mitigations (local cost functions, shallow circuits, smart initialization, data re-uploading) that partially address it.

How This Part Fits

Part VI depends on Parts I and II, on Chapter 16 (PennyLane is the primary tool throughout), and on Chapter 24 (the variational loop is the same loop). If you jumped here from Part III on the 🤖 Quantum ML path, read Chapter 24 first — it is the direct ancestor of everything in this part.

Part VI is self-contained with respect to Part VII; nothing later depends on it.

Time Investment

Chapter Title Difficulty Est. hours
32 QML Fundamentals Intermediate 7
33 Quantum Classifiers Intermediate 7
34 Quantum Kernels Advanced 6
35 Hybrid Architectures Advanced 7
Part VI total ~27 hours

The Project in This Part

vqelab's ansatz turns out to be a machine learning model.

That is not a metaphor. The hardware-efficient ansatz you built for VQE — parameterized rotations, entangling layers, an expectation value as output — is structurally identical to a quantum neural network. Chapter 32 wraps it as a differentiable QNode and verifies the parameter-shift gradients against finite differences. Chapter 33 reuses it as a classifier. Chapter 34 reuses it as a feature map. Chapter 32 §32.5 runs a barren-plateau diagnostic on it, which will tell you something uncomfortable and useful about the ansatz depth you chose back in Chapter 8. Chapter 35 puts the whole thing inside a hybrid loop and insists on the classical baseline first — where, on genuinely quantum data, a classical model reading nothing but the measured probabilities beats the quantum classifier 0.7857 to 0.6429.

The insight this part delivers is that VQE and QML are the same computational pattern with different loss functions. Once you see it, a large amount of the near-term quantum literature collapses into one idea.

Turn to Chapter 32.

Chapters in This Part