UNB Researchers Prove SGD Secretly Samples a Bayesian Posterior With 0.009 KL Divergence
A new theory maps SGD's late-stage training to diffusion on a fractal loss landscape, and shows it approximates a tempered Bayesian posterior.
ProTakeaways
- New paper models late-stage SGD as sub-diffusion on a fractal loss landscape via a fractional Fokker-Planck equation.
- Steady-state distribution is a tempered Bayesian posterior weighted by accessibility, resolving the SGD-Bayes gap.
- Two fractal dimensions govern dynamics: the local learning coefficient and the spectral dimension.
- Predicts $d_s \leq \lambda$ and power-law weight displacement, validated on TinyStories, ResNet, VGG, MNIST.
- Tempered SGD distribution matches SGLD posterior with KL divergence 0.009 on Moons dataset.
- Theory does not yet fully capture Adam or grokking; code uses the devinterp library.
For years, deep learning researchers have suspected that stochastic gradient descent behaves a bit like Bayesian sampling. Networks trained with SGD tend to land in flat, simple minima, which is exactly where a Bayesian posterior would concentrate. But nobody had a clean theoretical story explaining why, especially for the highly degenerate loss landscapes that real neural networks produce. A new paper titled Almost Bayesian: Dynamics of SGD through Singular Learning Theory offers one, by reframing SGD as diffusion on a porous, fractal medium.
The authors, Max Hennick and Stijn De Baerdemacker at the University of New Brunswick, show that in the long run SGD samples from what is effectively a tempered Bayesian posterior, where the tempering encodes which regions of parameter space the optimizer can physically reach. It is a rigorous connection between two frameworks that had only been loosely related before.
Why the old picture was broken
The standard way to relate SGD to Bayesian inference goes through the Langevin equation: treat the noisy weight updates as gradient descent plus Gaussian noise, and you get Brownian motion whose stationary distribution looks like a Boltzmann distribution over the loss. Earlier work by Mandt, Hoffman, and Blei pushed this analogy hard, modeling SGD as an Ornstein-Uhlenbeck process to draw the connection back to Bayesian inference.
The problem is that this derivation assumes the loss has quadratic minima, meaning the Hessian is non-degenerate. Neural networks are highly singular models and generally admit many equivalent parametrizations that compute the same function, so their minima are almost never quadratic. Empirically, the weights of trained networks do not diffuse like Brownian motion at all. Networks trained under SGD can behave super-diffusively early in training, becoming sub-diffusive as training continues, with displacement scaling as a power law $R(t) \propto t^{1/\nu}$ for $\nu \geq 2$, or even logarithmically when momentum and weight decay are used.
This is called anomalous diffusion, and the ordinary Fokker-Planck equation cannot produce it. Something more general is needed.
Singular learning theory, in one paragraph
The paper builds on Watanabe's singular learning theory (SLT) and its practical tool, the local learning coefficient (LLC). Roughly speaking, the LLC $\lambda(w^*)$ measures the effective dimension of the low-loss region around a parameter $w^*$. A small LLC means the parameter sits in a wide, flat, degenerate basin where many nearby configurations achieve similarly low loss. A large LLC means a sharper, more constrained minimum. In classical statistics you would replace $\lambda$ with $d/2$, half the parameter count, but for singular models like neural networks the LLC can be much smaller and it directly controls generalization behavior.
The core idea: SGD as diffusion through a porous medium
Instead of Brownian motion on a smooth surface, the authors model late-stage SGD as diffusion on a porous, fractal medium. Two fractal dimensions do the heavy lifting:
- The local learning coefficient $\lambda(w)$, which plays the role of a mass fractal dimension. It describes how the volume of low-loss configurations scales around a critical point.
- The spectral dimension $d_s$, which describes how quickly a diffusive process can actually explore that volume. Intuitively $d_s$ says how fast diffusion fills out the medium you are diffusing on, and in that sense it is the dimension that diffusion sees.
These are tied together by the Alexander-Orbach relation, which gives the walk dimension $d_{\text{walk}} = 2\lambda / d_s$. The authors then replace the standard Fokker-Planck equation with a fractional Fokker-Planck equation, using a Caputo fractional time derivative that acts like a derivative with power-law memory of the past. This is what produces the sub-diffusive behavior observed in real training runs.
The payoff: a tempered Bayesian posterior
Solving the steady state of this fractional equation yields a clean result. The stationary distribution over weights takes the form $p_s(w) \propto \exp(-\gamma \mathcal{L}_m[w] / D_\xi)$, where $D_\xi$ is an effective scalar diffusion coefficient at some measurement scale $\xi$. Raise this to the appropriate power and it recovers the Bayesian posterior, but with an extra exponent that depends on the LLC through $D_\xi$.
In plain terms: SGD does not sample the pure Bayesian posterior. It samples a version where each region is reweighted by how accessible it is to the optimizer. Regions with low LLC (wide, flat basins) act as traps because there is a lot of volume for the walker to explore, so SGD concentrates there more than a true Bayesian sampler would. This explains the earlier empirical finding from Mingard et al. that SGD is "almost" but not quite a Bayesian sampler.
Does it match reality?
The theory makes a sharp prediction: for a network trained to convergence, $d_s \leq \lambda(w)$, and the weight displacement should follow $R(t) \propto t^{d_s / 2\lambda}$. The authors test this across a range of models and datasets.

Results are reported for TinyStories-1M, TinyLlama-15M, TinyStories-33M, ResNet18, ResNet34, and VGG16, along with extensive ablations on MNIST and CIFAR10. The sub-diffusive fits give $r^2$ values of 0.97 to essentially 1.0 across the board. On a Moons dataset with 500 identically initialized networks, the tempered SGD distribution matches an SGLD-approximated Bayesian posterior almost exactly, with a KL divergence of 0.009 and a Wasserstein distance of 0.002.
Where it breaks down
The theory is built around SGD in the large-batch, small learning-rate regime. Adaptive optimizers are the main limitation:
- The theory does not explicitly take into account complex dynamics of adaptive optimizers like Adam, as adaptive optimizers can exhibit multiple spectral dimensions over the course of training.
- The results assume an approximate steady state exists, which may fail when label noise drives a non-equilibrium probability flow.
- Grokking-style training exhibits sudden jumps in weights and LLC that would require adding a fractional Laplacian in space (equivalent to a Levy-noise Langevin equation) to model properly.

Why this matters beyond theory
For practitioners, the paper suggests a few concrete uses:
- Better uncertainty calibration. Standard "Bayesian deep learning" approximations often assume Langevin dynamics with quadratic minima. This framework provides a principled correction for degeneracy and accessibility.
- Transfer learning diagnostics. Tracking $\lambda$ and $d_s$ during fine-tuning tells you whether you are stuck in a wide flat basin (low $d_s$, high loss suggests raising learning rate or shrinking batch size) or making real progress.
- Structural learning-rate schedules. Warmup and decay can be interpreted as shaping $d_s$ over time: high early for exploration, low later for localization.
- Optimizer evaluation. Comparing how $\lambda$ and $d_s$ evolve under different optimizers gives a geometric handle on why some generalize better than others.
Code for the experiments is available, and the LLC estimation itself is built on the open-source devinterp library from Timaeus Research, which is worth a look if you want to start measuring these quantities on your own models. The broader research program this connects to is called developmental interpretability, and it treats SLT quantities like the LLC as tools to study how structure emerges inside networks during training.