To FP8 and Back Again: Quantifying Reduced Precision Effects on LLM Training Stability

Joonhyung Lee, Jeongin Bae, Byeongwook Kim, Se Jung Kwon, Dongsoo Lee

TL;DR

Training Large Language Models (LLMs) in 8-bit floating-point (FP8) precision promises massive speedups, but it often comes at the cost of catastrophic training failure. This paper introduces a novel loss landscape sharpness metric to quantify this instability and demonstrates that current FP8 methods are highly sensitive to data quality and hyperparameters, potentially negating the cost savings they aim to provide.

What Problem Does This Paper Address?

As LLMs grow, the cost of pretraining becomes astronomical. Researchers have turned to reduced-precision formats like BrainFloat16 (BF16) and, more recently, FP8 to break through the "memory wall"—the bottleneck where moving data from memory to the processor takes longer than the actual computation.

However, reducing bits is a double-edged sword. While FP8 can theoretically double throughput compared to BF16, it is notoriously unstable. If a training run diverges (the "loss" explodes to infinity), the saved compute time is wasted on restarts and hyperparameter tuning. The authors argue that for FP8 to be truly economical, it must be as robust as BF16. Currently, we lack a standard way to quantify this "hidden" instability before a model actually crashes.

Methods

The authors investigate stability through two primary lenses:

  1. Simulated Bit Reduction: Instead of just testing hardware-native FP8, they simulated intermediate precisions (e.g., E8M5, meaning 8 exponent bits and 5 mantissa bits) by masking and clamping bits in a standard Llama-style architecture. This allowed them to pinpoint exactly how removing precision (mantissa) vs. range (exponent) affects the model.
  2. A New Sharpness Metric: Traditional loss landscape visualizations often look smooth even when a model is about to diverge. The authors proposed a new metric, $\phi_\epsilon$, adapted for autoregressive models. Unlike previous metrics that add noise to input images, this metric adds noise to the logit space of the last token. Because the last token in a Transformer "sees" all previous tokens, its logit space is a sensitive proxy for the entire model's state. They use the L-BFGS-B algorithm to find the largest possible loss spike in a small neighborhood around the model's current state.
Figure 2. Loss landscape diagrams for Llama 120M E8M3 at 5K steps (left) and 10K steps (right). Even during loss divergence, the loss landscape visualized using the method in Li et al. (2018) ap- pears smooth, motivating our introduction of a new loss landscape sharpness metric. The validation loss is shown for each point of the loss landscape.

Datasets

The study utilized several key datasets to test how data "cleanliness" impacts stability:

  • FineWeb Edu: A highly filtered, "clean" dataset used for Llama 120M experiments.
  • OpenWebText: A less filtered dataset used for GPT-2 (124M) experiments.
  • SlimPajama & StarCoder: Used for training the TinyLlama (up to 7B) models.

Key Insights and Ideas

  • BF16 is not as stable as we thought: In a surprising finding, the authors discovered that even standard BF16 mixed-precision training had a ~10% divergence rate when tested across 188 different random seeds on a GPT-2 codebase.
  • The "Dirty Data" Trap: FP8 methods that appear stable on "clean" academic datasets (like FineWeb Edu) often fail when exposed to the "dirtier," less-filtered data typically found in production environments.
  • Range > Precision: The model is far more sensitive to the number of exponent bits (which determine the range of numbers representable) than mantissa bits (which determine precision). Removing even one exponent bit (moving from E8 to E7) caused immediate training failure.
  • Sharpness as an Early Warning: The proposed sharpness metric increases steadily as precision is reduced, even if the loss curve itself hasn't diverged yet. This suggests the metric could be used as a "check engine light" for LLM training.
Figure 1. We show an example case of loss divergence on nanoGPT when using the same configurations as the default run except for the random seed. The blue lines indicate the average losses ob- tained for eight training runs that did not diverge. Of the 188 random seeds that were tested, 18 were found to diverge. As full pretraining requires over 4 days on a single node with 8 A100 GPUs, even for BF16, we perform early stopping at 30K steps, or 5% of the original training steps, requiring approximately 4 hours for a BF16 run and 8 hours for a TF32 run per A100 node with 8 GPUs. Because we only run 5% of the original training, we suspect that the measured divergence rate of approximately 10% underestimates the true rate of training loss divergence.

Key Results

  • Divergence Rates: In nanoGPT experiments, 18 out of 188 BF16 runs diverged, while zero TF32 (TensorFloat-32) runs failed. This highlights that even the current "gold standard" (BF16) introduces non-trivial instability compared to higher precision.
  • FP8 vs. BF16 Convergence: Using the MS-AMP library for FP8 training, the authors found that models failed to reach the same final loss as BF16 baselines on "dirty" data, even after 6x more training iterations.
  • Quantifying Instability: For a Llama 7B model, the sharpness metric for E8M3 (3 mantissa bits) was nearly 10x higher (1.927) than for E8M7 (0.215) after 5,000 steps, clearly mapping the relationship between bit-width and landscape volatility.

Limitations and Future Work

  • Early-Stage Focus: The study primarily looks at the first few billion tokens of training. Some instabilities in LLMs are known to emerge only after hundreds of billions of tokens (e.g., the "SwiGLU" instability).
  • Hardware Constraints: The authors were unable to test formats with more than 8 exponent bits (like E11M4) because current GPUs do not support these formats efficiently in hardware, making the training too slow to be practical for research.
  • Downstream Tasks: The evaluation relied on training loss and sharpness rather than downstream task performance (like MMLU scores). While loss divergence is a clear sign of failure, future work could explore how "hidden" instability affects the final model's reasoning capabilities.

Summary updated

BibTeX
@misc{lee2024fp,
  author = {Joonhyung Lee and Jeongin Bae and Byeongwook Kim and Se Jung Kwon and Dongsoo Lee},
  title = {{To FP8 and Back Again: Quantifying Reduced Precision Effects on LLM Training Stability}},
  year = {2024},
  eprint = {2405.18710},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.18710},
}
Figure