← All entries
Paper2026#1230

Broken Symmetry in BF16 Attention: Why FlashAttention Gradients Blow Up Late in Training

Summary

Diagnoses a late-training blow-up training a 450M transformer on 50B tokens with FlashAttention-3 in BF16: healthy for 25B tokens, then gradient norm grows 1000x and loss ends 0.2 nats above FP32 attention — with no NaNs at all. Recomputing just two layers' attention backward in FP32 removes almost all excess gradient. Part of the cause is known (a fused multiply-add in the forward softmax, never fixed in FA3); repairing it stops the blow-up but leaves the query gradient wrong by more than its own size (219% median error). The deeper cause is a broken conservation law: the softmax score gradient dS sums to zero along every row, making dQ blind to where the keys sit as a group; rounding dS to BF16 leaves a small nonzero sum that leaks the mean key into dQ — and the leak grows exactly as late training makes keys large and attention sharp. Fix: GProj (gauge projection), which restores the zero row sum after the cast with two rank-one corrections per row — cuts median dQ/dK errors from 219%/13% to 0.34%/0.37% (FP32-attention level) for 4.7% more step time; in matched from-scratch runs it reaches the same loss as FP32 attention while FA3 and key smoothing destabilize. KohakuBlueleaf replied on the thread reporting the same class of precision bug in FA4/cuDNN/flex attention and their KohakuFA fix. If a BF16 run blows up late with no NaNs, check the attention backward. Directly relevant to the user's LLM training-run debugging work.

Venue
arXiv:2609.34272 (cs.LG), submitted 28 Sep 2026
Source
arxiv
Access
free
Language
en
Added
Oct 4, 2026
Verified
Oct 5, 2026
Found via
#random-papers

Tags

flashattentionbf16gradient-stabilityattention-backwardprecisiongprojgauge-projectionkohakufa

Topics

FlashAttention, BF16, numerical precision, gradient stability, attention backward, training-run debugging, KohakuFA

Research notes

  • Discovery: @Chen94751623484 (Junlin Chen, author) X thread 2026-10-04 1:36 AM ET (https://x.com/Chen94751623484/status/2106619462287802663), 13.7K views
  • Rutgers / MBZUAI
  • Code: https://github.com/chenjunlin110/gproj-fa3
  • Related catalog entry: 1526 KohakuFA — 琥珀青葉 (@KBlueleaf) replied on this thread reporting similar backward-precision issues in FA4/cuDNN/flex attention
  • Commentary: @hillbig (Daisuke Okanohara, PFN co-founder/CEO, verified) long Japanese explainer 2026-10-04 6:32 PM ET (https://x.com/hillbig/status/2106875129590698465), 12.8K views, 138 likes, 80 bookmarks — frames the bug as insidious because it is invisible early in training (~25B tokens) and only surfaces once internal states reach a critical regime; emphasizes understanding symmetries/conservation laws in backward passes to distinguish tolerable vs structurally dangerous errors, increasingly important as training moves to FP8/FP4. Note: replier @KBlueleaf linked his own FA4/cuDNN/flex-attention precision repo under this thread.

Similar entries