Abstract
In this paper, we explore FP8 low-bit data formats for efficient training of large language models (LLMs). Our key insight is that most variables, such as gradients and optimizer states, in LLM training can employ low-precision data formats without compromising model accuracy and requiring no changes to hyper-parameters. Specifically, we propose a new FP8 automatic mixed-precision framework for training LLMs. This framework offers three levels of FP8 utilization to streamline mixed-precision and distributed parallel training for LLMs. Experiment results show that, during the training of GPT-175B model on H100 GPU platform, our FP8 mixed-precision training framework not only achieved a remarkable 42% reduction in real memory usage but also ran 64% faster than the widely adopted BF16 framework (i.e., Megatron-LM), surpassing the speed of Nvidia Transformer Engine by 17%.
Introduction: The Challenge of Scaling LLM Training
Training state-of-the-art Large Language Models (LLMs) like GPT-3 or PaLM is prohibitively expensive, requiring thousands of high-end GPUs and massive amounts of energy. While the industry has moved from 32-bit (FP32) to 16-bit (FP16/BF16) precision to save costs, the jump to 8-bit (FP8) has historically been "brittle."
FP8 has a much narrower dynamic range and lower precision than BF16, which often leads to training instability—numerical issues like overflows or underflows that cause the model to fail to learn. Previous solutions, like Nvidia’s Transformer Engine, only used FP8 for specific matrix multiplications (GEMM), leaving significant memory and communication efficiency on the table. FP8-LM aims to integrate FP8 into the entire training process: gradients, optimizer states, and distributed communication.
The FP8-LM Framework
The researchers from Microsoft introduced FP8-LM, a framework built on three core innovations to stabilize and optimize 8-bit training:
- Precision Decoupling: Not all variables are equally sensitive to precision. While master weights and second-order optimizer moments require 16-bit precision, gradients and first-order moments can thrive in FP8. This allows for significant memory reduction without sacrificing the fine-grained updates necessary for convergence.
- Automatic Scaling: To prevent data loss from the narrow FP8 range, an auto-scaling factor ($\mu$) adjusts on the fly. It decreases if values overflow and increases if they underflow.
- FP8 Distributed Parallelism: The framework extends FP8 to distributed strategies like Tensor, Pipeline, and Sequence parallelism. It also redesigns the ZeRO optimizer to handle FP8 tensors and their scaling factors using a "Greedy Distribution Algorithm" to balance memory across the cluster.
Experimental Validation
The framework was validated using a massive pre-training corpus and several fine-tuning benchmarks:
- Pre-training: A 100-billion token subset of a diverse collection including CommonCrawl, C4, and Wikipedia.
- Fine-tuning: Instruction-following data from ShareGPT and human preference data for RLHF using AlpacaFarm and Anthropic’s datasets.
- Evaluation: Models were tested on zero-shot tasks (HellaSwag, Lambada) and compared against Davinci-003 using AlpacaEval and MT-Bench.
Performance and Accuracy
Benchmarks on Nvidia H100 GPUs show dramatic improvements over the industry-standard Megatron-LM (BF16):
- Throughput: For a GPT-175B model, FP8-LM is 75% faster than the BF16 baseline and 37% faster than Nvidia’s Transformer Engine.
- Memory Efficiency: Real memory usage was reduced by 39% for the 175B model. This allows for training significantly larger models on the same hardware footprint.
- Accuracy: Across models from 7B to 175B parameters, training loss curves for FP8 and BF16 are virtually identical, with no significant degradation in zero-shot performance.
Conclusion
FP8-LM demonstrates that the "direction" of gradients is more critical than exact magnitude for optimizer convergence, allowing first-order moments to be compressed to 8 bits. By moving to FP8 for "all-reduce" operations, communication overhead is reduced by up to 65%. As a drop-in replacement requiring no hyperparameter changes, FP8-LM offers a practical path to reducing the immense costs of foundation model training.
The FP8-LM framework is open-sourced at aka.ms/MS.AMP.
Summary updated