TL;DR
In low-precision training (like FP8), the choice of which version of a tensor the backward pass reads—the original, the rounded forward value, or a new random rounding—is not just a memory optimization; it is a fundamental part of the learning algorithm. The authors show that making the wrong choice, such as reusing a forward rounding that the incoming gradient depends on, can lead to training divergence, even if the saved copy is highly "accurate."
What Problem Does This Paper Address?
As Large Language Models (LLMs) scale, training in low-precision formats like FP8 and 4-bit has become standard to save memory and compute. During the forward pass, tensors are rounded before being consumed by operations. The backward pass often needs to read these same tensors to compute gradients.
Currently, developers treat the decision of what to save for the backward pass (e.g., via FlashAttention or activation compression) as a low-level implementation detail settled by two checks: "Is the copy accurate?" and "Does the final loss look okay?"
The authors argue this is insufficient. They demonstrate that a "backward-state policy"—the specific choice of which tensor version each gradient use reads—can fundamentally change the gradient the model follows. A policy that seems accurate can still be "wrong" relative to the intended learning algorithm, leading to subtle biases or catastrophic training failure.
Methods
The authors introduce a formal framework to evaluate these policies:
- The Reference Gradient: They define a reference based on the "straight-through convention": the gradient of the forward pass as it actually ran, with gradients passed through rounding operations unchanged.
- Per-Use Requirements: Instead of a global policy for a tensor, they derive requirements for each specific use of that tensor in the backward pass. For example, a normalization layer's output might feed two different gradient calculations that each require a different version of that output to remain unbiased.
- Executable Checker: They developed a tool that tests backward-state policies against these requirements on single operators (like attention or log-softmax) without needing a full training run.
- Controlled Experiments: They conducted training runs (390M and 1.5B parameters) using emulated FP8 and stochastic rounding to isolate the effects of reusing forward roundings versus using new, independent random roundings from the same distribution.
Datasets
The models were trained and evaluated using:
- FineWeb-Edu: A 10-billion-token sample used for the primary LLM training experiments.
- Custom Synthetic Tests: Small-scale finite cases used for the executable checker to verify operator-level requirements.
Key Insights and Ideas
- One Tensor, Two Needs: A single tensor can feed multiple gradients that have conflicting requirements. In a normalization layer, the gradient for the gain needs the original unrounded value, while the gradient for the weights of the next layer needs the rounded value that the layer actually multiplied. No single shared substitute can be "right" for both.
- The Danger of Reuse: Reusing the exact rounded value from the forward pass is often the "most accurate" copy, but it can be the most dangerous. Because the loss (and thus the incoming gradient) already "saw" that specific rounding error, a dependency is created. This coupling prevents the error from averaging out, leading to biased gradients.
- Independence Over Accuracy: Surprisingly, a new random rounding—which is less "accurate" to the specific forward pass than the forward's own rounding—is often better because its error is independent of the incoming gradient, allowing the gradient to remain unbiased on average.
- Loss is a Blunt Instrument: Comparable final loss does not prove a policy is correct. The authors show that models can adapt to incorrect policies by shifting weights (e.g., changing the mean gain), effectively running a different, unintended learning algorithm.
Key Results
- Fixing FP8 Attention: In 390M parameter runs, NVIDIA’s Transformer Engine FP8 attention failed across all seeds. By replacing only the attention backward with a BF16 version (which recomputes values more accurately), the failure was completely removed while keeping the FP8 forward pass.
- Predictive Power: The authors' per-use requirements successfully predicted whether reuse would change the average gradient in three different software stacks: PyTorch checkpointing, log-softmax, and Transformer Engine’s fused attention kernels. Every prediction held true.
- Scaling: The findings were consistent across 390M and 1.5B parameter models, suggesting these issues are inherent to the math of low-precision training rather than specific model sizes.
Limitations and Future Work
- Straight-Through Reference: The entire framework relies on the straight-through convention as the "correct" reference. While standard, other gradient estimation techniques might imply different requirements.
- Implementation Complexity: Currently, most deep learning frameworks don't allow developers to easily specify different versions of a tensor for different uses in the backward pass. The authors suggest that future implementations should make these choices explicit.
- Scope: The study focuses heavily on attention and normalization. While these are critical for LLMs, the implications for other architectural components (like MoE routers or complex skip connections) remain to be fully explored.
Summary updated