Broken Symmetry in BF16 Attention: Why FlashAttention Gradients Blow Up Late in Training
Abstract
BF16 is now standard in large-scale pretraining, including in fused attention kernels such as FlashAttention, and these kernels are widely trusted. When we used FlashAttention-3 to pretrain a 450M-parameter transformer on 50B tokens, however, we ran into a problem: training was healthy for 25B tokens, then the gradient norm grew a thousandfold and the loss ended 0.2 nats above FP32 attention, without a single NaN. Recomputing the attention backward of just two layers in FP32 removes almost all of the excess gradient. Part of the cause is known: a fused multiply-add in the forward softmax, so far treated as an extreme-input NaN case and never fixed in FlashAttention-3. Repairing it stops the blow-up, but the query gradient is still wrong by more than its own size, and training still drives attention logits to thousands of times their size under accurate gradients. The remaining error comes from a broken conservation law. The softmax score gradient sums to zero along every row, which makes the query gradient blind to where the keys sit as a group; rounding it to BF16 leaves a small nonzero sum that leaks the mean key into the gradient, and the leak grows exactly as late training makes keys large and attention sharp. We introduce GProj (gauge projection), which restores the zero sum after the cast with two rank-one corrections per row. It cuts the remaining median query/key gradient errors from 219%/13% to 0.34%/0.37%, on par with FP32 attention, for 4.7% more time per training step. In matched from-scratch runs it trains to the same loss as FP32 attention, while FlashAttention-3 and key smoothing both destabilize.
Related
- FlashAttention-Compatible Modality-Mutual Attention with Virtual Reordering
- Unbiased Gradients, Moving Stability Boundaries: Exact Mini-Batch Geometry in Linear Self-Attention
- Convergent Stochastic Training of Multi-Headed Attention and Understanding LoRA
- LampAttention: Look-Ahead Mixed-Precision FlashAttention for Dedicated Accelerators
- Local Shellings of Broken-Circuit Complexes via Boundary States and the Chromatic Specialization of the Negami Polynomial
BibTeX
@misc{chen2026broken,
title = {{Broken Symmetry in BF16 Attention: Why FlashAttention Gradients Blow Up Late in Training}},
author = {Junlin Chen and Daize Dong and Huanwei Di and Haolong Jia and Jiawei Wu and Haotian Xie and Mingkai Zheng and Yang Li and Leshang Chen and Huishu Wang and Eric P. Xing and Hongyi Wang},
howpublished = {arXiv},
year = {2026},
month = sep,
doi = {10.48550/arxiv.2609.34272},
eprint = {2609.34272},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2609.34272},
}
RIS
TY - UNPB
TI - Broken Symmetry in BF16 Attention: Why FlashAttention Gradients Blow Up Late in Training
AU - Junlin Chen
AU - Daize Dong
AU - Huanwei Di
AU - Haolong Jia
AU - Jiawei Wu
AU - Haotian Xie
AU - Mingkai Zheng
AU - Yang Li
AU - Leshang Chen
AU - Huishu Wang
AU - Eric P. Xing
AU - Hongyi Wang
PY - 2026
DA - 2026/09/28
PB - arXiv
DO - 10.48550/arxiv.2609.34272
UR - https://arxiv.org/abs/2609.34272
AB - BF16 is now standard in large-scale pretraining, including in fused attention kernels such as FlashAttention, and these kernels are widely trusted. When we used FlashAttention-3 to pretrain a 450M-parameter transformer on 50B tokens, however, we ran into a problem: training was healthy for 25B tokens, then the gradient norm grew a thousandfold and the loss ended 0.2 nats above FP32 attention, without a single NaN. Recomputing the attention backward of just two layers in FP32 removes almost all of the excess gradient. Part of the cause is known: a fused multiply-add in the forward softmax, so far treated as an extreme-input NaN case and never fixed in FlashAttention-3. Repairing it stops the blow-up, but the query gradient is still wrong by more than its own size, and training still drives attention logits to thousands of times their size under accurate gradients. The remaining error comes from a broken conservation law. The softmax score gradient sums to zero along every row, which makes the query gradient blind to where the keys sit as a group; rounding it to BF16 leaves a small nonzero sum that leaks the mean key into the gradient, and the leak grows exactly as late training makes keys large and attention sharp. We introduce GProj (gauge projection), which restores the zero sum after the cast with two rank-one corrections per row. It cuts the remaining median query/key gradient errors from 219%/13% to 0.34%/0.37%, on par with FP32 attention, for 4.7% more time per training step. In matched from-scratch runs it trains to the same loss as FP32 attention, while FlashAttention-3 and key smoothing both destabilize.
ER -