Bayesian inference via sparse Hamiltonian flows

Naitong Chen, Zuheng Xu, Trevor Campbell

TL;DR

This paper introduces Sparse Hamiltonian Flows (SHF), a method that drastically speeds up Bayesian inference on large datasets by combining the efficiency of "coresets" (small, weighted data subsets) with the expressive power of Hamiltonian-based normalizing flows. By using a tiny fraction of the data to drive the dynamics and introducing a novel "quasi-refreshment" step to tune the model, SHF achieves high-fidelity posterior approximations with an order-of-magnitude reduction in runtime.

The "Big Data" Problem in Bayesian Inference

Bayesian inference is the gold standard for uncertainty quantification, but it struggles with massive datasets. Traditional methods like Markov Chain Monte Carlo (MCMC) or Variational Inference (VI) usually require a full pass over all $N$ data points at every single step. When $N$ is in the millions, this becomes prohibitively slow.

Researchers have historically tried two main workarounds, both with flaws:

  1. Stochastic Subsampling: Picking a different random subset of data at each step. This is fast but often leads to poor approximations or slow convergence.
  2. Bayesian Coresets: Finding a fixed, small, weighted subset of data that mimics the full dataset. While coresets exist, they are hard to build, and you still need a separate (often slow) inference algorithm to actually use them once they are constructed.

The authors aim to bridge this gap by developing a method that builds a coreset and performs inference simultaneously, providing a fast, "trainable" distribution that approximates the true posterior.

Introducing Sparse Hamiltonian Flows (SHF)

The authors propose Sparse Hamiltonian Flows (SHF), which consists of three main components:

  1. Selection via Uniform Subsampling: Instead of complex greedy algorithms to find the "best" data points, the authors show that simply picking a small number of points ($M$) uniformly at random is often sufficient, provided their weights are optimized later.
  2. Sparse Hamiltonian Dynamics: These $M$ points are used to define a "potential energy" function for Hamiltonian dynamics. Because $M \ll N$, calculating the gradients (the "forces" moving the particles) is exponentially faster. This defines a normalizing flow—a sequence of reversible transformations that turn a simple distribution (like a Gaussian) into the complex posterior.
  3. Quasi-refreshment Steps: Standard Hamiltonian flows often lack the flexibility to match a target distribution perfectly. Usually, MCMC "refreshes" momentum stochastically, but that breaks the ability to calculate the probability density. SHF introduces deterministic quasi-refreshment: learnable shift-and-scale transformations of the momentum. This allows the flow to "steer" toward the target more effectively while remaining a valid, density-trackable normalizing flow.
ELBO improvement during Hamiltonian dynamics and quasi-refreshment steps

Key Insights and Innovations

  • The Power of Logarithms: The authors prove that for certain representative models, you only need $O(d \log N)$ data points to recover the exact posterior. This justifies the "sparse" approach: you can compress a massive dataset into a tiny one without losing much information.
  • Tempering Isn't Enough: Previous work used "momentum tempering" (just scaling the momentum). This paper proves that tempering alone can't shift the mean of the distribution effectively. The "quasi-refreshment" (which adds a shift) is the crucial innovation that provides the necessary flexibility.
  • Optimization over Simulation: By treating the Hamiltonian dynamics as a trainable flow, the authors can use standard stochastic gradient descent (Adam) to minimize the KL divergence, making the method much more "plug-and-play" than traditional MCMC.

Experimental Results

The researchers evaluated SHF on synthetic benchmarks and real-world datasets, including a large Airline dataset ($N = 100,000$ flights) for Bayesian linear and logistic regression.

  • Speed: SHF achieved density evaluation and sample generation speeds more than an order of magnitude faster than full-data methods.
Density evaluation time comparison across methods
  • Accuracy: In the Airline dataset experiments, SHF provided higher-quality posterior approximations (measured by Evidence Lower Bound or ELBO) compared to other state-of-the-art Hamiltonian VI methods like HIS and UHA, especially when those methods were restricted to the same small data budgets.
  • Compression: The method successfully recovered accurate posteriors using only 100 data points from a set of 100,000—a 1000x compression ratio.

Limitations and Future Work

While highly effective, SHF does have limitations. The method relies on the assumption that the log-likelihood functions of the data are "compressible." If the data does not live on a lower-dimensional manifold, a small coreset might not be able to represent the full dataset adequately.

Additionally, the current quasi-refreshment assumes a Gaussian-like structure for the momentum. Developing more general-purpose, non-Gaussian refreshment moves is a promising path for future research. Finally, like many flow-based methods, SHF requires tuning hyperparameters such as the number of leapfrog steps and refreshment layers, which can impact overall performance.

Summary updated

BibTeX
@inproceedings{chen2022bayesian,
  author = {Naitong Chen and Zuheng Xu and Trevor Campbell},
  title = {{Bayesian inference via sparse Hamiltonian flows}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=B4OTsjq63T5},
}
Figure