TL;DR
Chemists want samples from the equilibrium state of a molecule, the configurations it is likely to be found in at a given temperature. Getting them by simulation is slow, because the molecule gets stuck in one shape for a long time before it jumps to another. This paper trains a neural network that maps simple random numbers to molecular configurations, with the probabilities of those configurations known exactly. The method, called a Boltzmann Generator, produces independent samples in one shot, then reweights them so that averages match the true equilibrium distribution.
Builds on: Boltzmann Distribution, Normalizing Flow, Kullback–Leibler Divergence, Importance Sampling · Leads to: Molecular Dynamics alternatives for sampling and free energy calculations; Generative Model methods that are unbiased by construction
Why it mattered
Free energy differences decide which of two molecular states is favored, which drug binds a protein, and how a reaction proceeds. Computing them needs many samples from both states. Standard molecular dynamics and Markov chain Monte Carlo can take an enormous number of steps to cross between two metastable states, and the paper estimates that folding or unfolding a protein can need around to simulation steps. A method that produces independent samples in one shot, and can compute free energies without a predefined reaction coordinate, targets exactly that bottleneck. The paper reports samples for a protein with 892 atoms, which was a large system for this kind of method.
History
The Boltzmann distribution, which gives each configuration a weight that falls off with its energy, has been the basis of statistical mechanics since the late nineteenth century. Simulation methods for sampling it, such as Metropolis Monte Carlo and molecular dynamics, developed over the decades that followed. Enhanced sampling methods, which bias a chosen reaction coordinate, became the standard fix for rare events. Normalizing flows, neural networks built from invertible maps whose densities can be computed, came out of machine learning in the mid-2010s. This paper joined the two lines: the invertible networks of machine learning, trained against a physical energy function instead of a dataset.
The problem
A molecule's equilibrium behavior is set by its energy function , where holds all the atomic positions. At a given temperature the probability of a configuration is proportional to . Two configurations of very different energy can be separated by a barrier that only a rare thermal fluctuation crosses. Simulation spends almost all its time inside one basin.
Dense systems make it worse. In a crowded liquid of repelling particles, the low-energy arrangements are a vanishingly small fraction of all arrangements. Designing a sampler by hand, one that places all the particles without clashes and with low energy, looks unfeasible. The paper's aim is a machine that learns the sampler from the energy function, without knowing in advance which coordinates matter.
How it works
The idea is traced on a one-dimensional toy, with a single invertible map and a standard normal prior. The prior is a random number from a Gaussian. The network is the map , which is invertible with derivative 2. The energy is .
- Draw a latent sample. Draw from the Gaussian prior. This is the "simple" distribution the sampler starts from.
- Map it to configuration space. . The configuration is .
- Compute its energy. . High energy means the configuration is unlikely under the target.
- Account for stretching. The map stretches space by a factor . The density of the generated samples picks up the same factor, and the log term records it.
- Score the sample with the loss. The contribution of this sample to the training loss is . Training lowers the average of this quantity over many samples.
- Reweight to the Boltzmann distribution. The density of the generated sample is , where is the Gaussian density. Here , so . The weight is .
- Average with weights. Any average is taken as , which corrects for the fact that the network did not sample the target exactly.
The diagram shows the flow of one training step.
flowchart LR Z[Latent sample z from Gaussian] --> F[Invertible network F_zx] F --> X[Configuration x] X --> E[Energy u of x] X --> J[Log stretch factor] E --> L[Loss: energy minus log stretch] J --> L L --> U[Update network parameters] X --> W[Weight e to minus u over p_X]
Training uses two signals. Training by energy is the loss in step 5, which needs no samples, only the energy function. Training by example uses a few configurations from short simulations or from an experimental structure: these are mapped back to the Gaussian space and their likelihood is maximized. The energy term alone tends to focus on the most stable state, so the example term is used early on to get the network into the right region of configuration space.
Worked examples
Use the same toy: , , . Take two latent samples, and .
- For : . Energy .
- Loss contribution: .
- For : , , loss contribution (from How it works).
- The loss contribution is lower for the first sample, which is the one with lower energy. This is the sense in which the loss pushes the network toward low-energy configurations.
Interpretation: a sample with a negative loss contribution pulls the average down. Training favors maps that send probable latent points to low-energy configurations.
Continue with the two samples above. For , the density is , and the weight is . For , as before.
- The unweighted mean of over the two samples is .
- The weighted sum is .
- The total weight is .
- The weighted mean is .
Interpretation: the generator undersampled the low-energy point , and reweighting moves the estimate from 0.5 to about , toward the configuration the Boltzmann distribution prefers.
The paper states that the loss is estimated from a batch of around 1000 samples, that a few hundred to a few thousand iterations train the network for its examples, and that this costs a few million energy evaluations. Each energy evaluation is a full molecular energy, which is the expensive part. Taking the paper's own figures:
- A batch of 1000 samples costs 1000 energy evaluations per iteration.
- Across 300 iterations, that is evaluations, about 0.3 million.
- Across 3000 iterations, that is , about 3 million.
- So the paper's "few million" describes the range of the budget. The paper gives between one minute and a few hours of computation for the present systems.
- Once trained, the network draws new samples at the cost of one forward pass each, with no further energy calls needed to get them, except for the reweighting.
Interpretation: the expensive work is front-loaded into training. The payoff is that the cost of each additional independent sample is small, while a molecular dynamics run would need very many steps for each one.
Try it: a run uses batches of 1000 samples and 2500 iterations. How many energy evaluations does training take? Answer: , about 2.5 million, which sits inside the paper's stated range.
The math
The target is the Boltzmann density , where is the partition function. The generator is an invertible map applied to a Gaussian prior . Its inverse is .
A Boltzmann Generator is an invertible neural network together with a Gaussian prior, such that the density of the generated configurations is known at every sample point. Its training losses approximate the difference between and , and its samples are reweighted to for any average.
Step 1 in symbols: the density of a generated sample
Let be the absolute determinant of the Jacobian, the factor by which the map stretches volume. The change of variables formula gives
so the density of the generated sample is known exactly, as long as is cheap to compute. The invertible layers are designed so that it is.
Step 2 in symbols: the energy loss
The Kullback-Leibler divergence from the generated distribution to the Boltzmann distribution is
Substituting Step 1 and , and dropping terms that do not depend on the network (the constant and ), gives the energy loss
This is the loss from How it works, step 5. The first term is the mean energy of the generated configurations. The second term is an entropy-like term that keeps the generator from collapsing onto one minimum-energy configuration. The paper notes that the value of also equals a free energy difference, up to a constant, which is why a difference of two such values gives a free energy difference between two states.
Step 3 in symbols: the example loss
For a configuration taken from a simulation, the network maps it back to latent space with . Maximizing the likelihood under the Gaussian gives
The first term is the energy of a harmonic oscillator, the Gaussian's negative log-density. The second term is the log-determinant of the inverse map. This is standard maximum likelihood, the same principle used for any density model.
Step 4 in symbols: reweighting
Each sample from the generator gets weight , and an average of an observable under the Boltzmann distribution is estimated by
This is importance sampling, with the generator's density as the proposal. Its accuracy depends on how close is to , which is what the training losses push toward.
Results
The main findings, with the paper's own numbers.
- Model systems. On two-dimensional double-well and Mueller potentials, a Boltzmann Generator trained from two short, disconnected simulations produces samples from both states and across the barrier. Its free energy differences match the reference values. For the double well, the paper estimates that direct simulation needs about steps per return trip and about 100 crossings, while training costs about steps. It calls the generator about a factor of 100 more efficient for this simple system.
- Dense solvated dimer. With 38 particles in a two-dimensional crowded box, the generator learns a latent space in which the configurations form a concentrated 76-dimensional ball. Free energy profiles agree with umbrella sampling across temperatures. The paper estimates that direct simulation would need at least steps to sample one transition from closed to open and back, and that training uses about energy evaluations, giving a speedup of at least seven orders of magnitude over MD.
- Exploration. Starting from a single configuration, an exploration method that runs Metropolis steps in latent space finds new metastable states within a few energy calls.
- Protein. For the bovine pancreatic trypsin inhibitor, in an implicit solvent, a generator with 8 invertible blocks produces one-shot samples of all 892 atoms. Its energy distribution overlaps the simulation data, and it samples a near-crystal structure and an open structure, the latter a transition that was seen only once in a millisecond simulation. The reported mean backbone deviation of the near-crystal samples from the crystal structure is 1.4 Å.
- Disconnected states. Two independently trained generators, each seeded with disconnected simulations, give free energy differences. For the dimer, the paper reports 50 times fewer energy calls than umbrella sampling at five temperatures.
What the results do not show: a generator is trained on one specific system, not on many, so each new molecule needs its own training. The paper's Discussion says the method may not be ergodic, meaning it can miss some configurations, and it recommends combining it with MD or MCMC moves. The statistical efficiency of the samples falls as dimension grows, and the authors describe divide-and-conquer approaches for systems with hundreds of thousands of coordinates as future work.
Common mistakes and tradeoffs
It is tempting to think a Boltzmann Generator is just an image generator for molecules. In fact it is trained against the energy function and its samples are reweighted, because its density is known. An image generator learns from examples and has no exact density to reweight with.
It is tempting to think the raw samples are already unbiased. In fact they come from the generator's density, not the Boltzmann distribution, so averages need the weights from Step 4. Skipping reweighting gives biased free energies.
It is tempting to think training by energy alone is enough. In fact the paper found it focuses on the most stable state, so training by example is used as well, especially early on.
It is tempting to think the method needs no physical knowledge. In fact the representation matters: the paper whitens the backbone atoms with principal component analysis and describes side-chain atoms in internal coordinates, and it removes permutations of identical solvent molecules. Without these, the learning problem is much harder.
When to use it: when you need independent equilibrium samples or free energies, the energy function is known, and the system is too large or too rare-event-prone for direct simulation to be practical. When not to use it: when a clear reaction coordinate already makes umbrella sampling cheap, when the system is huge and the sample efficiency falls, or when you need ergodic exploration without any extra moves. Alternatives include umbrella sampling, metadynamics and replica exchange, which the paper suggests can also be reformulated in the generator's latent space.
Reading guide
The paper's sections in order, with the lessons each one needs.
- Introduction. Needs Boltzmann Distribution, Partition Function and Molecular Dynamics. The introduction contrasts one-shot sampling with simulation steps.
- The method. Needs Normalizing Flow, Change of Variables Formula and Jacobian Matrix. Figure 1 shows the stacked invertible blocks and the Gaussian prior.
- Losses. Needs Kullback–Leibler Divergence, Maximum Likelihood Estimation and Gaussian (Normal) Distribution. Equations 1 and 2 are the energy loss and the example loss.
- Reweighting. Needs Importance Sampling. The weights are the importance weights.
- Results on model systems. Needs Markov Chain Monte Carlo to read the latent-space Metropolis exploration.
- Complex molecules. Needs Entropy for the role of the log-determinant term, and Generative Model for the general setting.
Recap
- The Boltzmann distribution gives probabilities of configurations, but drawing independent samples from it is hard for rare-event systems.
- A Boltzmann Generator is an invertible network with a Gaussian prior. Its generated density is known exactly by the change of variables formula.
- Its energy loss, the KL divergence to the Boltzmann distribution, needs only the energy function. Its example loss, a maximum likelihood term, uses a few configurations from simulation.
- Samples are reweighted by the ratio of Boltzmann weight to generated density, which gives unbiased averages and free energy differences.
- The paper applies this to model potentials, a crowded dimer and a protein with 892 atoms. Its main limits are per-system training and reduced efficiency in high dimension.
Read next: Molecular Dynamics for the baseline the paper improves on, and Normalizing Flow for the architecture family.
Check yourself
QuestionRecall: what is the role of the reweighting step in a Boltzmann Generator?Show answer
Samples come from the generator's density, not the Boltzmann distribution. Each sample is weighted by the Boltzmann weight divided by the generated density, so that averages and free energy differences estimate the true equilibrium values.
QuestionComputation: for the toy and , with , what is the loss contribution of the latent sample ?Show answer
Then , , and the loss contribution is .
QuestionWhy: why does the energy loss include the log-determinant term, and what would happen without it?Show answer
The log-determinant term rewards the generator for spreading samples across configuration space rather than concentrating them. Without it, the loss is only the mean energy, which is minimized by collapsing onto one minimum-energy configuration, the mode collapse the paper describes.
QuestionApplied: a group has a single protein whose two states are separated by a rare transition, and they can afford about one million energy evaluations. Which parts of the paper's approach apply, and what should they check before trusting the free energies?Show answer
Training by energy and reweighting apply, with the energy function as the only input the energy loss needs. They should check that the generator covers both states, which the paper addresses with training by example from each state, and that the reweighted estimates converge, for example by watching the loss and the effective sample size across training.
Sources
- Noé, F., Olsson, S., Köhler, J., and Wu, H. Boltzmann Generators: Sampling Equilibrium States of Many-Body Systems with Deep Learning. arXiv:1812.01729. https://arxiv.org/abs/1812.01729
- Noé, F., et al. Science (2019). https://doi.org/10.1126/science.aaw1147
- Boltzmann distribution. Wikipedia. https://en.wikipedia.org/wiki/Boltzmann_distribution