Bootstrap Your Flow

Laurence Illing Midgley, Vincent Stimper, Gregor N. C. Simm, José Miguel Hernández-Lobato

TL;DR

Training normalizing flows to approximate complex, unnormalized target distributions typically leads to mode collapse when using standard reverse KL divergence, or extreme gradient variance when using mass-covering objectives. Flow AIS Bootstrap (FAB) solves this by combining the mass-covering $\alpha$-divergence ($\alpha=2$) with Annealed Importance Sampling (AIS) in an iterative bootstrap loop: AIS draws samples closer to the target to provide low-variance gradient updates for the flow, while the improving flow continually offers a better starting proposal for AIS.

What Problem Does This Paper Address?

Computing expectations over intractable, unnormalized probability distributions (such as Boltzmann distributions in statistical physics or posterior distributions in Bayesian inference) is a central problem in machine learning and scientific computing.

Normalizing flows can act as flexible proposal distributions for importance sampling, but training them without pre-existing ground-truth samples is notoriously difficult:

  1. Mode Collapse: Minimizing the standard reverse Kullback-Leibler (KL) divergence, $\mathrm{D}_{\mathrm{KL}}(q \parallel p)$, is mode-seeking, causing flows to latch onto only a few modes and ignore the rest of the probability mass.
  2. High Loss Variance: Mass-covering objectives, like the $\alpha$-divergence with $\alpha=2$ (which minimizes the variance of importance weights), require evaluating expectations over the target $p(x)$. Estimating this expectation using samples drawn purely from an untrained flow $q(x)$ leads to extreme gradient variance whenever the flow places low density in regions where the target has high density.
  3. Reliance on Target Samples: While maximum likelihood training can cover modes, generating the necessary target samples via Molecular Dynamics or Markov Chain Monte Carlo (MCMC) is prohibitively expensive.

Methods

FAB introduces a synergistic bootstrapping procedure that trains a flow without requiring ground-truth samples:

  • Mass-Covering $\alpha$-Divergence: FAB optimizes $\mathrm{D}_{\alpha=2}(p \parallel q) \propto \mathbb{E}_{p(x)}[p(x) / q(x)]$. This penalizes $q$ heavily wherever $p$ has mass but $q$ is small, forcing the flow to cover all modes.
  • AIS for Gradient Estimation: Because target samples from $p(x)$ are unavailable, the expectation is estimated via Annealed Importance Sampling (AIS). The flow $q(x)$ serves as the initial proposal ($p_0$). Samples are transitioned through intermediate bridge distributions toward the target $p(x)$ using Hamiltonian Monte Carlo (HMC).
  • The Bootstrap Mechanism: The flow provides an initial proposal distribution for AIS, making AIS mixing faster. In turn, AIS produces better-targeted samples and importance weights, providing a stable, low-variance gradient estimator to update the flow.
  • Gradient Blocking and Stable Loss: To calculate valid gradients with automatic differentiation, gradients through the AIS sampling path and AIS importance weights are blocked (detached). To ensure numerical stability, the objective is evaluated in log-space using a Jensen's inequality upper bound with the LogSumExp trick: $$\mathcal{L}(\theta) = \log \sum_{l=1}^L \exp\left(\log \bar{w}_{\text{AIS}}^{(l)} + \log p(\bar{x}_{\text{AIS}}^{(l)}) - \log q_\theta(\bar{x}_{\text{AIS}}^{(l)})\right)$$

Datasets

The authors evaluate FAB on two synthetic yet challenging multimodal benchmarks:

  1. 2D Gaussian Mixture Model: A multimodal toy distribution evaluated alongside an expectation of a randomly initialized quadratic function to benchmark bias and variance.
  2. 16-Dimensional "Many Well" Problem: Formed by repeating a 2D Double-Well Boltzmann distribution 8 times, resulting in $2^8 = 256$ distinct, isolated modes. The authors construct a hand-crafted test set containing a point placed at each of the 256 mode centers to benchmark likelihood and coverage.

Key Insights and Ideas

  • Symbiosis over Competition: Instead of viewing MCMC/AIS and flows as alternative samplers, FAB recognizes that they address each other's primary weaknesses. Flows fix the slow mixing of MCMC across distant modes; MCMC/AIS fixes the poor local gradient signals of untrained flows.
  • Minimal AIS Overhead is Sufficient: In experiments, FAB used only 2 intermediate AIS distributions with 1 outer and 5 inner HMC steps. Even minimal annealing was sufficient to bridge modes and dramatically stabilize flow training.
  • Post-Training Boost: Once trained, the flow can be used on its own or paired with AIS at inference time to achieve even higher Effective Sample Sizes (ESS).

Key Results

  • 2D Mixture of Gaussians:
  • FAB captured all modes, whereas a standard flow and a Stochastic Normalizing Flow (SNF) trained with reverse KL collapsed onto a subset.
  • FAB achieved an Effective Sample Size (ESS) of 70.1% (77.5% after AIS), compared to 0.05% for the standard flow and 0.02% for the SNF.
  • In estimating the toy quadratic expectation, FAB exhibited only 1.2% bias (0.5% with AIS), while KL-trained baselines had biases around 100%.
  • 16D Many-Well Problem:
  • FAB achieved a test-set mean log-likelihood of -14.5 versus -86.2 for the KL-trained baseline.
  • FAB obtained an ESS of 79.6% (85.2% after AIS), compared to virtually zero (0.01%) for the KL-trained flow, reliably discovering all 256 modes across all marginal dimensions.

Limitations and Future Work

  • Computational Overhead: Running AIS (even with short chains) inside every training step increases wall-clock time relative to pure flow training, though it avoids the massive cost of long offline MCMC/MD sampling runs.
  • Component Ablation: The impact of varying the number of intermediate AIS temperatures, transition kernel parameters, and loss surrogates remains to be systematically ablated.
  • Real-World Scaling: Experiments were restricted to synthetic physics toy benchmarks. Scaling FAB to high-dimensional macromolecular Boltzmann distributions (e.g., complex protein folding) and Bayesian neural network posterior inference remains future work.

Summary updated

BibTeX
@inproceedings{midgley2022bootstrap,
  author = {Laurence Illing Midgley and Vincent Stimper and Gregor N. C. Simm and José Miguel Hernández-Lobato},
  title = {{Bootstrap Your Flow}},
  booktitle = {AABI},
  year = {2022},
  url = {https://openreview.net/forum?id=Rzwf6LeM-6E},
}
Figure