Convergence of SGD
Robbins–Monro conditions, step-size schedules and averaging.
Stochastic approximation is older than machine learning, and its theory is sharp: we know which step sizes converge, at what rates, and that no method using noisy gradients can do better. This lesson proves almost-sure convergence under the Robbins–Monro conditions, the optimal rates for convex and strongly convex problems, why the right average of the iterates matters, the rate for nonconvex problems, and the lower bounds that make all of these rates optimal.
What you’ll learn
- Prove almost-sure convergence of SGD on strongly convex problems under the Robbins–Monro conditions, using the Robbins–Siegmund lemma.
- Prove the rate of averaged SGD on convex problems, and explain how step sizes and averaging interact.
- Prove for the step , and explain why uniform averaging loses a factor and how suffix or weighted averaging recovers .
- State Polyak–Ruppert averaging, the guarantee for smooth nonconvex problems, and the lower bounds that match them.
Stochastic approximation and almost-sure convergence
The model. Minimize over a closed convex set (possibly all of ). At step an oracle returns a random with , an unbiased (sub)gradient given the past , and SGD moves to , where is the Euclidean projection. Empirical risk with uniform sampling and single-pass learning on fresh data are both instances.
Robbins & Monro (1951) introduced the method to find a root of a function observed only through noise, under the step conditions and , and proved that the iterates converge in probability. Almost-sure convergence followed soon after (Blum, 1954), and Robbins & Siegmund (1971) distilled the supermartingale argument behind such proofs into a lemma.
Expand the squared distance after one step and take the conditional expectation:
Strong convexity and give ; insert the moment bound:
This is the Robbins–Siegmund form with , , ; the condition makes and finite. So almost surely, and:
Because , a convergent forces . A convergent sequence with zero has limit zero.
The two conditions play exactly the roles the proof shows: caps the total injected noise, and keeps enough "drift" to reach the optimum from anywhere. The moment condition matters in practice: for least squares the gradient grows linearly with , so a uniform bound cannot hold on all of , and analyses that assume one implicitly project onto a bounded set.
Convex problems: the 1/√T rate
Expand the distance as before, take expectations, and use convexity, (any subgradient works):
Sum over ; the distances telescope and the last one is dropped:
Jensen's inequality moves the average inside . Balancing the two terms gives :
Three things to notice. First, the rate does not depend on the dimension, nor on whether the gradients are exact: noisy SGD matches the deterministic subgradient method, and no method can do better in the worst case. Agarwal, Bartlett, Ravikumar & Wainwright (2012) proved information-theoretic lower bounds of order for stochastic convex Lipschitz problems, matching the classical of Nemirovski & Yudin for this class (Lower Bounds & Oracle Complexity).
Second, the step must know , or must decay like ; with decaying steps the same telescoping needs a bounded domain (projection onto a set of diameter ) and gives . Third, the average is what is guaranteed. Shamir & Zhang (2013) showed the last iterate is within , a logarithm worse.
Averaged SGD on a convex Lipschitz problem reaches after steps, with the optimally tuned constant step. Roughly how many steps does the bound need for ?
Show the answer
B.
The bound scales like , so each tenfold improvement in accuracy costs a hundredfold more steps: complexity. That is the price of noise (and of nonsmoothness), and it cannot be avoided in the worst case.
Strongly convex problems: 1/T, and which average
Projection onto does not increase distances. With and strong convexity, , the usual expansion gives
Base. Strong convexity and optimality of give , and , so every point has :
Step (). If , the recursion gives the bound below, and is equivalent to , which always holds:
For -smooth (with ), turns the distance bound into the value bound.
Which iterate to return matters when is not smooth. Averaging all iterates is natural, but Rakhlin, Shamir & Sridharan showed that for nonsmooth strongly convex problems it can be stuck at , and that averaging only the last iterates (-suffix averaging) restores . Lacoste-Julien, Schmidt & Bach (2012) gave a simpler fix: steps and weights proportional to yield , computable on the fly. The last iterate itself is within (Shamir & Zhang, 2013), and Harvey, Liaw, Plan & Randhawa (2019) showed that for nonsmooth strongly convex functions this logarithm is genuinely there with these steps, even for gradient descent without noise. The rate is optimal: no stochastic first-order method beats it in the worst case (Agarwal et al., 2012).
On without noise, the steps give , so decays like when . In the example above (, ), what is the exponent ?
Show the answer
0.2
, so . The rate is tied to the product of the curvature and the step constant: the "optimal" schedule is only optimal if its constant is at least about .
Averaging, smooth problems and nonconvexity
is the best asymptotic covariance any estimator built from samples can have here: it is the "sandwich" covariance of the empirical risk minimizer on samples, which for a well-specified likelihood is the inverse Fisher information (Cramér–Rao). Without averaging, SGD reaches it only with the matrix step , which requires knowing . Averaging long, noisy steps gets it for free, with no tuning of : the theoretical justification for robust stochastic approximation. Bach & Moulines (2013) pushed this further: for least squares, averaged SGD with a constant step achieves an rate after samples without any strong convexity.
Smooth nonconvex problems. Without convexity the target is a point with a small gradient. Repeating the noise-ball argument of the Descent lesson without the Polyak–Łojasiewicz step gives the following guarantee, in the spirit of Ghadimi & Lan (2013), who analyzed SGD that returns a randomly chosen iterate.
Let be -smooth with , and the gradients unbiased with variance at most . For a constant , the smoothness expansion gives, in expectation,
Sum over and divide by . Returning a uniformly random iterate turns the average into an expectation:
Choose to balance the terms:
To make , the noise term needs : the price of noise is , against for exact gradients.
This is unimprovable. Arjevani, Carmon, Duchi, Foster, Srebro & Woodworth (2023) proved that any algorithm with access to unbiased, bounded-variance stochastic gradients of smooth functions needs order queries to find an -stationary point in the worst case, so SGD is minimax optimal in this model. Under the stronger assumption that each stochastic gradient is itself Lipschitz on average (mean-squared smoothness), is achievable and optimal, by the variance-reduction methods of Variance Reduction: SVRG & SAGA.
The complete picture and the frontier
| Setting (stochastic first-order oracle) | Achieved by | Rate or complexity | Lower bound |
|---|---|---|---|
| convex, , | averaged SGD, | ||
| -strongly convex, | SGD with and suffix or weighted averaging | ||
| smooth, strongly convex, local asymptotics | Polyak–Ruppert averaging | covariance | statistical (Cramér–Rao) |
| smooth nonconvex, variance | SGD, random iterate | for | |
| nonconvex, mean-squared smooth | recursive variance reduction |
Key takeaways
- Robbins–Monro: and , with the Robbins–Siegmund lemma, give almost-sure convergence on strongly convex problems; the first condition supplies drift, the second caps the noise.
- Convex problems with : averaged SGD with gets , which is optimal; the last iterate pays an extra .
- Strongly convex problems: gives ; with nonsmooth , use suffix or -weighted averaging to get . Underestimating the step constant can make it collapse to .
- Polyak–Ruppert averaging of slowly decaying steps attains the optimal asymptotic covariance without knowing or .
- For smooth nonconvex , SGD finds in steps, and that is optimal for bounded-variance oracles.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the almost-sure convergence proof, what does the condition guarantee?
- That the iterates move far enough to reach the optimum from any start
- That the total noise injected, the terms, is finite, so the Robbins–Siegmund lemma applies
- That the gradient is bounded
- That the function is strongly convex
Show the answer
B. That the total noise injected, the terms, is finite, so the Robbins–Siegmund lemma applies
Both perturbation terms in are proportional to ; summability makes converge. The other condition, , then forces the limit to be zero.
SGD with runs on a nonsmooth, -strongly convex problem. Which output has an guarantee in expectation?
- The uniform average of all iterates
- The average of the last half of the iterates
- The first iterate
- Only the last iterate
Show the answer
B. The average of the last half of the iterates
-suffix averaging (here ) gives (Rakhlin, Shamir & Sridharan, 2012). The uniform average is dragged down by the early, poor iterates and can be stuck at ; the last iterate carries a factor too.
With unbiased, bounded-variance stochastic gradients of a smooth nonconvex function, how many stochastic gradients does SGD need, in the worst case, to find a point with , and can another algorithm do better in that model?
- , and no one can do better
- , and acceleration improves it to
- , and is a lower bound for every algorithm in that model
- It cannot find such a point in finite time
Show the answer
C. , and is a lower bound for every algorithm in that model
The bound needs , and Arjevani et al. (2023) showed a matching lower bound. Only stronger assumptions (mean-squared smoothness) allow .
Further reading
- H. Robbins & S. Monro, "A stochastic approximation method," Annals of Mathematical Statistics 22(3), 400–407 (1951).
- B. T. Polyak & A. B. Juditsky, "Acceleration of stochastic approximation by averaging," SIAM Journal on Control and Optimization 30(4), 838–855 (1992).
- A. Nemirovski, A. Juditsky, G. Lan & A. Shapiro, "Robust stochastic approximation approach to stochastic programming," SIAM Journal on Optimization 19(4), 1574–1609 (2009).
- A. Rakhlin, O. Shamir & K. Sridharan, "Making gradient descent optimal for strongly convex stochastic optimization," Proceedings of the 29th ICML (2012); corrected version arXiv:1109.5647.
- S. Ghadimi & G. Lan, "Stochastic first- and zeroth-order methods for nonconvex stochastic programming," SIAM Journal on Optimization 23(4), 2341–2368 (2013).