What a Generative Model Has to Learn
A quantum generative model is a parameterised circuit trained to reproduce a target probability distribution:
The training objective is divergence minimisation against , evaluated from samples rather than from a classical closed form. That single fact drives most of the engineering: you never see exactly, you estimate it from shots, and the standard error on an estimated probability is . For a 12-bit distribution there are 4096 bins; at and shots, the overwhelming majority of bins receive zero or one sample, so bin-wise divergence estimates are dominated by sampling noise until the shot budget grows into the millions.
Two structural advantages are claimed for the quantum version. Amplitudes are square roots of probabilities, so a circuit with qubits has free amplitudes â an exponentially large object â and interference lets a shallow circuit represent distributions that would need exponentially many parameters in an autoregressive or flow-based classical model. The counterweight is that training signal must still be extracted by measurement, and that is where the practical limits arrive.
Quantum Born Machines
A quantum Born machine prepares a state and reads its Born-rule distribution:
- Prepare a parameterised state
- Measure in the computational basis
- Collect shots and form
Training minimises the Kullback-Leibler divergence:
KL is asymmetric and unbounded above, which matters when puts near-zero mass on a data-supported bin: the term diverges and one unlucky shot dominates the gradient. The Jensen-Shannon divergence fixes that by mixing both distributions through a midpoint , which keeps the value bounded in and is finite even where one side has zero support.
Worked numbers make the difference concrete. Take two bins with data against a model that gets them backwards, . The KL contribution is nats. The JS midpoint is , so both cross-terms are identical and JS comes out at nats â a quarter of the KL value for the same modelling error, and still finite if the model assigns exactly zero mass somewhere the data has support, where KL would diverge.
Moment matching sidesteps divergence entirely: define a set of observables and minimise . Each term costs one measurement setting instead of a full distribution estimate, and the resulting objective is quadratic in the estimation error, so shot noise averages down predictably.
Quantum GANs
A quantum GAN pairs a quantum generator circuit with a discriminator that can be classical or quantum:
- Generator : maps latent noise to a quantum state whose measurement statistics look real
- Discriminator : outputs the probability that a sample came from the data rather than the generator
The adversarial objective is the usual minimax:
At the Nash equilibrium the generator matches the data distribution exactly and the discriminator is reduced to a coin flip. In practice the two never settle: the discriminator usually wins early, its gradient through a measured, discrete sample vanishes, and the generator stops receiving useful signal. The usual remedies are to under-train the discriminator for a few rounds, to feed it raw amplitudes rather than sampled bitstrings, or to replace the adversarial loss with a fixed divergence and drop the discriminator altogether.
Hybrid arrangements are now the norm. The generator is a parameterised circuit on qubits, the discriminator is a small classical network, and the only quantum-in-the-loop cost is producing samples â which means the classical baseline is a GAN whose input is a sample stream, and any claimed advantage has to survive that comparison.
Where Training Breaks
Four failure modes account for most abandoned runs:
| Failure | Symptom | Diagnostic | Fix |
|---|---|---|---|
| Barren plateau | gradients flat in every direction | variance of parameter-shift gradients across seeds | shallower circuit, local cost |
| Shot noise | loss oscillates without descending | repeat one parameter-shift eval, compare spread | raise shots or reduce observables |
| Mode collapse | generator covers a subset of modes | compare support size, not just divergence | diversity regulariser, unrolled training |
| Simulation gap | perfect on simulator, useless on device | re-evaluate with a noise model added | noise-aware training |
The barren plateau arithmetic is worth doing once, because it explains why every published demo sits at a handful of qubits. Gradient standard deviation falls as : at that is , at it is . A single Pauli expectation estimated from 1000 shots carries error â eight times the signal at 16 qubits and 130 times the signal at 24. Requiring the noise floor to sit below the signal gives shots, so roughly 66,000 shots per evaluation at 16 qubits and 17 million at 24, doubled again for the two evaluations each parameter-shift pair costs. The shot budget grows as while a variational circuit's expressibility grows only polynomially, and that crossover is where training stops being possible.
def plateau_budget(n_qubits, margin=3.0):
"""Shots needed for parameter-shift noise to fall under the signal."""
expected_grad = 2.0 ** (-n_qubits / 2) # std of dL/dtheta
shots = (margin / expected_grad) ** 2 # estimator noise ~ 1/sqrt(S)
return expected_grad, int(shots)
print(f"{'n':>3} {'expected grad':>15} {'shots/eval':>12} {'x1000-shot floor':>18}")
for n in (4, 8, 12, 16, 20, 24):
g, s = plateau_budget(n)
print(f"{n:>3} {g:>15.3e} {s:>12,} {0.032 / g:>18.1f}")
The last column is the awkward one: at 24 qubits the naive 1000-shot evaluation is 130 times noisier than the quantity being measured, so every reported gradient is pure estimator noise and the optimiser descends at random. Reported Born-machine demos therefore sit at 4 to 10 qubits, and architectures are picked for low effective parameter count rather than for raw expressibility.
Shot noise also biases divergence estimates in a known direction: plugging into KL systematically overestimates it, because is convex. The practical response is to estimate divergences with the same shot budget on both sides and to compare runs only within a fixed budget â never a 10,000-shot training run against a 10-million-shot evaluation.
Python: A Born Machine and Its Loss Landscape
A one-parameter Born machine trained against a target of , with both the analytic and the sampled loss printed so the shot-noise gap is visible:
import numpy as np
from scipy.optimize import minimize
def probs(theta):
"""Amplitudes of RY(theta) on |0>: p0 = cos^2(theta/2). Accepts arrays too."""
th = float(np.asarray(theta).reshape(-1)[0])
return np.array([np.cos(th / 2) ** 2, np.sin(th / 2) ** 2])
def kl(p, q):
p, q = np.asarray(p, float), np.asarray(q, float)
mask = p > 0
return float(np.sum(p[mask] * np.log(p[mask] / np.clip(q[mask], 1e-12, None))))
def js(p, q):
m = 0.5 * (p + q)
return 0.5 * kl(p, m) + 0.5 * kl(q, m)
def sample(theta, shots, rng):
p = probs(theta)
return rng.multinomial(shots, p / p.sum()) / shots
p_data = np.array([0.7, 0.3])
theta_star = 2 * np.arccos(np.sqrt(0.7))
# 1. How precisely p0 can be read off at each shot budget.
print(f"{'shots':>10} {'p0_hat':>9} {'abs err':>9} {'predicted se':>13}")
for shots in (100, 1_000, 100_000, 1_000_000):
rng = np.random.default_rng(shots)
p0_hat = sample(theta_star, shots, rng)[0]
se = np.sqrt(0.7 * 0.3 / shots)
print(f"{shots:>10,} {p0_hat:>9.5f} {abs(p0_hat - 0.7):>9.5f} {se:>13.5f}")
# 2. What that noise does to a fit: optimise the sampled JS divergence.
print()
for shots in (100, 1_000, 100_000):
rng = np.random.default_rng(shots + 1)
fit = minimize(lambda t: js(p_data, sample(t, shots, rng)),
[1.0], method="COBYLA")
print(f"shots={shots:>7} fitted theta={fit.x[0]:.4f} "
f"exact={theta_star:.4f} |err|={abs(fit.x[0] - theta_star):.4f}")
The analytic optimum is , where JS is zero. The estimator table shows the law directly: the error on falls from about at 100 shots to at 100,000 and at a million, tracking the predicted standard error in every row. The fit table shows the consequence for training â the recovered angle is only as good as the budget behind it, so the error shrinks alongside the estimator noise rather than being fixed by the optimiser.
Choosing a Loss and a Baseline
The decision is easier than the literature makes it look:
- Small support, few bits â use exact divergence on a statevector simulator, and report the classical exact-match baseline.
- Hardware samples, many bits â use moment matching or a bounded divergence on coarse-grained observables rather than raw bins.
- Need sample quality, not just fit â use precision and recall over the generated set, because a divergence can look good while whole modes are missing.
- Always â compare against an autoregressive model or a classical GAN with a comparable parameter budget on the same data; the quantum claim lives or dies on that table.
| Aspect | Born machine | Quantum GAN |
|---|---|---|
| Objective | KL, JS or moment matching | minimax adversarial |
| Stability | stable, monotone in practice | unstable, mode collapse common |
| Cost per step | one measurement setting | generator plus discriminator step |
| Failure mode | shot-noise floor | discriminator wins, gradient vanishes |
| Classical baseline | mixture model, normalising flow | classical GAN on the same samples |
Applications Worth the Qubits
Current evidence points at three use cases rather than five. Quantum chemistry: generating molecular configurations whose energy landscape the same circuit family can later be evaluated on, keeping the workload native to the device. Financial scenario sampling: producing correlated return paths where the model only has to be indistinguishable from historical data over a coarse summary â exactly the property moment matching enforces. Data augmentation for quantum tasks: producing training states for a downstream quantum classifier, where a classical model would have to represent amplitudes it cannot store.
The two that look plausible on paper but fail on current hardware are drug-like molecular generation and high-dimensional image synthesis. Both need distributions over far more than 20 bits, and both are compared against mature classical generators with billions of parameters. The realistic near-term target is a distribution whose structure is quantum â interference fringes, strong correlations, sign problems â rather than one a classical model could not imitate.
Common Mistakes
Reporting a bin-wise KL divergence computed from the same finite shot budget used for training
Fix: Evaluate at a much larger shot budget than training used, or switch to moment matching, because convexity of the log function biases plug-in KL estimates upward
Claiming an exponential representational advantage without naming the classical baseline
Fix: Quote an autoregressive model or classical GAN with a comparable parameter count on the same data; the advantage must survive that table, not just a plot
Scaling to more qubits because the simulator still runs
Fix: Check the gradient variance first: past roughly 16 qubits shot noise exceeds the parameter-shift signal unless shots grow exponentially with every added qubit
Treating discriminator accuracy as the measure of GAN training health
Fix: Track mode coverage and precision/recall on generated samples, since a discriminator stuck near chance can mean either convergence or a collapse to a single mode
Key Takeaways
- Quantum generative models sample rather than evaluate, so every loss is estimated from finite shots and the standard error sqrt(p(1-p)/S) sets the floor on what can be resolved
- KL divergence is unbounded and blows up on zero-support bins while Jensen-Shannon is capped at ln 2 and stays finite there, which is why JS and moment matching are the defaults for shot-limited training
- Barren plateaus make gradient variance fall as two to the minus n, so past about 16 qubits the parameter-shift signal drops below shot noise unless the shot budget doubles per qubit
- Quantum GANs collapse when the discriminator wins early, and the honest evaluation is mode coverage plus a matched-parameter classical generator, not discriminator accuracy alone