AdamPM cuts memory use for large language model training
AdamPM: Memory-Efficient LLM Optimization via Moment Pooling
Machine LearningArtificial Intelligence
Summary
Training large language models usually requires a lot of computer memory because of the way the Adam optimizer stores extra information about the model's training steps. The authors propose AdamPM, a version of Adam that saves memory by grouping parts of this stored information together and sharing average values. This change reduces memory needs significantly without slowing down training or hurting the quality of the trained models. AdamPM can be used easily with existing training setups.
What this means in practice
- •For machine learning engineers: Reduce memory requirements during training of large language models without changing model performance or speed.
- •For multimodal ai developers: Train models combining text and images using less memory by adopting memory-efficient optimization.
Authors
Xiaowei Ji, Lishan Xu, Jianing An, Jie Luo, Wenjun Wu, Lei Huang
Abstract
Adam is widely used for training large language models (LLMs) owing to its strong optimization performance and training stability, but its element-wise estimation for the first and second moments incur substantial memory overhead. Although numerous memory-efficient optimizers have been proposed, many incur additional computational overhead or require additional tuning of hyperparameters. Consequently, Adam remains a dominant and reliable choice for LLM pre-training. We propose AdamPM (Adam with Pooled Moments), a simple and memory-efficient variant of Adam that groups adjacent moment entries along the row or column dimension and represents each group by a single shared mean. AdamPM can well inherit Adam's hyperparameter settings and is readily integrated into existing Adam optimizer implementations, with less memory overhead. We systematically investigate pooling of both first and second moment estimates and identify second moment pooling as the effective design. With a group size of $s$, AdamPM reduces second moment memory to $1/s$ of the original requirement. Extensive experiments on language model pretraining, fine-tuning and multimodal learning demonstrate that AdamPM maintains model performance and training speed while substantially reducing optimizer-state memory. Our code is available at \url{https://github.com/jixiaowei95/AdamPM}.