TL;DR
Shampoo is an optimizer for training neural networks. It keeps one small preconditioning matrix for each dimension of each weight tensor, rather than one number per weight or one huge matrix over all weights. Each step multiplies the gradient by these matrices on its left and right. The result approximates the full-matrix AdaGrad step at a memory and computation cost much lower than full-matrix AdaGrad, and in most of the paper's experiments each step took about as long as an SGD, Adam or AdaGrad step.
Builds on: AdaGrad, Preconditioning, Tensor Product, Shampoo Optimizer · Leads to: later optimizers that precondition whole weight matrices with structured factors
Why it mattered
The paper gave a practical method, with a proof, for getting something close to full-matrix AdaGrad. Diagonal AdaGrad and Adam are used everywhere, but they ignore correlations between parameters. Full-matrix AdaGrad captures those correlations, but its preconditioner for a layer with weights is , which is far too large for real models.
Shampoo's claim is that a layer's weights already have structure. A fully connected layer is an matrix, and a convolution filter is a four-dimensional tensor. Keeping one matrix per dimension captures much of the useful correlation while staying cheap. The paper's experiments trained a 32-layer residual network on CIFAR-10, a 55-layer residual network on CIFAR-100, and an attention model on the LM1B language benchmark, all with Shampoo as a drop-in optimizer.
By late 2026 the paper had about 700 citations on OpenAlex.
The problem
Stochastic gradient descent (Stochastic Gradient Descent) uses the same step size in every direction. A parameter that receives large gradients and one that receives tiny gradients both move at the same scale unless the step size is tuned by hand.
Preconditioning fixes this by transforming the gradient before the step (Preconditioning). The ideal preconditioner is the matrix that gives each direction the right scale. Newton's method uses the Hessian (Hessian Matrix), which is too costly to form for deep networks. AdaGrad (AdaGrad) accumulates the sum of squared gradients over all past steps. Its full-matrix version uses the sum of outer products of gradients. That matrix captures correlations, but it has to be stored and inverted, with memory and computation that grow with the square of the number of weights.
The problem the paper solves is: how to keep most of the benefit of full-matrix AdaGrad while storing and inverting only matrices of the size of the layer's dimensions.
How it works
Take a single weight matrix of size , for example a fully connected layer. Trace one training step with as the initial value of the accumulators.
- Start with two accumulators. Keep , an matrix, and , an matrix. Both start as times the identity. Check: they are small, numbers in total, not .
- Compute the gradient. On a mini-batch, compute the gradient , an matrix with one entry per weight. Check: has the same shape as .
- Update the accumulators. Add to , an matrix that records how the rows of the gradient vary together. Add to , which does the same for the columns. Check: both are sums of outer products, so they stay symmetric and positive semidefinite.
- Precondition from both sides. Compute and , the inverse fourth roots, and form . The left factor mixes the rows of and the right factor mixes its columns. Check: the result has the same shape as .
- Take the step. Set , with learning rate . Check: a direction with a long history of large gradients is shrunk on both sides, which is the AdaGrad effect in a structured form.
For a tensor with dimensions, there is one accumulator per dimension, and the exponent is instead of . For a convolution filter with four dimensions, each mode gets its own matrix raised to the power .
Two practical details from the paper. The inverse roots are only recomputed every 20 to 100 steps, which the authors report had almost no effect on accuracy and saved time. Momentum (Momentum), an average of past gradients with factor 0.9, is added to the step as in many other first-order methods.
The math
Given gradients of an weight matrix, the accumulators are
and the update is
Here for a symmetric positive semidefinite matrix means the matrix with the same eigenvectors and each eigenvalue raised to the power . is the identity matrix.
Step 3 in symbols: the accumulators
The term is an matrix whose entry is the dot product of rows and of . So records how the rows of the gradient have moved together over time, and does the same for the columns.
Step 4 in symbols: the two-sided preconditioner
The flattened gradient is an -vector. Using the Kronecker product identity from the paper's Lemma 4, the two-sided step is exactly a single preconditioned step on the flattened gradient with preconditioner
This is why the method is "full-matrix AdaGrad-like": the full preconditioner is never formed, but its action is computed through the two small matrices.
Step 5 in symbols: why the exponent is one quarter
The paper's Lemma 8 shows that the Kronecker product is an upper bound on the full-matrix AdaGrad accumulator, up to the rank factor (for gradients of rank at most ). The full AdaGrad step uses the square root of that accumulator, so uses the fourth roots of and to match it. The paper also notes that the fourth root gives an overall step-size decay of order , a decay rate common in stochastic optimization methods.
The regret bound
Under the online convex optimization framework, Theorem 7 bounds the regret after rounds, for gradients of rank at most and a bounded distance from the comparison point :
Each trace grows like under standard assumptions on the gradients, so the bound grows like , the rate that the paper's bound achieves for convex online problems.
Worked examples
Take , , , and a gradient .
- Update the accumulators. , and equals the same matrix.
- Take the inverse fourth roots. The entry for the first diagonal entry of each, and for the second.
- Multiply . The only nonzero entry is , which is .
- Update. .
Interpretation: the gradient entry of was shrunk to on its way into the weights. A step on a weight that had seen no gradient yet would have been larger.
Continue the previous example with a second identical gradient, , and .
- Update the accumulators. , and is the same.
- Take the roots. .
- Multiply. The first entry is , which is .
- Update. The second step is instead of .
Interpretation: as the same direction keeps receiving gradient, its step shrinks, following . This is the AdaGrad behaviour, carried out with two small matrices.
Take a fully connected layer with , so it has weights.
- Full-matrix AdaGrad needs a preconditioner of size , which has entries.
- Shampoo needs and , with entries in total.
- The ratio is about to one in favour of Shampoo.
Try it: a layer with and has weights. Compute and state whether it is smaller than the weights themselves. Answer: , which is about eight times the weights. For this shape Shampoo's accumulators are larger than the layer, so the paper's diagonal fallback for oversized dimensions matters in practice.
Results
The paper trained with mini-batches of 128, and for CIFAR it tuned each optimizer over 10 learning rates between 0.01 and 10.0 (scaled for Adam). Reported results:
- CIFAR-10, 32-layer residual network (2.4M parameters): error 5 percent on the test set. Figure 2 shows the training loss.
- CIFAR-10, 20-layer small Inception network (1.65M parameters): error 7.5 percent.
- CIFAR-100, 55-layer residual network without batch normalization (13.5M parameters): error 24 percent. Its largest layer is a tensor, which is four-dimensional.
- LM1B, Attention model (9.8M parameters): the paper reports test log-perplexity curves in Figure 4. Shampoo used its default learning rate of 1.0, and the other optimizers were run at several learning rates.
Speed was measured in steps per second on a Tesla K40 GPU (Table 1):
| Dataset | SGD | Adam | AdaGrad | Shampoo |
|---|---|---|---|---|
| CIFAR-10 (ResNet-32) | 2.184 | 2.184 | 2.197 | 2.151 |
| CIFAR-10 (Inception) | 3.638 | 3.667 | 3.682 | 3.506 |
| CIFAR-100 (ResNet-55) | 1.210 | 1.203 | 1.210 | 1.249 |
| LM1B (Attention) | 4.919 | 4.871 | 4.908 | 3.509 |
What this means: Shampoo does more work per step, yet on the two CIFAR-10 models it is only about 2 to 5 percent slower in steps per second than the others. On CIFAR-100 it is the fastest of the four. On the language model it completes about 30 percent fewer steps per second than the others, a bigger gap than the other settings.
The limits matter. The convergence guarantee is for convex problems, while the neural network experiments are not convex. The speed table counts steps per second on one GPU type, not wall-clock time to a target accuracy, so it does not show which optimizer reaches a given accuracy first. The method also changes its behaviour for very large dimensions, where it falls back to a diagonal preconditioner.
Reading guide
Read the paper in this order:
- Abstract and Section 1. Needs AdaGrad and Preconditioning. Figure 1 shows the three-dimensional tensor case.
- Section 1.1, the matrix case. Needs Tensor Product for the Kronecker product, and the update in Algorithm 1 matches the walkthrough above.
- Section 2. Needs Singular Value Decomposition (SVD) for the matrix powers, Matrix Square Root for the square-root identity, and the online convex optimization framework. The regret definition is in Section 2.1.
- Section 3, the matrix analysis. Uses the Kronecker identities of Lemmas 3 and 4 from Section 2.3. Lemma 8 is the key step; skim its proof on first reading.
- Section 4, the tensor algorithm. Needs the same ideas applied to each mode.
- Section 5, implementation. Plain engineering: the diagonal fallback for dimensions above about 1200.
- Section 6, experiments. Needs Convolutional Neural Network for the CIFAR models and Learning Rate for the tuning protocol.
Check yourself
QuestionShampoo keeps an matrix and an matrix . For a weight matrix with and , how many accumulator entries does it store, and how many would full-matrix AdaGrad need for the same layer?Show answer
Shampoo stores entries. Full-matrix AdaGrad flattens the weights, so its preconditioner has entries.
QuestionWith , a gradient and , compute the first entry of the step , to three decimals.Show answer
, and is the same. The first entry of is . The step's first entry is . This equals , to three decimals .
QuestionWhy does Shampoo use the fourth root of each accumulator instead of the square root, as AdaGrad does?Show answer
The product is the preconditioner, and the Kronecker product of the two square roots, , is what matches the full-matrix AdaGrad accumulator in the paper's Lemma 8. Splitting the power equally between the two sides gives each. It also gives the overall step-size decay of order needed for the regret bound.
QuestionA team wants to use Shampoo on a 4-dimensional convolution tensor of size . Which exponent does each mode's accumulator use, and what does the paper's diagonal fallback do?Show answer
For an order- tensor with , the exponent is on each mode's matrix. The diagonal fallback applies when one dimension is too large for its matrix to be stored or for its SVD to be computed, as set by a threshold of about 1200 in the paper. That dimension then uses a diagonal preconditioner, and the other dimensions still use full matrices.
Sources
- Gupta, Koren and Singer, "Shampoo: Preconditioned Stochastic Tensor Optimization", arXiv:1802.09568, 2018. https://arxiv.org/abs/1802.09568
- Digital object identifier for the same paper: https://doi.org/10.48550/arXiv.1802.09568