You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.
Classical ML vs. Quantum ML: The Hybrid Loop
How a neural network and a variational quantum model learn, side by side, and an honest look at when QML helps.
- 01Describe the hybrid loop: encoding, parameterised circuit U(θ), measurement, classical optimiser.
- 02Map each part of a neural network to its counterpart in a quantum model.
- 03Say where QML is a reasonable research bet and where classical ML is the better tool today.
A neural network learns by adjusting numbers. The input x is multiplied by a weight matrix W, passed through a non-linear activation, compared with the right answer by a loss function, and the weights are nudged downhill along the gradient. A quantum model keeps exactly this loop and replaces the model in the middle with a circuit.
| Step | Classical neural network | Hybrid quantum model |
|---|---|---|
| Input | a vector x of numbers | x written into rotation angles (encoding, feature map) |
| Model | layers: W·x, then an activation | parameterised circuit U(θ), the ansatz |
| Output | numbers from the last layer | expectation values such as ⟨Z⟩, estimated from shots |
| Loss | computed on the CPU or GPU | computed on the CPU from the measured values |
| Update | backpropagation through all layers | gradients from extra circuit runs, or a gradient-free optimiser such as COBYLA |
| Hardware | CPU or GPU | QPU for the circuit, CPU for everything else |
01One turn of the hybrid loop
- 1. The CPU chooses the parameters θ.
- 2. The QPU runs encoding + U(θ) for many shots.
- 3. The CPU turns the counts into expectation values and a loss.
- 4. The optimiser updates θ and the loop starts again until the loss stops falling.
Be the optimiser
The first ry is the data point x = 0.8, the second is the trainable weight θ = 1.2. Simulate and compute ⟨Z⟩ = P(0) − P(1) from the histogram (about −0.42). Here ⟨Z⟩ = cos(0.8 + θ): change θ to −0.8 and every shot reads 0; change it to 2.34 and almost every shot reads 1. Each edit is one turn of the loop done by hand.
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
bit[1] c;
ry(0.8) q[0];
ry(1.2) q[0];
c[0] = measure q[0];
02When does QML help? An honest answer
- Images, text, tables of business data and large language models: classical ML is the right tool. Today's chips have few qubits, slow data loading and shot noise, and no advantage has been shown on such data.
- Loading many classical numbers into a circuit is itself expensive, and that cost can cancel a speed-up that looks good on paper.
- Promising directions: data that is already quantum (states from a quantum sensor or simulation, molecules and materials) and quantum kernels, which compare data points in a very large feature space. Whether they beat classical methods on practical problems is still an open research question.
- Training has its own limits: in deep, randomly initialised circuits the gradients can vanish exponentially with the number of qubits (barren plateaus).
2 questions · one try each counts
In the hybrid loop, which part runs on the quantum processor?
Sign in to answer and climb the ranks; you will come back to this lesson.
Which statement about QML today is the most honest?
Sign in to answer and climb the ranks; you will come back to this lesson.