Control variates for stochastic gradient MCMC

Jack Baker, Paul Fearnhead, Emily B. Fox, Christopher Nemeth · DOI

Abstract

Bayesian inference on large datasets is often bottlenecked by the computational cost of standard Markov chain Monte Carlo (MCMC) methods. While Stochastic Gradient MCMC (SGMCMC) offers a solution via minibatches, the resulting gradient noise typically requires computational effort that scales linearly with dataset size. This paper, published in Statistics and Computing, introduces SGLD-CV, a method leveraging control variates to achieve a computational cost independent of dataset size ($O(1)$) for a fixed accuracy level. Additionally, the authors present a "Zero Variance" post-processing step to further refine posterior estimates using computed gradient information.

Introduction: The Scalability Challenge

Standard MCMC methods require a full pass over the entire dataset at every iteration, making them impractical for "Big Data" applications. Stochastic Gradient MCMC variants, such as Stochastic Gradient Langevin Dynamics (SGLD), mitigate this by using small minibatches to estimate the gradient of the log-posterior. However, the "noise" introduced by sub-sampling necessitates either very small step sizes or increasingly large minibatches as the total dataset size $N$ grows. Recent theoretical work suggested that for standard SGLD, the total computational cost to reach a specific accuracy still scales as $O(N)$, effectively negating the stochastic advantage for massive datasets.

Methodology: Variance Reduction via Control Variates

The authors propose two primary uses for control variates to address the noise inherent in SGMCMC.

SGLD-CV: Efficient Sampling

The core innovation, SGLD-CV, utilizes a "centering value" $\hat{\theta}$ (typically the MAP estimate or posterior mode) calculated once before sampling begins. Instead of a raw minibatch gradient, the algorithm uses a modified estimate: $$\nabla \tilde{f}(\theta) = \nabla f(\hat{\theta}) + [\nabla \hat{f}(\theta) - \nabla \hat{f}(\hat{\theta})]$$ Here, $\nabla f(\hat{\theta})$ is the full gradient at the mode, and the bracketed term is the difference between minibatch gradients at the current position $\theta$ and the mode $\hat{\theta}$. Since $\theta$ and $\hat{\theta}$ are often close during the simulation, these two minibatch gradients are highly correlated, and their difference has much lower variance than a single minibatch gradient.

Zero Variance (ZV) Control Variates: Post-processing

The authors also demonstrate that the gradient information already calculated during SGMCMC can be used to reduce the variance of final estimates after the chain has finished running. This "Zero Variance" (ZV) post-processing step provides a "free" improvement in accuracy by utilizing data that is typically discarded.

Algorithm for Zero Variance (ZV) post-processing of SGLD output.

Key Insights: Achieving $O(1)$ Complexity

A major theoretical contribution of this work is the proof that, under the assumption of strong log-concavity, the number of iterations and minibatch size required for SGLD-CV do not need to increase as the dataset size $N$ increases. This $O(1)$ complexity makes the algorithm truly scalable.

Furthermore, SGLD-CV proves more robust than competing methods like SAGA, which use the previous state's gradient as a control variate. In complex, high-dimensional landscapes like Latent Dirichlet Allocation (LDA), SAGA can get "stuck" in local modes or flat regions. By using a fixed centering point (the mode), SGLD-CV maintains better exploration properties.

Experimental Evaluation

The authors evaluated their methods on three distinct tasks using real-world data:

  • Logistic Regression: Using the Covertype dataset (581,012 observations). SGLD-CV maintained consistent, high log-predictive density as $N$ increased, while standard SGLD's performance degraded significantly for the same time budget.
  • Probabilistic Matrix Factorization (PMF): Using the MovieLens 100k dataset to predict user movie ratings.
  • Latent Dirichlet Allocation (LDA): Using a corpus of 80,000 Wikipedia articles. SGLD-CV escaped local modes (indicated by "blips" in perplexity) much faster than both standard SGLD and SAGA.

Across all experiments, the ZV post-processing step consistently "tightened" the box plots of predictive density, demonstrating a clear reduction in Monte Carlo error.

Limitations and Future Work

While SGLD-CV shows empirical success on non-log-concave models, the $O(1)$ theoretical guarantee currently relies on strong log-concavity. Extending these theoretical bounds remains an open question. Additionally, SGLD-CV requires an initial $O(N)$ optimization step to find $\hat{\theta}$. While this is a one-time cost, it may not be beneficial for very short MCMC runs. Finally, ZV post-processing requires storing gradients for every iteration, which could lead to memory bottlenecks in models with millions of parameters; future work could explore "on-the-fly" estimation to mitigate this.

Summary updated

BibTeX
@article{baker2019control,
  author = {Jack Baker and Paul Fearnhead and Emily B. Fox and Christopher Nemeth},
  title = {{Control variates for stochastic gradient MCMC}},
  journal = {Stat. Comput.},
  year = {2019},
  doi = {10.1007/s11222-018-9826-2},
}
Figure