|q⟩ Bad Qubits

intermediate · Programming · Quantum Machine Learning (Intro)

What Is Quantum Machine Learning?

Quantum machine learning (QML) sits at the intersection of two of the most active areas in modern science: quantum computing and machine learning. The central question is whether quantum hardware can offer a meaningful advantage — in speed, expressibility, or sample efficiency — on tasks that are economically or scientifically important.

What machine learning is trying to do

Classical machine learning trains a parameterised function fθf_\theta on data so that some loss L(θ)\mathcal{L}(\theta) is minimised. The function might be a neural network predicting drug toxicity, a support-vector machine classifying images, or a generative model producing text. Training means adjusting θ\theta along the gradient θL\nabla_\theta \mathcal{L}.

The bottleneck is often one of three things:

QML asks whether quantum mechanics can ease any of these three bottlenecks.

The quantum side

A quantum computer works with state vectors in a 2n2^n-dimensional Hilbert space. Even a modest register of n=50n = 50 qubits has 25010152^{50} \approx 10^{15} complex amplitudes — far more than the classical memory needed to write them all down explicitly. This exponential dimension is the resource that QML tries to exploit.

The main vehicle is the parameterised quantum circuit (PQC), sometimes called a variational quantum circuit or ansatz. A PQC is a circuit U(θ)U(\theta) whose gates depend on a vector of real angles θ=(θ1,,θp)\theta = (\theta_1, \dots, \theta_p). Given an input state ψin|\psi_\text{in}\rangle, the circuit produces

ψ(θ)=U(θ)ψin,|\psi(\theta)\rangle = U(\theta)\,|\psi_\text{in}\rangle,

and a measurement expectation value like Z0\langle Z_0 \rangle is returned as the model's output. Varying θ\theta is how the model is trained.

Core QML scenarios

Researchers distinguish four rough scenarios, depending on whether the data and the model are classical or quantum:

| Data source | Model | Setting | |-------------|-------|---------| | Classical | Classical | Standard ML (no quantum) | | Classical | Quantum | Quantum-enhanced ML (most near-term work) | | Quantum | Classical | Learning from quantum experiments | | Quantum | Quantum | Fully quantum learning |

Near-term work focuses on the classical data, quantum model setting because it is accessible on today's noisy intermediate-scale quantum (NISQ) devices. The hope is that the large Hilbert space allows the quantum model to represent correlations that would require exponentially many classical parameters.

How data enters the circuit

Before a PQC can process classical features xRdx \in \mathbb{R}^d, those features must be encoded into qubits. Three common strategies are:

  1. Basis encoding — store a binary string x{0,1}nx \in \{0,1\}^n as the computational-basis state x|x\rangle. Simple, but wastes superposition.
  2. Amplitude encoding — pack 2n2^n normalised values xi/xx_i / \|x\| directly into the amplitudes. Exponentially compact, but state preparation can itself be expensive.
  3. Angle encoding — apply a single-qubit rotation Ry(xi)R_y(x_i) per feature, one qubit per feature. Shallow and hardware-friendly, used in most near-term experiments.

The lesson on Encoding Classical Data in this module covers these in detail.

Quantum kernels

A particularly clean theoretical framework maps QML onto kernel methods. Define the quantum feature map ϕ(x)=U(x)0n\phi(x) = U(x)|0\rangle^{\otimes n} for some encoding circuit U(x)U(x). The quantum kernel is then

κ(x,x)=0nU(x)U(x)0n2.\kappa(x, x') = |\langle 0|^{\otimes n} U^\dagger(x)\,U(x')|0\rangle^{\otimes n}|^2.

This quantity is the squared overlap (fidelity) of two quantum feature vectors — easy to estimate on hardware by running the two circuits in sequence and measuring all zeros. A classical support-vector machine trained with this kernel inherits whatever structure the quantum feature map can express more compactly than any efficient classical kernel.

The optimisation challenge

Training a PQC means minimising L(θ)\mathcal{L}(\theta) with gradient descent. Gradients are accessible via the parameter-shift rule: for a gate eiθP/2e^{-i\theta P/2} (with PP a Pauli operator), the partial derivative is

θjO=12[Oθj+π/2Oθjπ/2].\frac{\partial}{\partial \theta_j}\langle O \rangle = \frac{1}{2}\big[\langle O \rangle_{\theta_j + \pi/2} - \langle O \rangle_{\theta_j - \pi/2}\big].

Each gradient component therefore costs two circuit evaluations — comparable to back-propagation in classical neural networks, but multiplied by the shot overhead of quantum measurement.

A severe obstacle is the barren plateau: for randomly initialised, sufficiently deep circuits, gradients vanish exponentially in the number of qubits. This is an active area of research; proposed mitigations include local cost functions, layer-by-layer pre-training, and problem-inspired ansatz design.

Where QML stands today

As of the mid-2020s, rigorous quantum advantage for practical ML tasks has not been demonstrated on real data. Several theoretical results show that quantum kernel methods can achieve exponential separation from classical methods on carefully constructed distributions, but translating this to real-world datasets remains an open problem. QML is best understood today as a research frontier rather than a deployed technology.

What this module covers

The remaining lessons in this module walk through the building blocks you need to implement QML pipelines on the simulator:

Each lesson is hands-on: you will write the circuit code and observe how the loss surface and decision boundary change as training progresses.

Sign in on the full site to ask questions and join the discussion.