MicroAdam: Accurate Adaptive Optimization with Low Space Overhead and Provable Convergence

Ionut-Vlad Modoranu, Mher Safaryan, Grigory Malinovsky, Eldar Kurtic, Thomas Robert, Peter Richtarik, Dan Alistarh

TL;DR

MicroAdam is a memory-efficient variant of the Adam optimizer that reduces optimizer state memory by up to 50% compared to 8-bit Adam while maintaining full accuracy and rigorous theoretical convergence guarantees. It achieves this by combining aggressive gradient sparsification with a novel, compressed error feedback mechanism that ensures the optimization trajectory stays on track.

What Problem Does This Paper Address?

Training and fine-tuning Large Language Models (LLMs) is notoriously memory-intensive. While model weights themselves are large, the optimizer states are often the silent killers of GPU memory. The standard Adam optimizer stores two additional values for every single model parameter: the first moment (momentum) and the second moment (uncentered variance).

For a model like Llama-2 7B, these states alone can consume over 50 GB of memory in full precision. Even popular "8-bit Adam" implementations, which quantize these states, still require significant overhead. Other memory-saving techniques often rely on heuristics that lack theoretical "proof" of convergence or can lead to degraded model performance. The authors of MicroAdam set out to create an optimizer that is both extremely lean and mathematically sound.

Methods

MicroAdam introduces a "compress-then-correct" approach to optimization:

  1. Top-K Sparsification: Instead of feeding dense gradients into the optimizer, MicroAdam uses a Top-K operator to keep only the most significant values (typically just the top 1%).
  2. Compressed Error Feedback (EF): To prevent the loss of information from the 99% of discarded gradient entries, the algorithm uses "error feedback." It stores the difference between the actual gradient and the compressed one, adding it back into the next step's gradient.
  3. The "Secret Sauce" - Quantized EF: Normally, an error buffer would take up as much space as the original optimizer state, defeating the purpose. MicroAdam's key innovation is showing that the error buffer itself can be compressed (quantized to 4 bits per component) without hurting convergence.
  4. Sliding Window Statistics: Rather than storing momentum and variance directly, MicroAdam maintains a "sliding window" of the last few sparse gradients and recomputes the necessary Adam statistics on the fly, further saving space.
Figure 1: Optimization trajectories of Adam, TopK-Adam and TopK-Adam with EF applied on the Rosenbrock function f(x, y) = (1 −x)2 + 100(y −x2)2 starting from (x0, y0) = (−1

Datasets

The researchers validated MicroAdam across a wide range of models and tasks:

  • Language Models: BERT-Base/Large (110M/335M parameters), OPT-1.3B, and Llama-2 7B/13B.
  • Benchmarks: GLUE/MNLI (general language understanding), GSM8k (grade-school math reasoning), and Open-Platypus (instruction tuning).
  • Computer Vision: ResNet-18 and ResNet-50 trained on the ImageNet dataset.

Key Insights and Ideas

  • Error Feedback is Essential: Without error feedback, sparse optimizers produce "jagged" trajectories and often fail to converge. EF acts as a corrective force that recovers the "true" optimization path (see Figure 1 above).
  • Are all gradient entries important? The paper suggests that for fine-tuning, they aren't—provided you track the cumulative error. Updating only 1% of weights at each step is sufficient for high-quality results.
  • Implicit Regularization: Interestingly, MicroAdam's sparse updates seem to provide a form of implicit regularization. In computer vision tasks (ResNet on ImageNet), MicroAdam actually outperformed standard SGD by about 2% in validation accuracy, likely because the sparse updates prevent overfitting.
  • Theoretical Parity: Unlike many heuristic optimizers, MicroAdam is proven to converge at the same rate as AMSGrad (a theoretically robust version of Adam).

Key Results

MicroAdam consistently matches or beats the accuracy of full-precision Adam while using significantly less memory:

  • Memory Savings: For a Llama-2 7B model, MicroAdam's optimizer state uses only 5.65 GB, compared to 12.55 GB for 8-bit Adam and a staggering 50.21 GB for standard AdamW-32.
  • Accuracy Gains: On the challenging GSM8k math dataset, MicroAdam (with a window size of 20) achieved 35.10% accuracy, slightly outperforming the standard Adam baseline of 34.50%.
  • Superiority over Heuristics: MicroAdam provided better accuracy than other high-compression methods like GaLore and CAME across almost all tested benchmarks, while maintaining similar or better memory footprints.
  • Efficiency: Despite the extra steps for compression and quantization, MicroAdam's GPU-aware implementation results in running times similar to uncompressed Adam.

Limitations and Future Work

  • LLM Pre-training: The authors noted that MicroAdam struggled to match Adam's performance during from-scratch pre-training of LLMs. They hypothesize that attention layers require dense updates to learn complex word correlations early in training.
  • Sparsity vs. Low-Rank: The current practical implementation focuses on sparsity (Top-K). While the theory supports low-rank projections (like those used in GaLore), a high-performance implementation for that case is left for future work.
  • Hyperparameter Sensitivity: While MicroAdam is robust, the "window size" ($m$) and "density" ($k$) are new knobs that users might need to tune for specific, novel architectures.

Summary updated

BibTeX
@inproceedings{modoranu2024microadam,
  author = {Ionut-Vlad Modoranu and Mher Safaryan and Grigory Malinovsky and Eldar Kurtic and Thomas Robert and Peter Richtarik and Dan Alistarh},
  title = {{MicroAdam: Accurate Adaptive Optimization with Low Space Overhead and Provable Convergence}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=Tck41RANGK},
}
Figure