πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
NEWSLIVESearch All Content
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Quantum Machine Learning

Quantum ComputingQuantum Machine Learning🟒 Free Lesson

Quantum-Classical ML Hybrids

Quantum machine learning (QML) combines quantum computing with classical machine learning. The main paradigms are:

  1. Quantum-enhanced feature maps: encode data into quantum states
  2. Parameterized quantum circuits: quantum analogues of neural networks
  3. Quantum kernels: compute kernel functions in quantum feature spaces
  4. Quantum data: process quantum data with quantum algorithms

The promise of QML is accessing exponentially large feature spaces while using only polynomially many qubits.

The promise has one precondition that decides most disputes: the input model. A quantum circuit can evaluate a kernel entry in time polynomial in the qubit count only if the data points are already loaded into amplitudes, and loading classical points costs gates without a quantum memory. Speedup claims are therefore conditional statements about who holds the data and in what form, which is why the field separates "quantum data" problems β€” where the input was produced by a quantum device and never existed classically β€” from "classical data" problems, where every gate spent encoding is a gate subtracted from the speedup.

Quantum Feature Maps

A quantum feature map maps classical data to a quantum state:

The kernel trick uses inner products in the quantum feature space:

This kernel is efficiently estimable on a quantum computer but may be hard to compute classically β€” providing potential quantum advantage.

The kernel is a valid Mercer kernel by construction: is the modulus squared of an inner product, so the resulting matrix is positive semi-definite and a classical SVM can consume it without modification. The open question is not validity but hardness. A map built from two layers of single-qubit rotations and a controlled-phase is efficiently contractible classically, because the statevector is reachable by a tensor network of bond dimension polynomial in the qubit count. Advantage requires depth or entangling structure that pushes that contraction cost past the quantum evaluation cost, and proving that a given map clears the bar is itself an open research problem.

Quantum Support Vector Machine (QSVM)

The QSVM uses a quantum kernel in a classical SVM framework:

  1. Encode training data into quantum states:
  2. Estimate the kernel matrix via quantum circuits
  3. Feed into a classical SVM for training

The quantum advantage arises if the kernel is hard to compute classically. However, dequantization results suggest this advantage may be limited for certain data distributions.

The measurement cost is worth spelling out. Each kernel entry is estimated from shots with variance bounded by the quantum CramΓ©r-Rao bound, so the matrix costs state preparations, and shot noise makes the estimated matrix slightly indefinite β€” an SVM tolerates that, but a kernel method that needs a matrix inverse does not. Practical implementations therefore treat as a hyperparameter tuned on a validation split, exactly as a classical practitioner would tune the number of Monte Carlo samples in a random-feature baseline.

Quantum Neural Networks (QNNs)

A QNN uses a parameterized quantum circuit as a model:

where encodes input data and is a trainable circuit.

The training loop:

  1. Forward pass: measure the QNN output
  2. Compute loss
  3. Compute gradients (via parameter-shift rule)
  4. Update parameters:

The parameter-shift rule provides exact gradients:

Two properties make the rule practical. The shift is regardless of circuit depth, so the gradient costs two circuit evaluations no matter how many gates sit behind the parameter β€” unlike finite differences, whose step size must shrink with the curvature of the composition. And the estimator is unbiased with no truncation error, so the only noise is shot noise. With shots per evaluation, the gradient standard deviation scales as , which sets the learning rate ceiling: a training run that steps before the gradient sign is reliable will wander, and the standard fix is to raise early and decay it as the parameters settle.

Barren Plateaus in QML

QNNs suffer from barren plateaus where gradients vanish exponentially. For a random QNN with qubits and depth :

This means training requires measurements to estimate gradients β€” negating any quantum advantage.

Solutions: structured circuits, local cost functions, layerwise training, and noise-aware optimization can mitigate barren plateaus.

The mechanism is twofold. A wide, deep circuit of random two-qubit gates approximates a design whose output state is close to Haar-random, and a Haar-random state spreads expectation values so thinly across the basis states that any single-qubit observable concentrates at its mean with variance . The cost function then inherits that concentration, and its derivatives inherit it too. The second mechanism is the initialisation: starting from the identity β€” all parameters at zero β€” keeps the circuit in a structured subspace where gradients are still visible, which is why layerwise training works: grow the circuit by one layer, train until the gradient signal fades, then grow again.

Quantum Generative Models

Quantum Born machines use quantum circuits to generate probability distributions:

Training minimizes the KL divergence between the quantum distribution and the data distribution. Quantum GANs use a quantum generator and classical (or quantum) discriminator.

These models can represent distributions that are exponentially hard for classical generators, though practical advantages remain an active research area.

The training signal is the hard part. A Born machine cannot be trained by maximum likelihood on the full distribution β€” evaluating for all strings is exponential β€” so it is trained by sampling: draw strings from the circuit, compare the empirical histogram with the data histogram, and update. Shot noise enters the loss directly, and for sparse distributions where most of the outcomes have zero probability, most samples land on outcomes the model should have suppressed, producing a gradient dominated by estimation error. This is the same barren-plateau pressure in a different costume, and it is why reported Born-machine results stay in the tens-of-qubits range where the histograms are still resolvable.

Python: Fidelity Kernel on Real Data Points

The kernel formula is directly simulable on a laptop for a handful of qubits, and the comparison below separates what the entangling layer contributes from what the single-feature rotations would give on their own:

python
import numpy as np

def ry(theta):
    c, s = np.cos(theta / 2), np.sin(theta / 2)
    return np.array([[c, -s], [s, c]], dtype=complex)

def crz(theta):
    # controlled-Rz with control on qubit 0, target on qubit 1
    e0, e1 = np.exp(-1j * theta / 2), np.exp(1j * theta / 2)
    return np.diag([1, 1, e0, e1]).astype(complex)

def feature_state(x, entangling=True):
    psi = np.array([1, 0, 0, 0], dtype=complex)
    for layer in (1, 2):
        psi = np.kron(ry(x[0] / layer), ry(x[1] / layer)) @ psi
        if entangling:
            psi = crz(np.pi / 2) @ psi
    return psi

def fidelity_kernel(X, entangling=True):
    states = [feature_state(x, entangling) for x in X]
    return np.array([[np.abs(np.vdot(a, b)) ** 2 for b in states] for a in states])

rng = np.random.default_rng(3)
X = rng.uniform(-np.pi, np.pi, size=(5, 2))

K_ent = fidelity_kernel(X, entangling=True)
K_sep = fidelity_kernel(X, entangling=False)
print(np.round(K_ent, 3))
off = K_ent[~np.eye(len(K_ent), dtype=bool)]
print(f"off-diagonal entries span {off.min():.3f} to {off.max():.3f}")
print(f"entry (0,2): entangling {K_ent[0,2]:.3f}, separable {K_sep[0,2]:.3f}")

The matrix printed has unit diagonal and entries between 0.001 and 0.639 off it, and the last line is the informative one: pair scores 0.639 through the entangling map and 0.362 without it. The controlled- is what stops the kernel from collapsing into a product of per-feature overlaps, and non-factorising similarity of that kind is the minimum a classical model would have to reproduce to match the quantum classifier.

Python: Watching a Barren Plateau Form

The same simulator can measure the gradient variance directly, by sampling random parameter settings and applying the parameter-shift rule to one parameter of a depth-scaled circuit:

python
import numpy as np

def apply_rx(psi, q, theta, n):
    out = psi.copy()
    step = 2 ** (n - 1 - q)
    c, s = np.cos(theta / 2), np.sin(theta / 2)
    for base in range(0, 2 ** n, 2 * step):
        for j in range(base, base + step):
            k = j + step
            out[j] = c * psi[j] - 1j * s * psi[k]
            out[k] = -1j * s * psi[j] + c * psi[k]
    return out

def apply_ry(psi, q, theta, n):
    out = psi.copy()
    step = 2 ** (n - 1 - q)
    c, s = np.cos(theta / 2), np.sin(theta / 2)
    for base in range(0, 2 ** n, 2 * step):
        for j in range(base, base + step):
            k = j + step
            out[j] = c * psi[j] - s * psi[k]
            out[k] = s * psi[j] + c * psi[k]
    return out

def apply_cnot(psi, control, target, n):
    out = psi.copy()
    cmask, tmask = 1 << (n - 1 - control), 1 << (n - 1 - target)
    for i in range(len(psi)):
        if (i & cmask) and not (i & tmask):
            out[i], out[i ^ tmask] = psi[i ^ tmask], psi[i]
    return out

def circuit(params, n, layers):
    psi = np.zeros(2 ** n, dtype=complex)
    psi[0] = 1.0
    idx = 0
    for _ in range(layers):
        for q in range(n):
            psi = apply_rx(psi, q, params[idx], n); idx += 1
        for q in range(n):
            psi = apply_ry(psi, q, params[idx], n); idx += 1
        for q in range(n - 1):
            psi = apply_cnot(psi, q, q + 1, n)
    return psi

def cost(params, n, layers):
    psi = circuit(params, n, layers)
    probs = np.abs(psi) ** 2
    signs = np.array([1 if (i >> (n - 1)) == 0 else -1 for i in range(2 ** n)])
    return float(probs @ signs)

def grad(params, n, layers, j):
    up, dn = params.copy(), params.copy()
    up[j] += np.pi / 2
    dn[j] -= np.pi / 2
    return (cost(up, n, layers) - cost(dn, n, layers)) / 2

for n in (2, 4, 6, 8):
    rng = np.random.default_rng(1)
    layers = n
    grads = [grad(rng.uniform(0, 2 * np.pi, size=2 * n * layers), n, layers, 0)
             for _ in range(200)]
    print(f"n={n}: var(grad) = {np.var(grads):.3e}, mean |grad| = {np.mean(np.abs(grads)):.3f}")

Variance falls from at to at , and the mean gradient from 0.27 to 0.065. That is a factor of 18 across six extra qubits in a two-qubit-wide connectivity pattern; the theoretical bound is the steeper , and deeper random circuits reach it. Either way the sample cost to resolve the gradient sign grows exponentially, which is exactly the wall the variance bound predicts β€” and the reason a laptop simulation of eight qubits is the honest upper limit for this style of training.

When a Speedup Survives Dequantization

Classical simulation results set the bar that QML claims must clear, and they have already removed some candidates.

Tang's 2019 classical algorithm solves the recommendation-system problem in time polynomial in the rank and the logarithm of the matrix dimensions, given the same classical description of the input that the quantum algorithm assumed. Applied to quantum PCA, the lesson was sharper still: the exponential separation rested on fast quantum access to the data, and once a classical algorithm is allowed comparable access the separation shrinks to polynomial. The surviving regime is narrower and better defined β€” quantum data that cannot be written down classically, kernels whose evaluation provably requires exponential classical resources, or learning tasks where the model itself is a quantum state.

ModelWhat is trainedCost per stepDocumented failure mode
Quantum kernel SVMnothing on the circuit state preparations per entryshallow maps are classically simulable
Parameterised circuit (QNN)circuit angles circuits per parameterbarren plateaus at width
Quantum Born machinecircuit anglessampling plus histogram distanceshot noise dominates sparse targets
Quantum Boltzmann machinethermal state parametersphase estimation per samplestate preparation dominates cost

Quantum ML Challenges

  1. Data loading: encoding classical data into quantum states may negate speedup
  2. Barren plateaus: gradients vanish exponentially with qubit count
  3. Noise: NISQ errors degrade model performance
  4. Classical simulability: many QML models can be efficiently simulated classically
  5. Interpretability: quantum models may be harder to interpret than classical ones

The field is actively researching which QML applications can provide genuine quantum advantage.

Each item has a measurable signature rather than being a slogan. Loading cost appears as gate count that grows with the dataset size rather than with the model. Barren plateaus appear as the variance decay measured above. Noise appears as a kernel matrix whose off-diagonal entries shrink toward a constant as depolarising noise pushes states toward the maximally mixed state, at which point every kernel entry tends to and the classifier degenerates to majority vote. Simulability appears when a tensor-network contraction of the same circuit finishes on a laptop while the quantum device is still queuing jobs.

Summary

Quantum machine learning offers three concrete mechanisms β€” kernels evaluated in a quantum feature space, parameterised circuits trained by the parameter-shift rule, and generative models whose samples are Born-machine measurements β€” and each one is fully analysable before any hardware is booked. The fidelity kernel for a two-layer map is a -state overlap, the parameter-shift gradient costs exactly two circuits per parameter at any depth, and the gradient variance for random circuits decays from at two qubits to at eight, which is the barren plateau appearing in a simulation rather than in a conjecture.

The decision rules follow from those measurements. Barren plateaus mean width must be paid for with structure β€” local cost functions, layerwise growth, or an identity initialisation. Dequantisation means a claimed speedup must survive a classical algorithm given the same input model, which leaves quantum data and provably hard kernels as the live candidates. And data loading means the honest accounting subtracts encoding gates from the speedup before the comparison is drawn.

Common Mistakes

Reporting a quantum kernel advantage without stating how the classical data reached the circuit

Fix: Count the loading gates: amplitude encoding costs order N without a quantum memory, and that cost is charged against the speedup before any comparison

Scaling a variational model to twenty qubits and blaming hardware noise when the gradients vanish

Fix: Measure the gradient variance first; random circuits fall by roughly a factor of two per added qubit, so switch to a local cost function or layerwise training before touching the device

Quoting a quantum speedup that dequantisation has already closed

Fix: Re-run the comparison with a classical algorithm given the same input model β€” sparse or low-rank access removes the exponential gap in recommendation systems and quantum PCA

Key Takeaways

  • A quantum kernel built as the modulus squared of a state overlap is automatically positive semi-definite, so a classical SVM can consume it, but advantage requires a map that a tensor network cannot contract cheaply
  • The parameter-shift rule gives exact gradients with two circuit evaluations per parameter at any depth, with variance falling as one over the shot count
  • Gradient variance for random parameterised circuits decays exponentially with width, measured here as 0.12 at two qubits down to 0.0069 at eight, which sets an exponential shot budget for training
  • Dequantisation results remove the exponential gap whenever the classical algorithm receives the same input model that the quantum speedup assumed
  • Data loading is the quiet term in every classical-data QML claim: encoding N points into amplitudes costs order N gates without a quantum memory
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-15

β€”
β˜†β˜†β˜†β˜†β˜†
0 ratings

Rate & Feedback

Need Expert Quantum Computing Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement