Scalable Second-Order Optimization: Shampoo at Scale

AI Post Transformers · episode companion visualization
arXiv:2002.09018 Rohan Anil, Vineet Gupta, Tomer Koren, Kevin Regan, Yoram Singer · 2020 Google Research

The Optimizer Lineage

First-order methods only ever see the gradient. Second-order methods bring in curvature — but the exact form is too expensive to use at scale. Shampoo's whole story is finding a tractable approximation to that curvature.

Cost Scaling: Why Full-Matrix Methods Die at Scale

For N parameters, a full preconditioner (Hessian or full-matrix AdaGrad) costs O(N²) to store and O(N³) to invert. Shampoo's Kronecker factoring collapses this back toward the per-dimension sizes.

Diagonal (Adam / AdaGrad) Full-Matrix (Newton / full AdaGrad) Kronecker-Factored (Shampoo)

Preconditioner Shape: Diagonal vs Full vs Factored

A diagonal preconditioner (Adam) can only stretch each coordinate independently. A full-matrix preconditioner can also rotate — capturing correlation between parameters. Hover any cell to inspect it.

Kronecker Factorization

Instead of one N×N monster, Shampoo keeps one small matrix per tensor dimension — L for rows, R for columns — and approximates the full preconditioner as their Kronecker product L ⊗ R.

Factored-Method Family

Shampoo isn't alone in this game. K-FAC factors the Fisher information matrix; K-BFGS factors the Hessian directly. All three only get head-to-head tested at toy scale in this paper.

Shampoo vs Well-Tuned Adam/LAMB Baselines

Real convergence gains across four production-scale workloads — but wall-clock savings only materialize where the systems engineering caught up, as BERT-Large shows.

80.56%
DLRM/Criteo AUC (new SOTA)
45%
WMT'14 Base wall-time cut
4%
BERT-Large wall-time (asterisk)

Toy-Scale Comparison: Shampoo vs K-FAC vs K-BFGS

The only head-to-head second-order comparison in the paper — MNIST / FACES / CURVES autoencoders, tens of thousands of parameters. All three factored methods cluster together, well ahead of RMSprop/Adam.

The Extra Cost of Shampoo (Per Step)

Three extra chunks of work versus Adam. The inverse fourth-root computation is the killer — up to 100× the cost of a normal step, and it must run in double precision because L and R are badly ill-conditioned.

Async Pipelining: Hiding the 100× Cost

The loss landscape doesn't shift much step to step, so the inverse root is only recomputed every few hundred steps — and it's offloaded to idle CPUs running alongside the accelerator, computed asynchronously and swapped in when ready.

References