NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sketchy: Memory-efficient Adaptive Regularization with Frequent Directions

Vladimir Feinberg, Xinyi Chen, Y. Jennifer Sun, Rohan Anil, Elad Hazan

TL;DR

"Sketchy" is a novel framework that makes powerful second-order optimization methods (like Shampoo) memory-efficient enough for massive deep learning models. By leveraging a deterministic matrix sketching technique called "Frequent Directions," the authors reduce the memory footprint of tracking gradient correlations from quadratic to sub-linear, all without sacrificing model performance.

The Memory-Quality Tradeoff in Optimization

Most deep learning models today are trained using Adam, a "first-order" optimizer. Adam is ubiquitous because it is highly memory-efficient: it only tracks the "diagonal" of the gradient covariance, essentially treating every parameter as if it evolves independently.

However, parameters in neural networks are highly correlated. "Second-order" methods like Shampoo or Full-matrix AdaGrad exploit these correlations to converge faster and often reach better solutions. The primary barrier to their widespread adoption is memory. For a model like ResNet-50, storing the full gradient covariance matrix would require over 2 petabytes of RAM. Even "factored" methods like Shampoo, which use Kronecker products to save space, frequently run out of memory (OOM) on the large rectangular layers common in modern Transformer architectures.

The paper addresses this critical bottleneck: How can we capture the rich correlation information of second-order methods without the prohibitive memory costs?

Methods: Enter "Sketchy"

The authors introduce Sketchy, which integrates the Frequent Directions (FD) sketch into adaptive regularization to drastically reduce memory requirements.

Memory footprint comparison of various optimizers
  1. Frequent Directions (FD): This deterministic sketching algorithm acts like a "streaming PCA." It maintains a low-rank approximation of the covariance matrix by keeping only the top $k$ eigenvectors and discarding the rest.
  2. Compensating for "Escaped Mass": A key theoretical contribution is how the authors handle the discarded information. Instead of simply throwing away the smaller eigenvalues, they track the "cumulative escaped mass" (the sum of discarded eigenvalues) and add it back as a dynamic diagonal regularization term. This ensures the optimizer remains stable and maintains theoretical "regret" guarantees.
  3. S-AdaGrad & S-Shampoo: The authors apply this sketching logic to create "Sketchy" versions of standard optimizers. In S-Shampoo, they sketch the left and right Kronecker factors of the gradient, achieving sub-linear memory scaling for large layers.

Key Insights

  • The "Low-Rank" Nature of Gradients: The authors found that in real-world deep learning training, gradient covariance matrices exhibit "fast spectral decay." This means most of the important information is concentrated in a tiny fraction of the eigenvalues. The "intrinsic dimension" is often 10x smaller than the actual number of parameters.
  • Sub-linear Memory is Possible: By focusing only on the top eigenspace, Sketchy achieves memory usage that is sub-linear relative to the number of parameters. For example, they achieved a 4x memory saving for Shampoo blocks of size 1024.
  • Pareto Improvement: Unlike previous sub-linear methods (like SM3 or AdaFactor) which often sacrifice quality for memory, Sketchy demonstrates a "Pareto improvement"—it matches the quality of full-memory Shampoo while using significantly less RAM.

Empirical Results

The authors evaluated Sketchy across three diverse deep learning tasks: ImageNet v2 (ResNet-50), Librispeech (16-layer Conformer), and OGBG-MolPCBA (Graph Neural Network).

Training curves comparing Adam, Shampoo, and S-Shampoo across three tasks
  • Competitive Performance: S-Shampoo matched or exceeded the performance of both Adam and the full-memory Shampoo across all three benchmarks.
  • Efficiency & Accuracy: On ImageNet, S-Shampoo reached a final validation accuracy of 77.18%, outperforming Adam (76.76%) and nearly matching the full Shampoo (77.69%), all while using a fraction of the memory for second-moment tracking.
  • Stability: In the GNN task, S-Shampoo was actually less susceptible to overfitting than Adam.

Limitations and Future Work

While Sketchy significantly saves memory, the current implementation relies on Singular Value Decomposition (SVD) for the sketching step, which introduces computational overhead. To maintain training speed, the authors currently update the sketch only every 10 steps.

Future work could explore faster, "accelerator-friendly" routines like Lanczos or LOBPCG to reduce this overhead, potentially allowing for more frequent updates and even higher quality optimization. Additionally, further tuning of the rank hyperparameter $k$ could yield even better memory-quality tradeoffs in hardware-constrained environments.

Summary updated

BibTeX
@inproceedings{feinberg2023sketchy,
  author = {Vladimir Feinberg and Xinyi Chen and Y. Jennifer Sun and Rohan Anil and Elad Hazan},
  title = {{Sketchy: Memory-efficient Adaptive Regularization with Frequent Directions}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=DeZst6dKyi},
}
Figure