FP8 Formats for Deep Learning

Paulius Micikevicius, Dusan Stosic, Neil Burgess, Marius Cornea, Pradeep Dubey, Richard Grisenthwaite, Sangwon Ha, Alexander Heinecke, Patrick Judd, John Kamalu, Naveen Mellempudi, Stuart F. Oberman, Mohammad Shoeybi, Michael Y. Siu, Hao WuarXiv 2022 · DOI

Abstract

As neural networks scale to hundreds of billions of parameters, the computational and memory requirements for training have become significant bottlenecks. This paper proposes a standardized 8-bit floating point (FP8) format designed to accelerate deep learning while maintaining model accuracy. By employing a hybrid approach with two distinct encodings—E4M3 for precision and E5M2 for dynamic range—we demonstrate that 8-bit training can match the performance of 16-bit sessions across a wide range of models, including Large Language Models (LLMs) with up to 175 billion parameters.

Introduction

The transition from 32-bit (FP32) to 16-bit (FP16 or bfloat16) precision was a landmark achievement that enabled the current era of large-scale deep learning. However, the search for further efficiency has led to the exploration of 8-bit formats. While 8-bit integers (INT8) are widely used for inference, they often lack the necessary dynamic range and precision for the delicate gradients and weight updates required during training. This work introduces a flexible FP8 framework that addresses these challenges.

Proposed FP8 Formats

We propose a hybrid approach using two different FP8 encodings tailored to specific needs within the network:

  1. E4M3 (4-bit exponent, 3-bit mantissa): Optimized for weights and activations, this format provides higher precision. To maximize its utility, we deviate from IEEE 754 standards by reclaiming bit patterns typically reserved for infinities, thereby extending the representable range to ±448.
  2. E5M2 (5-bit exponent, 2-bit mantissa): Optimized for gradients, this format offers a wider dynamic range (similar to FP16) to accommodate the small and volatile nature of gradient values, albeit at the cost of some precision.
Table 1: Technical specifications of the proposed E4M3 and E5M2 FP8 formats.

Training Methodology

To effectively utilize the narrow 8-bit window, we employ per-tensor scaling factors to shift data into the representable range before casting to FP8. Additionally, we found that saturating values—clipping them to the maximum representable value rather than zeroing them out—is essential for maintaining training stability when values exceed the format's range.

Evaluation and Results

The proposed FP8 formats were evaluated across a diverse set of industry-standard benchmarks, including computer vision (ImageNet), language translation (WMT16), and large-scale language modeling.

Computer Vision and Translation

Testing across 13 different CNN and Transformer architectures, including ResNet, VGG, and Vision Transformers (DeiT), showed that the Top-1 accuracy gap between FP16 and FP8 was typically within 0.1% to 0.3%. Similar parity was achieved in language translation tasks using GNMT and Transformer models.

Large Language Models (LLMs)

The scalability of FP8 was rigorously tested on GPT-style models ranging from 126 million to 175 billion parameters. As illustrated in Figure 1, the training loss (perplexity) curves for FP8 are virtually indistinguishable from the bfloat16 baselines, confirming that FP8 can support the training of the world's largest models without loss of quality.

Figure 1: Training loss curves for GPT models (126M to 175B parameters) comparing BF16/FP16 and FP8 formats.

Conclusion

FP8 represents a new frontier for scaling deep learning. Our results show that it matches 16-bit performance across a wide array of tasks and model sizes. Furthermore, FP8's non-linear sampling of the real number line makes it superior to INT8 for post-training quantization. While these experiments utilized software simulation, the integration of native FP8 support in next-generation hardware will unlock significant speedups and memory savings for the entire deep learning ecosystem.

Summary updated

BibTeX
@misc{micikevicius2022fp,
  author = {Paulius Micikevicius and Dusan Stosic and Neil Burgess and Marius Cornea and Pradeep Dubey and Richard Grisenthwaite and Sangwon Ha and Alexander Heinecke and Patrick Judd and John Kamalu and Naveen Mellempudi and Stuart F. Oberman and Mohammad Shoeybi and Michael Y. Siu and Hao Wu},
  title = {{FP8 Formats for Deep Learning}},
  year = {2022},
  eprint = {2209.05433},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2209.05433},
}
Figure