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

A Unified View of Stochastic Hamiltonian Sampling

Giulio Franzese, Dimitrios Milios, Maurizio Filippone, Pietro Michiardi · OpenReview

Abstract

We revisit the theoretical properties of Hamiltonian stochastic differential equations (SDEs) for Bayesian posterior sampling, and we study the two types of errors that arise from numerical SDE simulation: the discretization error and the error due to noisy gradient estimates in the context of data subsampling. Our main result is a novel analysis for the effect of mini-batches through the lens of differential operator splitting, revising previous literature results. The stochastic component of a Hamiltonian SDE is decoupled from the gradient noise, for which we make no normality assumptions. This leads to the identification of a convergence bottleneck: when considering mini-batches, the best achievable error rate is $\mathcal{O}(\eta^2)$, with $\eta$ being the integrator step size. Our theoretical results are supported by an empirical study on a variety of regression and classification tasks for Bayesian neural networks.

Introduction

Hamiltonian Monte Carlo (HMC) is widely regarded as the "gold standard" for sampling from complex probability distributions, particularly the high-dimensional posteriors of Bayesian Neural Networks (BNNs). However, the computational cost of calculating gradients over entire datasets at every step limits its scalability. To address this, researchers employ Stochastic Gradient HMC (SGHMC), which utilizes mini-batches to estimate gradients.

This paper re-evaluates the impact of mini-batching on sampling accuracy. Contrary to previous assumptions that mini-batching preserves asymptotic error rates, we identify a fundamental "convergence bottleneck" that limits the precision of stochastic samplers regardless of the numerical integrator's sophistication.

Theoretical Framework: Operator Splitting and Decoupled Noise

The study analyzes Hamiltonian samplers using Stochastic Differential Equations (SDEs) and differential operator splitting. A key innovation is the decoupling of gradient noise from thermal noise (Brownian motion). By treating these as separate entities and avoiding Gaussian assumptions for gradient noise, the authors model system evolution as a series of mathematical operators.

This geometric perspective allows for a precise calculation of the error introduced by each algorithmic component. The resulting framework, termed SHMC (SDE-based HMC), simplifies the sampling process by demonstrating that a simple friction term is sufficient to reach the correct distribution, rendering complex "noise counterbalancing" steps optional.

Figure 5: Predictive posterior and SDE sample paths for different friction coefficients (C). The visualization shows how varying friction levels influence the exploration of the parameter space and the resulting predictive distribution.

The $O(\eta^2)$ Convergence Bottleneck

The central finding of this research is the $O(\eta^2)$ bottleneck. In traditional numerical simulation, using higher-order integrators typically reduces discretization error. However, the noise introduced by mini-batching creates a hard error floor proportional to the square of the step size ($\eta^2$).

Empirical results confirm this theory. In full-batch scenarios, a 3rd-order integrator (MT3) significantly outperforms 2nd-order methods (Symmetric and Lie-Trotter). However, once mini-batches are introduced, the performance of the high-order MT3 integrator collapses to the same level as the 2nd-order methods. This suggests that for large-scale Bayesian inference, sophisticated integrators are often "overkill" because stochastic gradient noise—not discretization—becomes the dominant source of inaccuracy.

Figure 1: Comparison of average Kolmogorov distance across different step sizes for mini-batch and full-batch settings. In the full-batch case (right), the 3rd-order MT3 integrator maintains lower error for longer. In the mini-batch case (left), all integrators converge to a similar error floor, illustrating the O(η²) bottleneck.

Key Insights and Results

  • HMC as an Integrator: The classic HMC algorithm with partial momentum refreshment is shown to be mathematically equivalent to a specific SDE integrator (Lie-Trotter splitting), unifying two distinct theoretical perspectives.
  • Step Size Sensitivity: Larger mini-batches (lower noise) allow for larger step sizes. However, as noise increases, the step size $\eta$ must be drastically reduced to maintain accuracy, eventually hitting the $O(\eta^2)$ floor.
  • Predictive Performance: Despite the theoretical bottleneck, the simplified SHMC method achieved competitive RMSE and Log-Likelihood scores on standard UCI benchmarks compared to more complex adaptive SGHMC variants.

Conclusion

This work provides a more robust theoretical foundation for stochastic Hamiltonian sampling. By identifying the $O(\eta^2)$ bottleneck, it clarifies why high-order integrators may not yield expected benefits in mini-batch settings. Future research may explore dynamic tuning of friction coefficients to further mitigate the impact of mini-batch noise on sampling accuracy.

Summary updated

BibTeX
@inproceedings{franzese2022unified,
  author = {Giulio Franzese and Dimitrios Milios and Maurizio Filippone and Pietro Michiardi},
  title = {{A Unified View of Stochastic Hamiltonian Sampling}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=lqO95Z4uYuF},
}
Figure