There are a huge number of available analyses for stochastic gradient descent (SGD), which can account for its behavior in many different scenarios, from convex to non-convex objectives, with or without acceleration, within Euclidean geometry or beyond, with or without pre-conditioning, and with an infinite variation regarding the decay of step sizes.
Recently, while these were a bit looked down upon for quite a while, a lot of focus has come back to asymptotic scaling laws (see earlier blog posts I, II, III, and references therein). Most of them rely on quadratic objective functions, from extremely (too?) simple (additive noise on gradients as done just below in full detail) to less simple (least-mean-squares with potentially multiplicative noise, see [24]), with few results beyond (in recent work, we were able to obtain scaling laws for the cross-entropy loss in a restricted setting inspired by text data [13]).
This post aims to describe existing asymptotic analyses for SGD.
**Insights from quadratics.** In the simplest situation, one wants to minimize the quadratic function $F: \mathbb{R}^d \to \mathbb{R}$, with access to gradients with additive noise whose distribution is independent of the point where the gradient is taken, that is, at iterate $x_{k-1}$, we access $F'(x_{k-1}) + \varepsilon_k$, where $(\varepsilon_k)_{k \geqslant 1}$ is a sequence of independent zero-mean random vectors in $\mathbb{R}^d$ with covariance matrix $\Sigma$ (which we assume to commute with the Hessian matrix $H$ of $F$ for later simplifications). If $x_\ast \in \mathbb{R}^d$ is a minimizer of $F$, the iteration with constant step size $\gamma$ (the main focus of this blog post) $$ x_k = x_{k-1} – \gamma \big( F'(x_{k-1}) + \varepsilon_k\big) = x_{k-1} – \gamma \big( H(x_{k-1}-x_\ast) + \varepsilon_k\big) $$ can be unrolled into $$x_k -x_\ast = (I -\gamma H)^k (x_0 – x_\ast) \, – \sum_{i=1}^k ( I- \gamma H)^{k-i} \gamma \varepsilon_i. $$ This implies that $\mathbb{E} [ x_k -x_\ast ] = (I -\gamma H)^k (x_0 – x_\ast) $ (which is the deviation of the gradient descent iterate from $x_\ast$), and, with a slight abuse of notation regarding matrix fractions, we have $${\rm cov} (x_k) = \gamma^2 \Sigma \sum_{j=0}^{k-1} ( I- \gamma H)^{2j} = \frac{\gamma }{2} \frac{I – ( I – \gamma H)^{2k}}{I – \frac{\gamma H}{2} } H^{-1/2} \Sigma H^{-1/2}.$$
This implies that if $H$ is invertible and $\gamma < 2/L$ (so that $\| I – \gamma H \|_{\rm op} <1$, where $L = \lambda_{\max}(H)$), we have a strict separation of two effects, with two distinct phases that are observed in practice:
-
Forgetting of initial conditions like in gradient descent (with the expectation being exactly GD), converging to $x_\ast$.
-
Residual noise with a known covariance matrix that can be computed in closed form, and that is asymptotically equivalent to $\gamma C$ for $C= \frac{1}{2} H^{-1/2} \Sigma H^{-1/2}$ (when $C$ and $H$ commute), when $\gamma$ tends to zero (note that there is a general formula for any $\gamma \in (0,2/L)$). Moreover, still when $\gamma$ tends to zero, a central limit theorem shows that the stationary distribution isGaussian with mean $x_\ast$ and covariance matrix $\gamma C$ (see [8] and [1, Part II, Section 4.6]). See illustration below. The main question I am addressing in this blog post is: What can be asymptotically and quantitatively said for constant-step-size stochastic gradient descent beyond the simplest quadratic case above?
There are already several approaches, from going beyond additive noise to studying only the stationary distribution, which we review first, before moving to a full description of the whole trajectory in the general non-quadratic case.
Beyond additive noise. As presented in an earlier post, for least-squares regression with linearly parameterized predictors (the so-called least-mean-squares setup, which does not correspond to purely additive noise as above [24]), we can also use linear algebra to obtain rates and maximal step sizes, but this time with a recursion on the second-order deviation, $\mathbb{E}[ ( x_k , -, x_\ast)(x_k-x_\ast)^\top ]$. In the general case, this requires knowledge of the fourth-order moment of input features, and several simplifying assumptions can be considered to obtain simpler statements. I like the one found out by Alexandre Défossez in our paper [18], when input features are normalized: for convergence, we need $\gamma < 2 / {\rm tr}(H)$ instead of $\gamma < 2 / \lambda_{\max}(H)$ (thus SGD requires smaller step sizes). Overall, we obtain the same separation between forgetting of initial conditions and residual noise. But this is still for quadratic objectives.
In this post, we will move beyond least squares, but remain mostly in the “simple” convex world where gradient descent usually converges to the global optimum of the objective function $F$. We make it even simpler by assuming strong convexity (e.g., regularized logistic regression or least-squares with invertible input feature covariance matrix). In this situation, we can still get interesting asymptotic statements.
Stationary distribution. In this setup, for a sufficiently small constant step size, provable convergence to a (typically non-Gaussian) stationary distribution can be obtained (this is true with much weaker assumptions but this is not the topic here), with some mean $\mu_\gamma$ and covariance matrix $C_\gamma$ that can be analyzed when $\gamma$ tends to zero [23]. More precisely, the mean has an asymptotic expansion $\mu_\gamma = x_\ast + \gamma \Delta + o(\gamma)$, which makes it a good candidate for Richardson extrapolation, and the covariance matrix has the same expansion as for the simple least-squares setup above, where $\Sigma$ is the covariance of the gradients at the optimum $x_\ast$. These analyses, however, focus only on the limit behavior (with a precise description), but do not tackle the initial transient phase. Note that such analyses can be extended beyond the convex case (see the nice study in [25]).
Joint asymptotics in step size and horizon. We get asymptotic separation in two terms for a fixed horizon $K$ (that is, we know in advance how many iterations we want to perform) and when $\gamma K$ tends to a constant, which is the main topic of this post. I will try to look at the simplest analysis, which is (interestingly) historically among the first ones, and see it as the approximation by an ordinary differential equation (ODE), the gradient flow, with stochastic fluctuations characterized by a linear stochastic differential equation (SDE).
The goals of the post are thus (1) to describe these approximations in the simplest situation (strongly-convex), (2) mention classical extensions, in particular in the non-convex case, and (3) show how this can be used to analyse simple modifications (here, only averaging).
Why does it matter? This is a simple model to understand modifications of SGD, such as acceleration, mirror descent, steepest descent, averaging, or to study the impact of forgetting initial conditions vs. noise. Future posts will probably touch upon these. The key here is that these analyses can be carried out with limits and not with bounds.
Why is it not ideal? These results correspond to small step sizes while in practice we aim for large ones (and even very large ones in recent work on “edge of stability” [26]), and some behaviors cannot be explained (e.g., minibatching, as shown below). Two possible extensions are meant to go beyond: higher-order “modified” equations [4], or continuized acceleration [14] as presented in an earlier post.
We can now go into more details.
Setup #
We consider the SGD recursion, started from some $x_0 \in \mathbb{R}^d$, $$x_k = x_{k-1} – \gamma f'(x_{k-1},c_k),$$ where $f: \mathbb{R}^d \times \mathcal{C} \to \mathbb{R}$ is a fixed deterministic function and $(c_k)_{k \geqslant 1}$ is a sequence of i.i.d. random variables. Here, we only consider gradients with respect to $x$.
For each $c \in \mathcal{C}$, the function $f(\cdot,c)$ is a convex $L$-smooth function from $\mathbb{R}^d$ to $\mathbb{R}$. We consider $F(x) = \mathbb{E}[f(x,c)]$ (which has to be convex and $L$-smooth, but which we assume to be strongly-convex for simplicity). We assume that the step size $\gamma > 0$ is constant across iterations, with a potential dependence on the horizon (that is, we stop the algorithm after $K$ iterations, and we allow $\gamma$ to depend on $K$).
Notation conflict. In this blog post I have chosen the optimization convention where $x$ is used for iterates, and another letter $c$ for data. In much of my work and in my book [31], I chose $\theta$ for iterates and $x,y,z$ for data, which is more classical in machine learning and statistics. I mostly did it here because uppercase letters are not that practical to use for Greek letters, but I stood my ground and will never use $n$ for the dimension of iterates as this is reserved for the number of observations. I (try to) have principles!
Deterministic case #
We first consider the deterministic case where all functions $f(\cdot,c)$ are equal to $F$, that is, the gradient descent (GD) recursion $$x_k = x_{k-1} – \gamma F(x_{k-1}).$$ We consider the gradient flow (GF) $$dX_t = , – F'(X_t)dt,$$ with a natural matching of time $t_k = \gamma k$ for the $k$-th iteration. Note that time has a dimension (homogeneous to a step size, and thus to an inverse Hessian), while the iteration number does not. We thus see that gradient descent is exactly the Euler discretization of the gradient flow, but our goal is not to approximate GF by GD, but to study GD through GF, keeping in mind that at the end, the goal is to find the global minimizer.
Convergence for convex functions. For convex $L$-smooth functions, we can show (see elementary proof at the end of the post) $$\sup_{k \in {0,\dots,K}} | x_k , – X_{\gamma k} | \leqslant \frac{K ( \gamma L)^2}{2} \frac{ | F'(x_0)|}{L}.$$ Thus, if $(\gamma L)^2 K$ tends to zero (on top of $\gamma L$ tending to zero and $K$ tending to $+\infty$), the gradient flow is a good match to gradient descent between iterations $0$ and $K$. In particular, when $\gamma L K$ tends to a constant, we get convergence in $1/K$. Note that strong convexity is not needed here (we only care about approximation of GD by the gradient flow, not about convergence to the global optimum).
Convergence for potentially non-convex functions. When we only assume smoothness and not convexity, we get an extra exponential term, that is, we can show $$\sup_{k \in {0,\dots,K}} | x_k, – X_{\gamma k} | \leqslant e^{ \gamma L K } \frac{K ( \gamma L)^2}{2} \frac{ | F'(x_0)|}{L}.$$ Note here that for a good approximation, we need the stronger condition that $\gamma L K$ remains bounded, and an exponential term appears. A proof is given at the end of the post. This is a standard estimate for the explicit Euler method (see [20, Section II.3]): without some form of contraction argument, errors may accumulate exponentially.
Stochastic case #
In the stochastic case, we need to characterize the noise. A nice feature (but also a “bug” since it prevents further analysis that depends on higher-order moments) is that only second-order moments are needed. Define $$ \Sigma(x) = \mathbb{E} \big[ ( f'(x,c) -F'(x) )( f'(x,c) -F'(x) )^\top\big] \in \mathbb{R}^{d \times d}$$ the local covariance of the gradient noise (remember that $\mathbb{E}[f'(x,c)] = F'(x)$).
Our goal is to extend the deterministic analysis and be able to analyze two effects:
- Forgetting of initial conditions like in gradient descent.
- Oscillations around the global optimum (that should disappear when all $\Sigma(x)$ are zero).
An old surprising result is that because the gradient noise is multiplied by the step size $\gamma$, at first order, the limit of SGD for vanishing step size, that is, when $\gamma L $ tends to zero, and $K$ tends to infinity, is still gradient flow, and only at the next order in $\sqrt{\gamma}$, we can see fluctuations.
For the general non-convex case, if $\gamma$ tends to zero and $K$ tends to infinity while $\gamma K$ converges to a constant, then $$x_k \approx X_{k\gamma} + \sqrt{\gamma} U_{k\gamma}$$ with $X \in \mathbb{R}^d$ the deterministic gradient flow, and $U\in \mathbb{R}^d$ satisfying the “tangent” non-homogeneous *linear* SDE (started at $U_0=0$), that depends on noise covariance matrices and Hessians along the gradient flow: $$ dU_t = -F^{\prime \prime}(X_t) U_t dt + \Sigma(X_t)^{1/2} dB_t.$$ More precisely, when $\gamma \to 0$, we have when $K \to +\infty$ such that $\gamma K$ converges to a constant: $$ \frac{x_k- X_{k\gamma} }{\sqrt{\gamma}} \to U_{\gamma k}$$ in distribution uniformly for $k \in \{0,\dots,K\}$. See [1] for the classical account from a more general stochastic approximation point of view. In terms of bounds, it is possible to show a convergence rate for the proper metric, in $(\gamma L)^2 K$ for the convex case, and with an extra exponential dependence in $e^{ (\gamma L)K}$ for the generic case. See after the references for a proof sketch. Note that these approximation results require neither strong convexity nor uniqueness of minimizers of $F$ (no claim about convergence to a minimizer is yet made).
**Limiting distribution.** Assuming that the gradient flow converges to a unique minimizer $x_\ast$ with positive-definite Hessian (e.g., when $F$ is strongly-convex), the distribution of $U_t$ converges to a Gaussian distribution with mean zero and covariance matrix $C_\ast$ defined as $F^{\prime \prime}(x_\ast) C_\ast + C_\ast F^{\prime \prime}(x_\ast) = \Sigma(x_\ast)$ (the stationary covariance for the solution $U$ of the linear SDE). This is simply obtained as the stationary distribution of the homogeneous SDE $dV_t = -F^{\prime \prime}(x_\ast) V_t dt + \Sigma(x_\ast)^{1/2} dB_t.$ This is a classical continuous-time [Lyapunov equation](https://en.wikipedia.org/wiki/Lyapunov_equation) (which itself is a special case of the [Sylvester equation](https://en.wikipedia.org/wiki/Sylvester_equation)). Note that in the “interpolating regime” where $\Sigma(x_\ast) = 0$, the limiting distribution of SGD is then a Dirac at $x_\ast$ (see [30] for more results).
**Single SDE.** The same two leading-order effects can also be represented by a single small-noise SDE, as developed in [10, 4, 17, 19]: $$dY_t =\, \, – F'(Y_t) dt + \sqrt{\gamma} \Sigma(Y_t)^{1/2} dB_t,$$ but with the same approximation properties as the tangent SDE (that is, the difference is $o(\sqrt{\gamma})$ and can be shown to be of order $O(\gamma)$). Therefore, it is not a better approximation; better ones exist with error $O(\gamma^2)$ [10, 4], but they “miss the point” in understanding SGD’s converging behavior, because SGD is already off by $O(\gamma)$.
Historical note. These approximations are classical in stochastic approximation. The ODE method describes the average trajectory, while a linear SDE describes the fluctuations around it; see Benveniste, Métivier, and Priouret [1]. For constant step sizes near a stable optimum, related stationary Gaussian approximations go back at least to Kushner and Huang [8]. Finnoff [9] used a similar transient decomposition for constant-learning-rate backpropagation. The nonlinear SDE above corresponds to the stochastic-modified-equation formulation developed in the modern SGD literature by Li, Tai, and E [10, 4]; Mandt, Hoffman, and Blei [17] used a local Ornstein–Uhlenbeck model to study stationarity.
Taking into account the two effects. The analysis as “gradient flow + fluctuations” already puts forward two main often contradicting effects that were already mentioned: (1) forgetting of initial conditions (which needs to be as fast as possible) and (2) non-vanishing fluctuations (which need to be diminished in some way). These two effects need to be taken care of simultaneously. Over the years and across communities, one of these two effects has taken over. In a caricatural way, the optimization community focuses a lot on forgetting initial conditions, with the largest possible step size and several notions of acceleration (at the expense of final fluctuations). The statistics community focuses on the final fluctuations, which are asymptotically what matters at the end of estimation, proposing diminishing step sizes or averaging (at the expense of forgetting initial conditions). These two effects matter and most of the modern literature take them into account.
Averaging #
In order to dampen the oscillations around the optimum, various forms of averaging have been introduced [21, 32, 33].
Classical averaging is $$ \bar{x}k = \frac{1}{k+1} \sum{i=0}^k x_i, $$ which can be updated online as $\bar{x}0 =x_0$, and $$ \bar{x}k = \Big( 1 , – \frac{1}{k+1} \Big) \bar{x}{k-1} + \frac{1}{k+1} x_k.$$ We can then view $\bar{x}k$ as the approximation of $\bar{X}{k\gamma}$ for $(\bar{X}){t \geqslant 0}$ a continuous-time process satisfying the ODE $$ d \bar{X}_t = \frac{1}{t} ( X_t – \bar{X}_t) dt.$$
More generally, we can consider any averaging of the form $$ \bar{x}k = ( 1 -\alpha_k) \bar{x}{k-1} + \alpha_k x_k,$$ with $\alpha_k \in (0,1)$. With the identification $\alpha_k \sim \rho_{k\gamma} \gamma$ for a function $\rho_t = \kappa’_t / \kappa_t$ with $\kappa’_t > 0$, we get the ODE $$ d \bar{X}_t = \rho_t ( X_t, – \bar{X}_t) dt.$$ This leads to a low-pass filter with $$\bar{X}_t = \frac{\kappa_0}{\kappa_t} x_0 + \frac{1}{\kappa_t} \int_0^t \kappa’_u X_u du.$$
The deterministic limiting system is $$
\left{ \begin{array} {rcl}dX_t & = &
-F'(X_t),dt \ d\bar X_t
& = &
\rho_t(X_t-\bar X_t),dt. \end{array} \right. $$
At the fluctuation scale, the tangent system is $$
\left{ \begin{array} {rcl} dU_t & = &
-F^{\prime \prime}(X_t)U_t,dt +
\Sigma(X_t)^{1/2}dB_t \
d\bar U_t
& = &
\rho_t(U_t-\bar U_t),dt. \end{array} \right. $$
A single nonlinear system containing the same two leading orders is $$\left{ \begin{array} {rcl} dY_t
& = &
-F'(Y_t),dt +
\sqrt{\gamma}\,
\Sigma(Y_t)^{1/2}dB_t,
\
d\bar Y_t
& = &
\rho_t(Y_t-\bar Y_t),dt, \end{array} \right. $$ still with averaging done “on the side”.
Non-uniform averaging. For $\alpha_k = \frac{\beta}{k+\beta}$ (with $\beta > 0$), we get $\rho_t = \beta / t$, with $\kappa_u = u^\beta$, that is, more weight is put on later iterates. Then the covariance matrix of $\bar{U}t$ satisfies, for $\beta > 1/2$ [27]: $$ {\rm cov}(\bar{U}t) = \frac{1}{t} \frac{\beta^2}{2\beta – 1} F^{\prime\prime}(x\ast)^{-1} \Sigma(x\ast) F^{\prime\prime}(x_\ast)^{-1} + o ( t^{-1}).$$ The covariance of the fluctuations then vanishes at rate $O(1/t)$. This notably shows that $\beta=1$ (uniform averaging) leads to the smallest asymptotic covariance, corresponding to the usual sandwich covariance matrix, which coincides with the Cramér-Rao lower bound for correctly specified likelihood models [2]. Another interesting benefit is that increasing $\beta$ beyond 1 only increases the variance term by a constant factor, while the forgetting of initial conditions is typically improved significantly.
Constant averaging. We consider $\bar{x}k = ( 1 -\alpha) \bar{x}{k-1} + \alpha x_k$ with $\alpha \in (0,1)$. In order to obtain limiting ODEs/SDEs, we need to scale $\alpha$ with the step size $\gamma$ as $$\alpha = \rho \gamma,$$ for $\rho>0$ (thus $\alpha$ tends to zero with the horizon).
Constant averaging then becomes a continuous-time exponential low-pass filter with memory $1/\rho$: $$ \bar X_t = e^{-\rho t}\bar x_0 +
\rho
\int_0^t
e^{-\rho(t-s)}X_s,ds. $$
Moreover, the stationary covariance matrix can be shown to tend to $$ \frac{\rho}{2} \big[ (F^{\prime\prime}(x_\ast) + \rho I)^{-1} C_\ast + C_\ast (F^{\prime\prime}(x_\ast) + \rho I)^{-1}) \big].$$ When $\rho$ tends to zero, it tends to zero, that is, fluctuations vanish.
Effects of averaging. We thus see two effects:
- Slowing down of gradient flow: in the case of convergence, if $X_t – x_\ast \sim \frac{1}{t^\alpha} \Delta$, then $\bar{X}t$ has the same expansion for exponential moving averaging, but is significantly slowed down for $\rho_t = \beta /t$, that is, one can check that $$ \displaystyle \bar{X}t-x\ast=\begin{cases} \frac{\beta}{\beta-\alpha}t^{-\alpha}\Delta+o(t^{-\alpha}) & \text{if } \beta>\alpha,\ \beta t^{-\alpha}\log(t)\Delta+o(t^{-\alpha}\log t) & \text{if } \beta=\alpha,\ t^{-\beta}\bar{\Delta}\beta+o(t^{-\beta}) & \text{if } \beta<\alpha. \end{cases}$$ with, for $\beta<\alpha$, $\displaystyle \bar{\Delta}\beta=\beta \int_0^\infty s^{\beta-1}(X_s-x\ast)ds$ a constant. Thus, after averaging, convergence is always slower, in the constant or (worse) in the exponent.
- Dampening of oscillations: as shown earlier, the limiting covariance matrix can be made significantly smaller.
Mini-batching #
In the minibatch set-up, we consider at time $k$, $b$ independent samples $c_{k,1},\dots,c_{k,b}$ and the sum of the $b$ gradients $$ x_k = x_{k-1} – \gamma \sum_{i=1}^b f'(x_{k-1},c_{k,i}).$$ For a fixed $b$, we obtain the exact same gradient flow limit with $x_k \sim X_{bk \gamma}$, thus, with $b$ gradients, the SGD recursion advances $b$ times faster, which provides no gain in terms of gradient evaluations (we traverse the gradient flow with the same speed per accessed gradient). Moreover, in terms of fluctuations, the variance happens to be exactly the same as before.
From the asymptotic limit, it would seem that minibatching leads to the same per iteration complexity, and thus significant gains once taking into account that accessing blocks of data is in practice much faster. However, this hides the fact that for non-vanishing step sizes, the situation differs. For example, for least-mean-squares with normalized features, the largest step size for $b=1$ is $\gamma = 2/{\rm tr}(H)$, while for $b>1$, a typical maximal step size (see [29]) is $$ \frac{2}{ (b-1) \lambda_{\max}(H) + {\rm tr}(H) }.$$ Thus, when $b$ gets large the step size is significantly smaller for minibatching, and the traversal of the gradient flow is thus slower, but this cannot be seen from the asymptotic limit.
Going beyond #
A common misconception is that SGD with vanishing step size converges to an SDE. It in fact converges to the gradient flow ODE, and the SDE is only a first-order expansion in $\sqrt{\gamma}$ around this gradient flow. The classical asymptotic result presented in this blog post clearly establishes, beyond the usual quadratic case, that SGD has two properties: (1) it forgets initial conditions and (2) oscillates around the optimum. These two effects are characterized by letting the step size $\gamma$ go to zero with the horizon $K$, with $\gamma K$ tending to a constant, thus approximating ODEs and SDEs over a finite interval.
Further insights can be obtained using such asymptotic analyses and limiting ODEs and SDEs:
-
Acceleration [4, 5, 11]: second-order SDEs can then be obtained, using a different time discretization with discrete step $\sqrt{\gamma}$. The bias-variance trade-offs can also be analyzed, in particular the potential noise explosion due to acceleration. A link with first-order gradient flow can also be established through multistep integration schemes [16].
-
Mirror descent [3, 6, 7]: themirror descent recursion also leads to a similar analysis that can highlight the link between the mirror geometry and initialization [12].
-
Continuized analysis [14]: instead of relying on vanishing step sizes, if gradient steps are taken at independent Poisson times, then we obtain a continuous-time Markov jump process that can be analyzed.
-
Performance estimation [15]: for aficionados ofperformance estimation , the framework can be extended to continuous time as well.
References #
[1] Albert Benveniste, Michel Métivier and Pierre Priouret, Adaptive Algorithms and Stochastic Approximations, Stochastic Modelling and Applied Probability, vol. 22, Springer, 1990.
[2] Aad W. van der Vaart. Asymptotic Statistics. Cambridge University Press, 1998. [3] Panayotis Mertikopoulos and Mathias Staudigl. Stochastic mirror descent dynamics and their convergence in monotone variational inequalities. Journal of Optimization Theory and Applications 179.3 (2018): 838-867.
[4] Qianxiao Li, Cheng Tai, and Weinan E. Stochastic Modified Equations and Dynamics of Stochastic Gradient Algorithms I: Mathematical Foundations. Journal of Machine Learning Research, 20(40):1–47, 2019.
[5] Pan Xu, Tianhao Wang, and Quanquan Gu. Continuous and Discrete-time Accelerated Stochastic Mirror Descent for Strongly Convex Functions. International Conference on Machine Learning, 2018.
[6] Pan Xu, Tianhao Wang, and Quanquan Gu. Accelerated Stochastic Mirror Descent: From Continuous-time Dynamics to Discrete-time Algorithms. International Conference on Artificial Intelligence and Statistics, 2018.
[7] Walid Krichene and Peter L. Bartlett. Acceleration and Averaging in Stochastic Descent Dynamics. Advances in Neural Information Processing Systems, 2017.
[8] Harold J. Kushner and Hai Huang. Asymptotic Properties of Stochastic Approximations with Constant Coefficients. SIAM Journal on Control and Optimization, 19(1):87–105, 1981.
[9] William Finnoff. Diffusion Approximations for the Constant Learning Rate Backpropagation Algorithm and Resistence to Local Minima. Advances in Neural Information Processing Systems, 1992.
[10] Qianxiao Li, Cheng Tai, and Weinan E. Stochastic Modified Equations and Adaptive Stochastic Gradient Algorithms. International Conference on Machine Learning, 2017.
[11] Weijie Su, Stephen Boyd, and Emmanuel J. Candès. A Differential Equation for Modeling Nesterov’s Accelerated Gradient Method: Theory and Insights. Journal of Machine Learning Research, 17(153):1–43, 2016.
[12] Belinda Tzen, Anant Raj, Maxim Raginsky, and Francis Bach. Variational Principles for Mirror Descent and Mirror Langevin Dynamics. IEEE Control Systems Letters, 7:1542–1547, 2023.
[13] Adélie Benhaim, Francis Bach, Frederik Kunstner. The Cross-Entropy Gap: Scaling Laws for Sign and Gradient Descent. arXiv:2612.02334, 2026. [14] Mathieu Even, Raphaël Berthier, Francis Bach, Nicolas Flammarion, Pierre Gaillard, Hadrien Hendrikx, Laurent Massoulié, and Adrien Taylor. A Continuized View on Nesterov Acceleration for Stochastic Gradient Descent and Randomized Gossip. Advances in Neural Information Processing Systems, 2021.
[15] Céline Moucer, Adrien Taylor, and Francis Bach. A Systematic Approach to Lyapunov Analyses of Continuous-Time Models in Convex Optimization. SIAM Journal on Optimization, 33(3):1558–1586, 2023.
[16] Damien Scieur, Vincent Roulet, Francis Bach, and Alexandre d’Aspremont. Integration Methods and Optimization Algorithms. Advances in Neural Information Processing Systems, 2017.
[17] Stephan Mandt, Matthew Hoffman, and David Blei. A Variational Analysis of Stochastic Gradient Algorithms. International Conference on Machine Learning, 2016.
[18] Alexandre Défossez and Francis Bach. Averaged Least-Mean-Squares: Bias-Variance Trade-offs and Optimal Sampling Distributions. International Conference on Artificial Intelligence and Statistics, 38:205–213, 2015.
[19] Xavier Fontaine, Valentin De Bortoli, and Alain Durmus. Convergence rates and approximation results for SGD and its continuous-time counterpart. Conference on Learning Theory, 2021.
[20] Ernst Hairer, Syvert P. Nørsett, and Gerhard Wanner. Solving Ordinary Differential Equations I: Nonstiff Problems. Second edition, Springer Series in Computational Mathematics, vol. 8, Springer, 1993.
[21] David Ruppert. Efficient Estimations from a Slowly Convergent Robbins-Monro Process. Technical Report 781, Cornell University, 1988.
[22] Peter E. Kloeden and Eckhard Platen. Numerical Solution of Stochastic Differential Equations. Stochastic Modelling and Applied Probability, vol. 23, Springer, 1992.
[23] Aymeric Dieuleveut, Alain Durmus, and Francis Bach. Bridging the Gap between Constant Step Size Stochastic Gradient Descent and Markov Chains. Annals of Statistics, 48(3):1348-1382, 2020.
[24] Aymeric Dieuleveut, Nicolas Flammarion, and Francis Bach. Harder, Better, Faster, Stronger Convergence Rates for Least-Squares Regression. Journal of Machine Learning Research, 18(101):1-51, 2017.
[25] Waïss Azizian, Franck Iutzeler, Jérôme Malick, Panayotis Mertikopoulos. What is the long-run distribution of stochastic gradient descent? A large deviations analysis. International Conference on Machine Learning, 2024.
[26] Jeremy Cohen, Simran Kaur, Yuanzhi Li, J. Zico Kolter, Ameet Talwalkar. Gradient Descent on Neural Networks Typically Occurs at the Edge of Stability. International Conference on Learning Representations, 2021.
[27] Ziyang Wei, Wanrong Zhu, and Wei Biao Wu. General Weighted Averaging in Stochastic Gradient Descent: CLT and Adaptive Optimality. International Conference on Artificial Intelligence and Statistics, 2026.[ 28] Harold J. Kushner and Hai Huang. On the Weak Convergence of a Sequence of General Stochastic Difference Equations to a Diffusion. SIAM Journal on Applied Mathematics, 40(3):528–541, 1981.
[29] Prateek Jain, Sham M. Kakade, Rahul Kidambi, Praneeth Netrapalli, Aaron Sidford. Parallelizing Stochastic Gradient Descent for Least Squares Regression: Mini-batching, Averaging, and Model Misspecification. Journal of Machine Learning Research, 18(223),1-42, 2018.
[30] Sharan Vaswani, Francis Bach, and Mark Schmidt. Fast and Faster Convergence of SGD for Over-Parameterized Models and an Accelerated Perceptron. International Conference on Artificial Intelligence and Statistics, 2019.
[31] Francis Bach. *[Learning theory from first principles](https://www.di.ens.fr/~fbach/ltfp_book.pdf)*. MIT Press, 2024.
[32] Boris T. Polyak. [A New Method of Stochastic Approximation Type](https://www.mathnet.ru/links/81eb2e23ac402fb7fd74c8540ba4a612/at5521.pdf). *Automation and Remote Control*, 51(7):937–946, 1990.
[33] Boris T. Polyak and Anatoli B. Juditsky. Acceleration of Stochastic Approximation by Averaging. SIAM Journal on Control and Optimization, 30(4):838–855, 1992.
Acknowledgements. AI tools were used for proofreading, generating the figures, and assisting with the proofs below.
Proof for gradient flow approximations #
Convex functions. The argument below is a standard in the analysis of the explicit Euler method; see [20, Section II.3] for the general numerical-ODE framework. Let $T_\gamma(x)=x-\gamma F'(x)$ be the gradient descent recursion operator. For a convex $L$-smooth function and $\gamma L\leqslant 2$, the map $T_\gamma$ is non-expansive, that is, $| T_\gamma(x)-T_\gamma(y)| \leqslant | x, – y|$ for all $x,y$. Define the local discretization error $$ r_k = X_{\gamma k}-T_\gamma(X_{\gamma(k-1)}) = \int_0^\gamma
\left[ F'(X_{\gamma(k-1)}) , – F'(X_{\gamma(k-1)+s}) \right]ds.
$$
Along the gradient flow, $$ \frac{d}{dt}\Big( \frac{1}{2}|F'(X_t)|^2 \Big) = -F'(X_t)^\top F^{\prime \prime}(X_t)F'(X_t) \leqslant 0, $$ so $t\mapsto |F'(X_t)|$ is non-increasing. Therefore, using $L$-Lipschitz-continuity of the gradient $F’$, we get $$
|r_k|
\leqslant
L\int_0^\gamma
|X_{\gamma(k-1)+s}-X_{\gamma(k-1)}|,ds \leqslant
L\int_0^\gamma\int_0^s
|F'(X_{\gamma(k-1)+u})|,du,ds, $$ which leads to $$ |r_k|
\leqslant \frac{L\gamma^2}{2}|F'(x_0)|. $$
Since $x_k=T_\gamma(x_{k-1})$, non-expansiveness gives $$
\|x_k-X_{\gamma k}\| \leqslant \| T_\gamma(x_{k-1})\, – T_\gamma(X_{\gamma(k-1)}) \| +
\| T_\gamma(X_{\gamma(k-1)}) \, – X_{\gamma k}\|,$$ which leads to
$$ \|x_k-X_{\gamma k}\| \leqslant
\|x_{k-1}-X_{\gamma(k-1)}\|
|r_k|.
$$
Summing these inequalities yields $$
\sup_{k\in\{0,\ldots,K\}}
\|x_k-X_{\gamma k}\|
\leqslant \frac{K\gamma^2L}{2}\|F'(x_0)\| = \frac{K(\gamma L)^2}{2}
\frac{\|F'(x_0)\|}{L}.
$$
**Non-convex functions.** Let $T_\gamma(x)=x-\gamma F'(x)$ and define $e_k=x_k-X_{\gamma k}.$ Since $F’$ is $L$-Lipschitz-continuous, without convexity, we can only use, for all $x,y$, $$
\|T_\gamma(x)-T_\gamma(y)\|
\leqslant
|x-y|
\gamma|F'(x)-F'(y)| \
\leqslant
(1+\gamma L)|x-y| \
\leqslant
e^{\gamma L}|x-y|. $$
We first bound the norm of the gradient along the flow. Since $$ X_t-x_0 = -\int_0^t F'(X_s),ds, $$ we have $$
|F'(X_t)| \leqslant
|F'(x_0)| +
L\int_0^t|F'(X_s)|,ds. $$ Gronwall’s inequality therefore gives $|F'(X_t)| \leqslant e^{Lt}|F'(x_0)|.$ Define the local discretization error like in the convex case $$ r_k =X_{\gamma k}-T_\gamma(X_{\gamma(k-1)}) =\int_0^\gamma
\left[ F'(X_{\gamma(k-1)}) , – F'(X_{\gamma(k-1)+s}) \right]ds.
$$
Using the $L$-Lipschitz continuity of $F’$ and the preceding bound, $$ |r_k|
\leqslant
L\int_0^\gamma
|X_{\gamma(k-1)+s}-X_{\gamma(k-1)}|,ds \
\leqslant
L\int_0^\gamma\int_0^s
|F'(X_{\gamma(k-1)+u})|,du,ds, $$ which leads to $$ |r_k|
\leqslant
\frac{L\gamma^2}{2}
e^{L\gamma k}
\|F'(x_0)\|.
$$
Since $x_k=T_\gamma(x_{k-1})$, $$ |e_k|
\leq |T_\gamma(x_{k-1}), – T_\gamma(X_{\gamma(k-1)})| +
|r_k|
\
\leqslant
e^{\gamma L}|e_{k-1}| +
\frac{L\gamma^2}{2}
e^{L\gamma k}
\|F'(x_0)\|.
$$
An induction on $k$ gives (|e_k|
\leqslant k e^{L\gamma k} \frac{L\gamma^2}{2} |F'(x_0)|,) which leads to the desired bound.
Partial proof for gradient flow + tangent SDE approximation #
In order to show that $\frac{x_k- X_{k\gamma} }{\sqrt{\gamma}}$ converges to $U_{\gamma k}$ in distribution, a number of extra assumptions need to be made, and a specific notion of convergence in distribution has to be used. Unfortunately, obtaining a bound in Wasserstein distance is difficult for the full Gaussian approximation (the linear SDE $U$ is a Gaussian process), and authors typically show convergence of expectations of functions $\varphi$ for $\varphi$ from a large class of “regular enough” functions, but not as large as simply Lipschitz-continuous (which would typically lead to a bound in Wasserstein distance).
To obtain a formal result (such as done in [28]), one typically needs regularity assumptions such as $F$ being three-times continuously differentiable, $f'(x,c) – F'(x)$ with uniformly bounded and smooth (with respect to $x$) moments.
The classical proof technique has two parts, and we only give a sketch here in the convex case.
**First part.** The first part is close to the one above and provides an explicit coupling between $x_k$ and $X_{k\gamma} + \sqrt{\gamma} u_k$ with $u_k$ following a time-varying stochastic linear recursion, that is, $u_0 = 0$, and $$ u_k = ( I – \gamma F^{\prime \prime}(X_{(k-1)\gamma}) ) u_{k-1} – \sqrt{\gamma} \big[ f'(X_{(k-1)\gamma},c_k) \, – F'(X_{(k-1)\gamma})\big].$$ The key is to use the same noise as the SGD recursion of $x_k$ (that is, using the same $c_k$), around the corresponding gradient flow iterate.
We thus need to show that $\| x_k – X_{k\gamma} – \sqrt{\gamma} u_k\| $ is small enough. We first show a bound that shows that the gradient flow is close, that is $x_k – X_{k \gamma}$ is small. Reusing notations from the gradient flow proof above, we have: $$x_k = T_{\gamma}( x_{k-1})\, – \gamma \big[ f'( x_{k-1},c_k) \, – F'( x_{k-1})\big], $$ leading to the decomposition $$ \displaystyle x_k-X_{k\gamma}=T_\gamma(x_{k-1})-T_\gamma(X_{(k-1)\gamma})-\gamma[f'(x_{k-1},c_k)-F'(x_{k-1})]-[X_{k\gamma}-T_\gamma(X_{(k-1)\gamma})].$$
From the gradient flow proof above, we have $$ \big\| X_{k\gamma} – T_{\gamma}( X_{(k-1)\gamma}) \big\| \leqslant \frac{L\gamma^2}{2}\|F'(x_0)\|.$$ Moreover $T_\gamma$ is non-expansive. Therefore, using [Minkowski’s inequality](https://en.wikipedia.org/wiki/Minkowski_inequality), $$ \big( \mathbb{E}[ \| x_k – X_{k \gamma} \|^2] \big)^{1/2} \leqslant \big( \mathbb{E}[ \| x_{k-1} – X_{(k-1) \gamma} \|^2] + \gamma^2 \sigma^2 \big)^{1/2} +\frac{L\gamma^2}{2}\|F'(x_0)\|,$$ if $\mathbb{E}[ \| f'(x,c) – F'(x)\|^2 ] \leqslant \sigma^2$ for all $x$. A simple induction on $k$ then leads to $$ \big( \mathbb{E}[ \| x_k – X_{k \gamma} \|^2] \big)^{1/2} \leqslant \frac{\sigma}{L} \gamma L \sqrt{k} + \frac{k L^2\gamma^2}{2}\frac{\|F'(x_0)\|}{L}= \Delta_k.$$ This shows that if $\gamma L k$ is bounded, the gradient flow is within $O(\sqrt{\gamma L})$ of the SGD recursion.
We then need to bound $x_k – X_{k \gamma} – \sqrt{\gamma} u_k$. We have $$ F'(x_{k-1}) – F'(X_{(k-1)\gamma}) = F^{\prime \prime} (X_{(k-1)\gamma}) ( x_{k-1} -X_{(k-1)\gamma} ) + \eta_k,$$ with $| \eta_k | \leqslant \frac{M}{2} | x_{k-1} -X_{(k-1)\gamma}|^2$, if $F^{\prime \prime}$ is $M$-Lipschitz-continuous in operator norm.
With $\delta_k = x_k – X_{k \gamma} – \sqrt{\gamma} u_k$, we then have the decomposition, for $\xi(x,c) = f'(x,c) – F'(x)$, $$\delta_k
= ( I – \gamma F^{\prime\prime}(X_{(k-1)\gamma})) \delta_{k-1} – \gamma \eta_k – \gamma [ \xi(x_{k-1}, c_k) – \xi(X_{(k-1)\gamma},c_k) ] – \big[ X_{k\gamma} – T_{\gamma}( X_{(k-1)\gamma}) \big].$$
We then need to use the assumption that for all $x,y$, $$ \mathbb{E} [ \| \xi(x,c)-\xi(y,c)\|^2] \leqslant N^2 \| x – y \|^2.$$
We can then unroll the recursion above, as $$ \delta_k = -\gamma \sum_{i=1}^k M_{i,k} \eta_i – \gamma \sum_{i=1}^k M_{i,k} [ \xi(x_{i-1}, c_i) – \xi(X_{(i-1)\gamma},c_i) ] – \sum_{i=1}^k M_{i,k} \big[ X_{i\gamma} – T_{\gamma}( X_{(i-1)\gamma}) \big],$$ where $M_{i,k}$ are matrices with operator norms less than one.
For the first term, we have, by using results above, $$ \mathbb{E} \bigg[ \bigg| -\gamma \sum_{i=1}^k M_{i,k} \eta_i \bigg| \bigg] \leqslant \frac{M \gamma k}{2} \Delta_k^2, $$ with a similar result for the third term. For the second term we use martingale calculus to get $$ \mathbb{E} \bigg[ \bigg| \gamma \sum_{i=1}^k M_{i,k} [ \xi(x_{i-1}, c_i) – \xi(X_{(i-1)\gamma},c_i) ] \bigg| \bigg] \leqslant \Big( \gamma^2 N^2 k \Delta_k^2 \Big)^{1/2}.$$ We then have shown that $$ \mathbb{E}[ | \delta_k |] \leqslant \frac{Mk \gamma}{2} \Delta_k^2 + N \gamma \sqrt{k} \Delta_k + \frac{Lk\gamma^2}{2}|F'(x_0)|.$$ If we only keep the dependence on $\gamma L $ and $k$, we get $$ \mathbb{E}[ | \delta_k |] = O \big( (\gamma L)^2 k ( 1 + k \gamma L)^3 \big) = O(\gamma). $$
Second part. This requires a form of central limit theorem for martingales. See [28] and [1, Part II, Chapter 4]. This can also be made quantitative (see [4, 10]). The key thing to notice is that a discretization of the SDE $$ dU_t = -F^{\prime \prime}(X_t) U_t dt + \Sigma(X_t)^{1/2} dB_t $$ is obtained as $$ \tilde{u}k = ( I, – \gamma F^{\prime \prime}(X{(k-1)\gamma}) ) \tilde{u}{k-1} – \sqrt{\gamma} \xi_k,$$ with $\xi_k$ with conditional mean zero and covariance matrix $\Sigma(X{(k-1)\gamma})$. The sequence $u_k$ exactly corresponds to $$\xi_k = f'(X_{(k-1)\gamma},c_k) , – F'(X_{(k-1)\gamma}).$$