Memory Efficient Optimizers with 4-bit States

Bingrui Li, Jianfei Chen, Jun Zhu

Abstract

The memory requirements for training large-scale neural networks are dominated not just by model parameters, but by the states maintained by optimizers. While 8-bit quantization has become a standard for reducing this footprint, pushing to 4-bit precision has historically resulted in significant training instability and accuracy degradation. This paper introduces a framework for 4-bit optimizers that achieves lossless accuracy compared to full-precision counterparts. By implementing smaller block sizes for the first moment, Rank-1 normalization for the second moment, and a novel linear quantization strategy that excludes zero, we reduce optimizer memory overhead by up to 57.7%. These optimizations enable the training of models up to four times larger on the same hardware constraints.

Introduction

In the era of Large Language Models (LLMs), the primary bottleneck for training is often GPU memory. While model weights (parameters) are the most visible component, popular optimizers like AdamW maintain additional "states"—specifically the first moment (momentum) and the second moment (uncentered variance)—for every parameter. In standard 32-bit precision, these states consume three times as much memory as the weights themselves.

Previous research successfully compressed these states to 8-bit precision (e.g., Bitsandbytes), but 4-bit quantization remained elusive due to catastrophic training failures. This work identifies the root causes of these failures—specifically the "zero-point problem" and the complex distribution of outliers—and provides the engineering solutions necessary to make 4-bit optimizers a viable reality for production-scale training.

Overcoming the Challenges of 4-bit Quantization

Transitioning from 8-bit to 4-bit precision is not a simple matter of reducing bit-depth; it requires addressing three fundamental issues in how optimizer states behave during training.

1. Managing Localized Outliers

Optimizer states exhibit highly localized and heterogeneous outliers that vary across layers and training stages. Standard quantization methods use large "block sizes" (e.g., 2048) to normalize values. However, the authors found that these large blocks fail to capture the variance of optimizer outliers. By shrinking the block size to 128 for the first moment, the quantizer can more accurately "wrap" around these outliers, preserving critical information that would otherwise be lost to rounding errors.

2. Rank-1 Normalization for the Second Moment

For the second moment (variance), outliers often persist along specific rows or columns of a parameter matrix. To address this, the researchers proposed "Rank-1 normalization." Instead of simple block-wise scaling, this method utilizes both row-wise and column-wise statistics to normalize the tensor. This provides a tighter bound and higher precision, ensuring that the second moment remains stable even at 4-bit depth.

3. The Zero-Point Problem

In weight or activation quantization, representing "zero" is essential. However, in the context of Adam-based optimizers, zero is effectively "poison." Because the update rule involves dividing by the square root of the second moment ($1/\sqrt{v}$), quantizing a tiny non-zero value to zero causes the update to explode toward infinity. The authors solved this by implementing a linear quantizer that explicitly excludes zero from its representable values, ensuring that the denominator in the update equation never collapses.

Experimental Results

The 4-bit optimizers were evaluated across a diverse suite of benchmarks to ensure generalizability across architectures and tasks.

Performance and Accuracy

Across Natural Language Understanding (RoBERTa-Large on GLUE), Question Answering (SQuAD), Machine Translation (WMT14), and Image Classification (Swin-Transformer), the 4-bit AdamW optimizer achieved results comparable to the 32-bit baseline. Notably, in fine-tuning LLaMA-7B on the Alpaca dataset, the 4-bit version matched the full-precision loss curve almost perfectly, demonstrating that the compression is virtually lossless.

Memory Efficiency and Scaling

The practical impact of these savings is substantial. For a LLaMA-7B model, total training memory was reduced from 75.40 GB to 31.88 GB—a 57.7% reduction. This efficiency allows a single 80GB GPU to fine-tune models that previously required multi-GPU setups or aggressive offloading to CPU memory. Effectively, this technology enables researchers to train models four times larger than previously possible on the same hardware budget.

Conclusion and Future Work

4-bit optimizers represent a significant milestone in democratizing LLM training. By identifying the unique requirements of optimizer state distributions—specifically the need to avoid zero and manage localized outliers—this work provides a path toward significantly more efficient training pipelines.

Future work will focus on developing optimized CUDA kernels to reduce the dequantization overhead, which currently limits speed gains on smaller models. Additionally, extending these methods to other domains such as Reinforcement Learning and Graph Neural Networks will be essential to confirming the universal applicability of 4-bit optimizer states.

Summary updated

BibTeX
@inproceedings{li2023memory,
  author = {Bingrui Li and Jianfei Chen and Jun Zhu},
  title = {{Memory Efficient Optimizers with 4-bit States}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=nN8TnHB5nw},
}
Figure