CAME: Confidence-guided Adaptive Memory Efficient Optimization

Yang Luo, Xiaozhe Ren, Zangwei Zheng, Zhuo Jiang, Xin Jiang, Yang You · DOI

Abstract

Training Large Language Models (LLMs) is increasingly constrained by hardware memory limits, primarily due to the significant state requirements of adaptive optimizers like Adam. While memory-efficient alternatives such as Adafactor reduce this overhead through matrix factorization, they often suffer from training instability and slower convergence. This paper introduces CAME (Confidence-guided Adaptive Memory Efficient Optimization), a novel optimizer designed to provide the best of both worlds: the low memory footprint of Adafactor and the fast, stable convergence of Adam. By incorporating a confidence-guided mechanism that tracks update instability, CAME achieves state-of-the-art performance while reducing optimizer memory overhead by nearly 50%.

1. Introduction

The primary bottleneck in scaling LLMs is often GPU memory. Standard adaptive optimizers like Adam maintain two states for every parameter: the first moment (momentum) and the second moment (uncentered variance). For massive models, these optimizer states can consume significantly more memory than the model weights themselves, tripling the total memory requirement.

To address this, Adafactor was proposed to compress the second-moment matrix from $O(nm)$ to $O(n+m)$ using Non-negative Matrix Factorization (NMF). However, this compression is lossy. The resulting "rank-1" approximation introduces errors that make training unstable, particularly in large-batch settings. This instability leads to a "performance tax," characterized by slower convergence or lower final model quality compared to Adam. CAME is designed to mitigate these stability issues without sacrificing the memory benefits of factorization.

2. Methodology

CAME builds upon the memory-saving foundations of Adafactor but introduces a "confidence" layer to handle the instability inherent in matrix factorization. The optimizer's logic is defined by three core components:

2.1. Second-Moment Factorization

Following the approach of Adafactor, CAME utilizes NMF to store a compressed version of squared gradients. This keeps the auxiliary memory usage at $O(n+m)$, significantly lower than the $O(nm)$ required by Adam.

2.2. The Instability Matrix ($U_t$)

The core innovation of CAME is the calculation of an instability matrix, $U_t$. This matrix represents the residual difference between the current update and the accumulated momentum. A large residual indicates that the current update is "unstable" or has "low confidence."

2.3. Confidence-Guided Updating

CAME applies NMF to this instability matrix as well. The optimizer then uses this factored information to scale the update dynamically:

  • High Instability: When the residual is high, the optimizer takes a smaller, more cautious step.
  • Low Instability: When the residual is low, the optimizer has high confidence in the update and takes a larger step.

By applying NMF to both the second moments and the instability matrix, CAME maintains minimal memory usage while regaining the training stability lost in previous factored methods.

3. Experimental Evaluation

The authors evaluated CAME across several standard NLP benchmarks and model architectures, including BERT-Large, GPT-2 (Medium), and T5-Base.

3.1. Pre-training and Fine-tuning

Models were pre-trained on BookCorpus and English Wikipedia (3.3B words). Downstream performance was measured using the GLUE benchmark (MNLI, SST-2, MRPC) and SQuAD (v1.1 and v2.0) for reading comprehension.

3.2. Key Results

  • Memory Efficiency: For a BERT model with 4 billion parameters, CAME reduced the optimizer state memory footprint by 47% compared to Adam.
  • Accuracy and Convergence: In BERT-Large pre-training with a 32k batch size, CAME achieved 68.0% accuracy, significantly outperforming Adafactor (61.9%) and matching the performance of the memory-intensive LAMB optimizer. Furthermore, CAME reached target validation accuracy in roughly half the training steps required by Adafactor.
  • Generalization: BERT models pre-trained with CAME showed a 0.5 to 0.7 point improvement in average scores on GLUE tasks compared to the baseline.

4. Discussion

The success of CAME suggests that the performance penalty in memory-efficient optimizers is not merely a result of missing information, but rather the noise introduced by compression. By explicitly modeling this noise as "instability," CAME can counteract it effectively. This is particularly beneficial for large-batch training, which typically exacerbates the errors in adaptive methods.

4.1. Limitations

While CAME offers significant memory savings, calculating the NMF for the instability matrix introduces a slight computational overhead per step. Additionally, the current study is primarily empirical and focused on NLP; further theoretical analysis and testing in domains like Computer Vision (CV) or Reinforcement Learning (RL) are necessary to fully understand the optimizer's generalizability.

5. Conclusion

CAME represents a significant step forward in LLM optimization, successfully bridging the gap between speed and memory efficiency. By using confidence-guided updates to stabilize factored gradients, it allows researchers to train large-scale models with the performance of Adam and the memory footprint of Adafactor.

Summary updated

BibTeX
@inproceedings{luo2023came,
  author = {Yang Luo and Xiaozhe Ren and Zangwei Zheng and Zhuo Jiang and Xin Jiang and Yang You},
  title = {{CAME: Confidence-guided Adaptive Memory Efficient Optimization}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.243},
}
Figure