Structured Stochastic Gradient MCMC

Antonios Alexos, Alex James Boyd, Stephan Mandt

Presented at ICML 2022, this paper introduces a clever way to speed up Bayesian inference for deep learning. By borrowing a "divide and conquer" strategy from Variational Inference (VI) and applying it to Stochastic Gradient Markov Chain Monte Carlo (SGMCMC), the authors propose Structured Stochastic Gradient MCMC (S-SGMCMC). This hybrid algorithm combines the non-parametric flexibility of MCMC with the rapid mixing of structured VI. By systematically breaking specific posterior correlations using a "self-averaged" energy function, it achieves faster convergence and better uncertainty estimates in high-dimensional models like Bayesian Neural Networks (BNNs).

The Problem: Speed vs. Flexibility

BNNs are the gold standard for reliable uncertainty estimation, but they are notoriously difficult to train. Practitioners usually choose between two extremes:

  1. Stochastic Gradient MCMC (SGMCMC): Theoretically exact and non-parametric, but painfully slow to "mix" (explore the parameter space) in high dimensions because all parameters are coupled.
  2. Variational Inference (VI): Fast and scalable, but relies on rigid parametric assumptions (like assuming the posterior is a simple Gaussian). This often leads to "over-confident" models that underestimate variance and fail to capture complex, multi-modal distributions.

The authors aim to bridge this gap, seeking the speed of VI’s coordinate-ascent style updates without losing the "shape-shifting" ability of MCMC to represent any distribution.

Methodology: Self-Averaged Energy Functions

The core innovation is the "self-averaged" posterior energy function. In standard SGMCMC, a particle simulates movement through a high-dimensional landscape defined by an energy function. In S-SGMCMC, the parameters are partitioned into $M$ groups. When updating one group, the algorithm "averages out" the other groups using samples collected from earlier iterations of the Markov chain.

  • Structured Sampling: Inspired by structured VI, this approach breaks dependencies between groups in a controlled way, allowing the chain to move much faster through the landscape.
  • Structured Dropout SGMCMC ($S_d$-SGMCMC): To scale to massive models where updating $M$ groups individually is too expensive, the authors introduce a "dropout" mechanism. Stochastic masks approximate the energy function, allowing the user to interpolate between a fully joint posterior (standard MCMC) and a fully factorized one (mean-field VI).
  • Non-parametric Nature: Unlike standard VI, this method doesn't assume a functional form. The "variational distribution" is simply the empirical distribution of the samples in the chain.

Key Insights and Ideas

  • Capturing Multi-modality: A standout "aha moment" is demonstrated in a 2D toy visualization. While parametric VI collapses to a single Gaussian mode, S-SGMCMC successfully captures multiple distinct modes in the posterior while maintaining the independence structure imposed by the user.
Toy visualization comparing Gaussian VI and S-SGLD on a multi-modal energy landscape.
  • Mixing vs. Accuracy Trade-off: Increasing the number of parameter groups ($M$) monotonically improves the mixing rate (measured by lower Integrated Autocorrelation Time). Surprisingly, this doesn't always hurt accuracy; in many cases, the "dropout" effect acts as a beneficial regularizer.
  • Random Partitioning Works: Ablation studies on regression tasks revealed that complex partitioning schemes (e.g., by layer or by neuron) weren't strictly necessary. A simple random partition of parameters often performs just as well for BNNs.

Key Results

The authors evaluated their approach across image classification (ResNet-20 on CIFAR-10, SVHN, FMNIST) and various regression benchmarks.

  • Faster Convergence: On CIFAR-10 and SVHN, the dropout variant ($S_d$-SGMCMC) reached optimal accuracy significantly faster than standard SGMCMC and even outperformed advanced VI methods like "Ensemble-I."
Model averaged accuracy over time for CIFAR-10, SVHN, and FMNIST.
  • Better Mixing: The method showed a dramatic reduction in autocorrelation. For example, on CIFAR-10, $S_d$-pSGLD achieved an Integrated Autocorrelation Time (IAC) of 620, compared to 831 for standard pSGLD—a clear win for efficiency.
  • Competitive Accuracy: In most classification tasks, the structured approach either matched or slightly exceeded the final accuracy of the baseline SGMCMC while being much more computationally efficient.

Limitations and Future Work

  • GPU Memory Overhead: To perform the "self-averaging," the algorithm needs to keep a history of samples on the GPU. For very large-scale models, this could become a memory bottleneck. The authors suggest "thinning" the chain or using reservoir sampling as a potential fix.
  • Compute per Sample: While the wall-clock time to convergence is better, each individual sample in $S_d$-SGMCMC requires slightly more computation than a standard SGMCMC step due to the masking and averaging logic.
  • Masking Distributions: The current work focuses heavily on Bernoulli (dropout-style) masks. Exploring other distributions (like Gaussian or Beta-dropout) remains a promising avenue for future research.

Summary updated

BibTeX
@inproceedings{alexos2022structured,
  author = {Antonios Alexos and Alex James Boyd and Stephan Mandt},
  title = {{Structured Stochastic Gradient MCMC}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=57T1ctyxtP},
}
Figure