Understanding Quantum Boltzmann Machines

A pedagogical walk through quantum Boltzmann machines: why a handful of non-commuting qubits can represent probability distributions that a much larger classical Boltzmann machine cannot, and what that buys you when the target is a particle jet.

November 25, 2024

Generative models are everywhere in machine learning, but physicists had a working generative model more than a century before anyone talked about GANs or diffusion: the Boltzmann distribution. Give me an energy function and a temperature, and I can hand you a recipe for sampling configurations of a physical system. In this post I want to walk through [1], Learning to generate high-dimensional distributions with low-dimensional quantum Boltzmann machines, which asks a very physics-flavoured question about quantum machine learning: if you upgrade a classical Boltzmann machine to a quantum Boltzmann machine (QBM), does a small quantum model get access to correlations that its wiring diagram alone shouldn't allow?

The answer is yes, and the mechanism — non-commuting operators smuggling correlations across qubits that were never directly coupled — is worth understanding slowly, the way you'd explain it to a student seeing it for the first time.

From spins to samples: what is a Boltzmann machine?

Start classical. A Boltzmann machine (BM) describes a bit string s=s0s1⋯sn−1s = s_0 s_1 \cdots s_{n-1}, si∈{−1,+1}s_i \in \{-1,+1\}, through an energy function E(s)E(s) and the associated Gibbs distribution

p(s)=e−βE(s)Z,Z=∑se−βE(s).p(s) = \frac{e^{-\beta E(s)}}{Z}, \qquad Z = \sum_s e^{-\beta E(s)}.

If you've read my earlier post on the Ising model, this should look familiar — it's exactly an Ising-type Hamiltonian [2], generalised to have a free weight on every site and every allowed interaction:

E(s)=∑iwi(1)si+∑i<jwi,j(2) sisj+⋯E(s) = \sum_{i} w^{(1)}_i s_i + \sum_{i<j} w^{(2)}_{i,j}\, s_i s_j + \cdots
E=-2E=-1E=0E=1E=2weight
Five configurations ss at fixed β=1\beta=1: the Boltzmann weight falls off exponentially as the energy rises, so low-energy configurations dominate the samples you draw.

Every bit is a visible unit here — you observe it directly, as opposed to hidden units that only exist to help the model represent correlations it otherwise couldn't. A fully-visible BM is the simplest possible generative model: no hidden units, just an energy function over the data itself. The catch is expressivity. If your energy function only contains nearest-neighbour terms sisi+1s_i s_{i+1}, the model can only ever represent correlations that respect that same nearest-neighbour graph. Reach for anything more structured — three-body correlations, correlations between distant sites — and a fully-visible classical BM simply cannot get there without adding hidden units, which is exactly why restricted Boltzmann machines (RBMs) became the practical default, at the cost of an intractable partition function for anything but small systems.

Making it quantum

A quantum Boltzmann machine keeps the same skeleton — a parametrised Hamiltonian, a Gibbs state, a temperature — but the energy function becomes a genuine quantum operator built from Pauli strings:

ρθ=e−βHθTr ⁣(e−βHθ),Hθ=∑iθiHi,\rho_\theta = \frac{e^{-\beta H_\theta}}{\mathrm{Tr}\!\left(e^{-\beta H_\theta}\right)}, \qquad H_\theta = \sum_i \theta_i H_i,

where each HiH_i is a one- or two-body Pauli string (ZiZ_i, ZiZjZ_iZ_j, but also XiX_i, XiYjX_iY_j, and so on) and ρθ\rho_\theta is now a density matrix rather than a diagonal probability vector. If you restrict HθH_\theta to only ZZ and ZZZZ terms, ρθ\rho_\theta stays diagonal in the computational basis and you recover an ordinary classical BM exactly. The entire generalisation — and everything interesting that follows — comes from allowing terms that don't commute with each other.

That single change matters more than it sounds like it should. A classical spin is a switch: it points up or down, and correlating two switches requires an explicit wire between them. A qubit is not a switch — it lives in a superposition, and two qubits coupled through non-commuting operators can end up correlated even along a path where there is no direct term in the Hamiltonian at all:

q₀q₁q₂correlated anyway, even with no direct couplingHamiltonian term
HθH_\theta only couples neighbouring qubits (q0 ⁣− ⁣q1q_0 \!-\! q_1 and q1 ⁣− ⁣q2q_1 \!-\! q_2), but because the terms don't commute, tracing out q1q_1 still leaves q0q_0 and q2q_2 correlated. A classical nearest-neighbour chain cannot do this.

This is the entire thesis of the paper, stated as a picture in its own Figure 1:

Fully-visible BM and QBM compared to a restricted Boltzmann machine
Figure 1 of [1]. A nearest-neighbour fully-visible BM can only represent nearest-neighbour statistics. A nearest-neighbour fully-visible QBM, with the same connectivity, can represent distributions that would classically require an all-to-all connected model — or an RBM with extra hidden units.

The authors define the dimension of a distribution as the dimension of the lattice needed to generate it classically: a chain is one-dimensional, a grid is two-dimensional, all-to-all connectivity is (n−1)(n-1)-dimensional. Their central claim is that a low-dimensional QBM — one whose Hamiltonian only has nearest-neighbour terms — can learn distributions of higher dimension than its own connectivity graph. Classically that would require either more edges or hidden units; quantum mechanically, entanglement does the work for free.

You can make this precise with conditional mutual information. For subsystems AA, BB, CC of a state ρ\rho,

I(A ⁣: ⁣C ∣ B)=S(AB)+S(BC)−S(ABC)−S(B),\mathcal{I}(A\!:\!C\,|\,B) = S(AB) + S(BC) - S(ABC) - S(B),

where S(⋅)S(\cdot) is the von Neumann entropy. For a classical nearest-neighbour chain this vanishes exactly whenever BB separates AA from CC — that's just the Markov property of a 1D classical chain. The paper shows numerically that a nearest-neighbour-connected QBM has non-zero I(0 ⁣: ⁣2 ∣ 1)\mathcal{I}(0\!:\!2\,|\,1) even though qubits 0 and 2 share no term in HθH_\theta: correlation is leaking through the middle qubit via entanglement, not via an explicit coupling.

Training: same recipe, different bookkeeping

Training a QBM looks almost identical to training a classical BM. You minimise the quantum relative entropy between a target state η\eta (your data, embedded as a density matrix) and the model state ρθ\rho_\theta:

S(η∥ρθ)=Tr(ηlog⁡η)−Tr(ηlog⁡ρθ).S(\eta \Vert \rho_\theta) = \mathrm{Tr}(\eta \log \eta) - \mathrm{Tr}(\eta \log \rho_\theta).

For a classical BM this reduces exactly to the ordinary KL divergence between p(s)p(s) and qθ(s)q_\theta(s). The gradient with respect to each Hamiltonian weight has the same contrastive-divergence flavour you'd expect from a classical BM:

∂θiS(η∥ρθ)=Tr(ηHi)−Tr(ρθHi),\partial_{\theta_i} S(\eta \Vert \rho_\theta) = \mathrm{Tr}(\eta H_i) - \mathrm{Tr}(\rho_\theta H_i),

the difference between the expectation value of HiH_i on the data and on the model. Nothing about this formula requires HiH_i to commute with anything else — it is the one line of the classical training rule that silently generalises to the full quantum case. The practical headache is that preparing ρθ\rho_\theta exactly requires diagonalising a non-diagonal Gibbs state, which gets expensive fast; the paper works around this with thermal pure quantum (TPQ) states, a statistical trick for estimating Tr(ρθHi)\mathrm{Tr}(\rho_\theta H_i) from a handful of pseudo-random pure states rather than the full density matrix. It's a computational detail rather than a conceptual one, so I won't dwell on it — the important part is that the loss and its gradient are exactly the classical BM recipe, evaluated on a genuinely quantum object.

Does the extra machinery pay off?

The first test is entirely synthetic: four qubits, all-to-all connectivity, both a BM and a QBM equipped with a generic Hamiltonian (all one- and two-body Pauli strings), trained on 1000 randomly generated three-body Boltzmann distributions.

Scatter plot of KL divergence for QBM versus BM
Figure 2 of [1]. Each point is one target distribution; nearly all of them sit below the diagonal, meaning the QBM reaches a lower KL divergence than the BM trained on the identical connectivity.

The comparison is deliberately fair: both models have up to two-body interactions and the same connectivity graph. The gap in performance isn't coming from extra parameters, it's coming from the fact that the target distributions contain genuine three-body correlations, which a two-body classical energy function cannot represent no matter how you tune the weights — while the QBM's non-commuting two-body Pauli terms can fake a three-body effect through entanglement.

A real target: particle jets

Synthetic Boltzmann distributions are a clean testbed, but the paper's more interesting experiment uses real collider data. A jet is a collimated spray of particles produced when a quark or gluon fragments and hadronizes; the momentum shared between the leading particles inside a jet is highly correlated by construction — it has to add up to the jet's total momentum, and QCD radiation patterns leave characteristic correlations behind. Using the JetNet dataset, the authors build a joint probability distribution over the (binned) relative transverse momentum ∣pTrel∣|p_T^{\rm rel}| of the four hardest particles in a jet:

Corner plot of the joint probability distribution of four jet particles
Figure 4 of [1]. Marginal distributions (top row) and pairwise joint distributions for the four hardest particles in a jet. The strong off-diagonal structure is exactly the kind of high-order correlation a low-connectivity classical model struggles with.

Discretising four particles into 16 bins each needs 16 qubits — small enough to simulate, large enough to be a genuine stress test. Training both BMs and QBMs (with all-to-all connectivity) across system sizes from 4 to 16 qubits, for both m=2m=2 and m=4m=4 particle datasets, gives the headline result:

KL divergence versus number of qubits for BM and QBM on jet data
Figure 6 of [1]. QBM (solid) consistently reaches a lower KL divergence than BM (dashed) trained under exact diagonalisation, for both two- and four-particle jet targets, across every system size tested.

Perhaps the most striking follow-up result — not reproduced here, but worth stating — is that a QBM restricted to nearest-neighbour-particle connectivity (units within a particle fully connected, particles chained to their neighbours by ∣pTrel∣|p_T^{\rm rel}| ordering) can match an all-to-all connected classical BM. The quantum model with a sparser wiring diagram ties the classical model with a denser one. That's the practical payoff of the entanglement argument from the previous section: you don't need to pay for all-to-all connectivity if non-commuting terms can smuggle the correlation through for you.

Where this leaves us

None of this is a free lunch. QBM training is expensive precisely because Gibbs states of non-commuting Hamiltonians can't be classically simulated the easy way a diagonal BM can — the TPQ/Lanczos machinery exists to work around that cost, and it introduces its own finite-size systematic error. The system sizes tested here top out at 16 qubits on a classical simulator; a genuine quantum-hardware advantage would need fault-tolerant devices with far more logical qubits than exist today. What the paper does establish convincingly is the mechanism: non-commuting Hamiltonian terms are not a nuisance to be minimised, they are the entire source of a fully-visible QBM's extra representational power over its classical counterpart, and that power shows up on a genuine, correlated, high-energy-physics dataset and not just on constructed toy examples.

I like this line of work for the same reason I liked writing about a physics-informed quantum circuit for QCD splittings: the interesting question in near-term quantum machine learning for particle physics is rarely "can a big enough quantum circuit fit this data" — it's "does the quantum structure buy you something a classical model of the same size provably cannot have." Here the answer is entanglement standing in for connectivity, and it holds up on real jet data.

References

[1]
C. Tüysüz, M. Demidik, L. Coopmans, E. Rinaldi, V. Croft, Y. Haddad, M. Rosenkranz, K. Jansen, Learning to generate high-dimensional distributions with low-dimensional quantum Boltzmann machines, (2024). DOI:10.48550/arXiv.2410.16363
[2]
E. Ising, Contribution to the Theory of Ferromagnetism, Z. Phys. 31 (1925) 253–258. DOI:10.1007/BF02980577