Variance Reduction: SVRG & SAGA
Linear convergence for finite sums by correcting the noise.
On a fixed training set, SGD's noise floor is self-inflicted: the full gradient is computable, just expensive. Variance-reduced methods correct each cheap stochastic gradient with stored or periodically refreshed information, so that the noise vanishes at the optimum. The payoff is linear convergence at nearly the per-step cost of SGD, gradient evaluations instead of . This lesson derives SVRG and SAGA, proves SVRG's rate, and asks why methods so effective on convex problems rarely help deep learning.
What you’ll learn
- Explain why constant-step SGD stalls on finite sums, and compare the gradient-evaluation complexity of gradient descent, SGD and variance-reduced methods.
- Derive the SVRG and SAGA estimators as control variates, and prove the bound .
- Prove the linear convergence of SVRG and read off its complexity.
- Compare SAG, SAGA, SDCA and accelerated variants with the lower bounds, and weigh the evidence on deep learning.
The noise floor of a finite sum
Take with every convex and -smooth, -strongly convex, and . At the minimizer , but the individual gradients do not vanish: their spread is positive unless every example is fitted perfectly. That is the variance that keeps constant-step SGD in its noise ball, and that forces decaying steps and sublinear rates.
Gradient descent has no noise but pays gradient evaluations per step. Variance reduction gets the best of both: one or two component gradients per step, and an estimator whose variance goes to zero as the iterates approach .
| Method | Gradient evaluations of the to reach accuracy | Rate type |
|---|---|---|
| Gradient descent | linear, per step | |
| Nesterov's accelerated gradient | linear, per step | |
| SGD, decaying steps and averaging | plus lower-order terms | sublinear, independent of |
| SAG, SAGA, SVRG | linear, per step | |
| Accelerated variance reduction (e.g. Katyusha) | linear, optimal |
examples and . Ignoring constants and the shared factor, how many times fewer component gradients does a variance-reduced method need than gradient descent?
Show the answer
1000 ×
. When the ratio is about : variance reduction pays roughly one pass over the data per "condition number's worth" of progress, instead of passes.
Control variates
Monte Carlo has an old trick for estimating with less noise: find a that is strongly correlated with and whose mean is known, and use . It has the same mean, and variance , small when .
For SGD, with uniform. SVRG (Johnson & Zhang, 2013) takes at a snapshot where the full gradient was computed once. SAGA (Defazio, Bach & Lacoste-Julien, 2014) keeps a table with the last gradient computed for each example, , and takes , whose mean is the table's average:
Lemma. For convex -smooth , . Average over ; the linear terms cancel because :
Split the SVRG estimator around and use :
The second bracket is a random vector minus its mean (), and a variance is at most the second moment. Apply the lemma twice:
Compare SGD, whose second moment at the optimum is . Here it is bounded by suboptimality gaps that shrink to zero: the noise dies out exactly where it used to hurt.
SVRG and its linear rate
SVRG(x̃_0, step η, inner length m)
for s = 1, 2, ...:
x̃ ← x̃_{s-1}; μ̃ ← ∇F(x̃) = (1/n) Σ_i ∇f_i(x̃) # one full pass: n gradients
x_0 ← x̃
for t = 0, ..., m-1:
pick i uniformly from {1..n}
x_{t+1} ← x_t - η (∇f_i(x_t) - ∇f_i(x̃) + μ̃) # 2 gradients
x̃_s ← x_τ for τ uniform in {0, ..., m-1} # "option II"; practice uses x_mNo table of gradients is stored: only the snapshot and its full gradient. The cost of an outer loop is component gradients.
One inner step. Expand the distance, use unbiasedness, convexity () and the variance bound:
Sum over (the distances telescope, and ), dropping the final distance:
Option II makes the sum , and strong convexity gives :
Divide by : the factor is exactly . Iterate over outer loops.
Take and inner steps. What is the contraction factor per outer loop?
Show the answer
0.5
. First term: , using . Second term: . So : each outer loop, costing component gradients, halves the gap. Reaching takes loops, hence in total.
SAG, SAGA and dual methods
SAG (Le Roux, Schmidt & Bach, 2012; journal version Schmidt, Le Roux & Bach, 2017) was the first stochastic method with a linear rate on strongly convex finite sums at SGD's per-step cost. It steps along the average of the stored gradients, refreshing one entry per step, which amounts to using : the correction is damped by . Defazio, Bach & Lacoste-Julien note that, for the same table, SAG's update has the variance of SAGA's, but it is biased. SAGA's unbiased version gives a short proof and better constants.
SAGA's guarantees: with step , contracts by per step (times a constant depending on the start). With the step , which does not need , the factor is : the method adapts to whatever strong convexity is present, and without any it converges at rate for the averaged iterate. A proximal step after each update handles nonsmooth regularizers such as the lasso penalty.
| Method | Extra memory | Gradients per step | Notes |
|---|---|---|---|
| SGD | none | 1 | sublinear on finite sums; simplest |
| SVRG | snapshot and its full gradient, | 2, plus per outer loop | needs and ; loopless variants refresh the snapshot at random |
| SAGA | one gradient per example, | 1 | unbiased; proximal; adapts to |
| SAG | as SAGA | 1 | biased, lower variance |
| SDCA | one dual variable per example | 1 | dual coordinate ascent for regularized ERM (Shalev-Shwartz & Zhang, 2013) |
from sklearn.linear_model import LogisticRegression
# L1-regularized logistic regression solved by SAGA (proximal steps handle the L1 term).
clf = LogisticRegression(penalty="l1", solver="saga", C=1.0, max_iter=1000)
clf.fit(X_train, y_train)Variance-reduced solvers are standard tools for convex empirical risk minimization; scikit-learn offers sag and saga solvers for its linear models.
What distinguishes SAGA's update from SAG's, for the same table of stored gradients?
- SAGA stores fewer gradients
- SAGA's estimator is unbiased; SAG's damps the correction by , which lowers its variance but biases it
- SAG converges linearly and SAGA only sublinearly
- SAGA needs a full gradient at every step
Show the answer
B. SAGA's estimator is unbiased; SAG's damps the correction by , which lowers its variance but biases it
SAGA uses undamped, so its mean is exactly . That makes its analysis short and lets it take proximal steps; SAG trades bias for variance.
Optimality, nonconvexity and deep learning
Acceleration and lower bounds. Katyusha (Allen-Zhu, 2018) combines variance reduction with a Nesterov-type momentum and attains the optimal accelerated rate, . Woodworth & Srebro (2016) proved matching lower bounds for randomized methods that access the components' gradients: for smooth finite sums, an accelerated variant of SVRG is optimal. When , the term dominates: about passes over the data suffice, close to the least one could hope for.
Nonconvex finite sums. Variance reduction also helps without convexity. SPIDER (Fang, Li, Lin & Zhang, 2018) finds an -stationary point with stochastic gradient evaluations, nearly matching the lower bound under averaged smoothness, against for SGD (Convergence of SGD).
Key takeaways
- On a finite sum, SGD's gradient noise does not vanish at the optimum (), so constant steps stall and decaying steps are sublinear.
- SVRG and SAGA are control variates: . They are unbiased, with for SVRG.
- SVRG contracts the gap by per outer loop; , give and gradient evaluations, versus for gradient descent.
- SAGA is unbiased, proximal and adaptive to ; SAG is biased with lower variance; accelerated variants reach the optimal .
- On large deep networks, variance reduction has so far not helped: iterates decorrelate from the snapshot, augmentation breaks the finite-sum structure, and statistical accuracy is reached first.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
On a strongly convex finite sum, why does SVRG with a constant step converge linearly, while constant-step SGD stalls in a noise ball?
- SVRG uses a larger step size
- SVRG computes the full gradient at every step
- The variance of SVRG's estimator is bounded by suboptimality gaps that shrink to zero, whereas SGD's variance at the optimum is
- SVRG is a second-order method
Show the answer
C. The variance of SVRG's estimator is bounded by suboptimality gaps that shrink to zero, whereas SGD's variance at the optimum is
, which vanishes at the optimum. With no persistent noise, a constant step gives a geometric contraction, as for gradient descent.
One outer loop of SVRG with inner steps costs how many component-gradient evaluations?
Show the answer
C.
for the snapshot's full gradient, then two per inner step ( and , unless the latter are stored). With and a constant contraction per loop, the total is .
According to Defazio & Bottou (2019), what is the main reason SVRG fails to reduce gradient variance when training large modern networks?
- Deep networks are nonconvex, so the variance bound is false
- Within an epoch the iterates move far from the snapshot, so the stored and current gradients decorrelate
- The full gradient is too expensive to compute even once per epoch
- Batch normalization makes the gradients exactly zero
Show the answer
B. Within an epoch the iterates move far from the snapshot, so the stored and current gradients decorrelate
A control variate helps only while and are strongly correlated. In large networks trained with practical step sizes they decorrelate quickly, and even more frequent snapshots did not rescue the large models.
Further reading
- M. Schmidt, N. Le Roux & F. Bach, "Minimizing finite sums with the stochastic average gradient," Mathematical Programming 162(1–2), 83–112 (2017).
- R. Johnson & T. Zhang, "Accelerating stochastic gradient descent using predictive variance reduction," Advances in Neural Information Processing Systems 26 (2013).
- A. Defazio, F. Bach & S. Lacoste-Julien, "SAGA: a fast incremental gradient method with support for non-strongly convex composite objectives," Advances in Neural Information Processing Systems 27 (2014).
- A. Defazio & L. Bottou, "On the ineffectiveness of variance reduced optimization for deep learning," Advances in Neural Information Processing Systems 32 (2019).
- R. M. Gower, M. Schmidt, F. Bach & P. Richtárik, "Variance-reduced methods for machine learning," Proceedings of the IEEE 108(11), 1968–1983 (2020).