NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The promises and pitfalls of Stochastic Gradient Langevin Dynamics

Nicolas Brosse, Alain Durmus, Eric Moulines

Stochastic Gradient Langevin Dynamics (SGLD) is often hailed as the "silver bullet" for Bayesian inference on massive datasets. By combining the sampling power of Markov Chain Monte Carlo (MCMC) with the efficiency of mini-batch gradients, it promises to make posterior sampling as fast as optimization. However, a 2018 paper by Brosse, Moulines, and Durmus reveals a significant catch: in the "big data" limit, SGLD might not be sampling what you think it is.

While SGLD is a popular tool for large-scale Bayesian learning, this research proves that with standard constant step sizes, it fails to converge to the true posterior as the dataset size $N$ grows. Instead, it behaves more like Stochastic Gradient Descent (SGD). Fortunately, the "Fixed Point" variant (SGLDFP) offers a mathematically sound way to regain accuracy without sacrificing speed.

The Problem with Standard SGLD

In Bayesian machine learning, the goal is to sample from a posterior distribution $\pi$. Traditional MCMC methods, like Metropolis-Hastings, are gold standards for accuracy but are computationally expensive because they require a full pass over the entire dataset ($N$ samples) at every single iteration.

SGLD was introduced to solve this by using mini-batches to estimate gradients. To keep the algorithm stable as $N$ increases, practitioners typically set the step size $\gamma$ to be inversely proportional to $N$ (i.e., $\gamma \approx 1/N$). The authors investigate a critical question: Does SGLD actually sample from the posterior in this large-$N$ regime?

The answer is a resounding "no" for standard SGLD, though the authors provide a roadmap for how to fix it.

Analyzing the Algorithms

The authors conduct a rigorous theoretical analysis comparing four algorithms:

  1. Langevin Monte Carlo (LMC): The "full-batch" baseline that uses the entire dataset for every gradient step.
  2. SGLD: The mini-batch version that adds Gaussian noise to a stochastic gradient.
  3. SGD: Stochastic Gradient Descent (SGLD without the added Gaussian noise).
  4. SGLDFP (Fixed Point SGLD): A modified SGLD that uses control variates. It centers the stochastic gradient around a pre-computed estimate of the mode (the MAP estimate, $\theta^*$).

The researchers use the Wasserstein-2 distance ($W_2$)—a metric that measures the distance between probability distributions—to quantify how far each algorithm's "steady state" is from the true target posterior.

Key Insights: Variance and Control Variates

  • The SGLD "Pitfall": The most striking finding is that as $N \to \infty$, the invariant measure of SGLD does not approach the posterior $\pi$. Instead, the variance of the stochastic gradients becomes so high that it "drowns out" the injected Langevin noise. SGLD essentially turns into SGD with a bit of useless jitter.
  • The Gradient Variance Problem: In standard SGLD, the variance of the stochastic gradients scales as $O(N^2)$. This is the root cause of the departure from the posterior.
  • The "Promise" of Control Variates: By using SGLDFP, the gradient variance is reduced to $O(N)$. This allows the algorithm to maintain an accuracy comparable to the full-batch LMC while keeping the computational cost sublinear (meaning it doesn't get exponentially slower as you add more data).
  • Bias vs. Variance: The paper provides explicit expressions for the means and covariances of these algorithms' stationary distributions, showing that SGLD has a non-vanishing bias in the large-data limit.

Key Results and Convergence Rates

The theoretical findings are supported by experiments on simulated Bayesian Logistic Regression (a controlled environment with $N=10^5$ observations and $d=2$ dimensions) and the real-world Covertype dataset.

The authors prove that the $W_2$ distance between SGLD and the posterior remains at a constant "floor" ($\Omega(1)$) even as $N$ grows. In contrast, SGLDFP's distance to the posterior shrinks at a rate of $O(1/\sqrt{N})$.

Log-log plots of distance to the mode vs. dataset size N for LMC, SGLDFP, SGLD, and SGD.

Numerical experiments confirm the theory. As shown in the log-log plots of distance to the mode versus $N$, LMC and SGLDFP exhibit a clear downward slope, indicating convergence. Meanwhile, SGLD and SGD flatten out, indicating they have hit an error floor they cannot cross. Ultimately, SGLDFP achieves the same accuracy as LMC but requires significantly fewer operations per iteration, making it the only viable "true" sampler among the bunch for massive datasets.

Limitations and Future Work

  • Strong Convexity: The analysis relies on the assumption that the potential function $U$ is strongly convex (i.e., the distribution is strongly log-concave). While common in theoretical papers, many deep learning models have non-convex landscapes where these guarantees might not hold.
  • Preprocessing Cost: SGLDFP requires an initial estimate of the mode $\theta^*$. While the authors suggest this can be done quickly with SGD, it adds a mandatory preprocessing step to the pipeline.
  • Numerical Scope: The experiments are limited to logistic regression. Future work could explore how these "pitfalls" manifest in more complex architectures like neural networks, where the relationship between SGD and SGLD is even more nuanced.

Summary updated

BibTeX
@inproceedings{brosse2018promises,
  author = {Nicolas Brosse and Alain Durmus and Eric Moulines},
  title = {{The promises and pitfalls of Stochastic Gradient Langevin Dynamics}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=HkVQewbd-S},
}
Figure