More Bits Won't Fix It: Diagnosing and Treating an Ill-Conditioned Backward Pass (A Case Study on Gemma-4)
Authors: Jeong Hyun Lee
Organizations: Department of Radiology and Center for Imaging Science, Samsung Medical Center, Sungkyunkwan University School of Medicine, 81 Irwon-ro, Gangnam-gu, Seoul 06351, Republic of Korea
During LoRA fine-tuning of Gemma-4 (12B and 31B) on long prompts, whether they contain CT images, natural photos, or about 2,000 tokens of text, bf16 and fp32 gradients agree in the upper third of the language model (cosine similarity 0.96 or above) but are nearly orthogonal in the lower third. On image prompts, we trace the effect to an ill-conditioned backward path. The fp32 gradient is unchanged by element-wise relative noise of 10−6 on hidden states, confirming that fp32 is a valid reference. At 10−4, however, its cosine similarity with the noise-free gradient falls below 0.9 in 7 of 10 measurements, whereas bf16 forward states differ from fp32 states by about 1% per token. State swaps and backward-only interventions localize this sensitivity in Gemma-4-12B to the MLPs of layers 19-21 at image-token positions, where the gradient can be dominated by a single low-information patch. Detaching that path in the backward pass (while leaving the forward pass unchanged) keeps the gradient stable at 10−4 (cosine similarity 0.97 or above across all five measurements), lowers the median pre-clipping gradient norm from 8.5 to 0.63, and improves validation loss on a CT lesion-grounding task from 0.336 ± 0.019 to 0.296 ± 0.003 (four seeds; every modified run beats every baseline run). The gain disappears when the lower layers are frozen, and an fp32 run still exhibits gradient spikes (maximum norm 39,862) and fails to match this improvement. These training results cover one task and one model.
Figures & tables
Figure 1: Agreement between bf16 and fp32 LoRA gradients by depth. Thin lines represent individual prompts and bold lines show medians; each block spans one-sixth of the language-model layers. Short text prompts contain 200–350 tokens, and long text prompts about 2,200. The Gemma-4-12B panels use full-precision weights; the others use 4-bit NF4 weights [6] with bf16 or fp32 arithmetic (Appendix A). “SFT task” uses the training prompts from §5.
Figure 2: (a) Cosine similarity between the lowest-block fp32 gradient with and without element-wise relative noise σ applied to every layer output (five image prompts, Gemma-4-12B). Each point is compared against its own noise-free gradient (standard or detached). The final column compares bf16 with fp32; “Detach” refers to the intervention in §4–5. (b) Cosine similarity between bf16 and fp32 gradients at each layer’s output (10 image prompts and 11 short text-only prompts).
Backward pass
bf16 states in
Agreement
Gain
Standard
layers 12–14 or 15–18
0.99 and 0.93 (medians)
21 [11, 206]
Standard
layers 19–21
0.07 [−0.24, 0.75]
21 [11, 206]
MLP output detached, image tokens, L19–21
all layers
0.94 [0.69, 0.98]
6.8 [4.8, 8.9]
Gate activation detached, image tokens, L19–21
all layers
0.86 [0.56, 0.97]
7.1 [6.0, 9.1]
Up-projection detached, image tokens, L19–21
all layers
0.27 [0.07, 0.86]
21 [10, 145]
Table 1: Sensitivity of the backward map from layer 21 to layer 11 to bf16 forward states (Gemma-4-12B, 5 image prompts; median [min, max]). Agreement is the cosine similarity between J T g evaluated at fp32 states and at states where the listed layers use bf16 values. Gain is the ratio of the norm of J T g to the norm of g at fp32 states. Full table in Appendix F.
Figure 3: Training Gemma-4-12B on CT lesion grounding. (a) Validation NLL on 80 held-out lesions from 80 scans not seen during training; every run starts at 0.653. (b) Global gradient norm before clipping (log scale).
Arm
Val. NLL
Center error (voxels)
In box
Median grad. norm
Max grad. norm
Standard
0.336 ± 0.019
16.3 ± 2.1
75% ± 10
8.5
23,307
Frozen below layer 19
0.334 ± 0.003
16.0 ± 0.4
74% ± 4
0.73
100
Detach + Frozen
0.336 ± 0.002
17.0 ± 0.5
71% ± 3
0.46
25
Standard, fp32
0.332
16.2
81%
7.7
39,862
Detach
0.296 ± 0.003
10.8 ± 0.5
88% ± 2
0.63
125
Table 2: Results after 300 steps (mean ± s.d. over four seeds; single seed for fp32). “In box” denotes the fraction of predictions whose center falls inside the ground-truth box, evaluated with greedy decoding on 80 validation examples.
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
Image prompt
bf16
σ = 10 −7 , seed 1
σ = 10 −7 , seed 2
σ = 3×10 −7 , seed 1
σ = 3×10 −7 , seed 2
σ = 10 −5
Prompt 1
−0.02
−0.99
−0.97
−0.66
+0.99
−0.60
Prompt 2
+0.37
+1.00
+1.00
+0.05
+0.07
+0.34
Prompt 3
+0.01
+0.91
+0.99
+0.65
+0.92
+0.19
Prompt 4
−0.07
+0.92
−0.41
+0.23
−0.41
−0.20
Prompt 5
−0.20
+0.86
+0.83
+0.88
+0.92
+0.47
Appendix
Table 3: Cosine between the lowest-block (layers 0–11) gradient under RMS-scaled noise and the plain fp32 gradient , Gemma-4-12B, image prompts. Two noise seeds for σ = 10 −7 and 3×10 −7 . The bf16 column compares bf16 with fp32.
Direction
Image prompt
η = 10 −6
η = 10 −5
η = 3×10 −5
η = 10 −4
η = 3×10 −4
η = 10 −3
fp32
Prompt 1
+0.68
+0.42
+0.20
+0.09
+0.01
+0.02
fp32
Prompt 2
+0.24
+0.87
+0.89
+1.16
+0.91
+0.61
fp32
Prompt 3
+0.44
+0.84
+0.89
+0.77
−0.02
+0.44
fp32
Prompt 4
+0.84
+0.33
+0.33
−0.36
−0.18
−0.06
fp32
Prompt 5
+0.65
+1.18
+1.20
+0.18
+0.45
+0.06
bf16
Prompt 1
+0.64
−0.05
−0.03
+0.10
+0.61
+0.20
Appendix
Table 4: Ratio of actual to predicted loss decrease along the lowest-block gradient direction (loss evaluated in fp32; one row per prompt). “Detach” rows use the gradient computed with the detach of §5 and its own norm for the prediction; the loss is the unmodified one.
Quantity
Prompt 1
Prompt 2
Prompt 3
Prompt 4
Prompt 5
Standard, σ = 10 −7
+1.00 / +1.00
+1.00 / +1.00
+1.00 / +1.00
+1.00 / +1.00
+1.00 / +1.00
Standard, σ = 10 −6
+1.00
+1.00
+1.00
+1.00
+1.00
Standard, σ = 10 −5
+1.00 / +1.00
+1.00 / +1.00
+0.99 / +1.00
+1.00 / +0.23
+0.86 / +0.97
Standard, σ = 10 −4
+0.84 / +0.97
+0.38 / +0.96
+0.62 / +0.96
+0.35 / +0.80
+0.70 / −0.38
Standard, σ = 10 −3
+0.06 / +1.00
−0.01 / +0.56
+0.23 / −0.04
−0.74 / −0.35
−0.57 / +0.30
Standard, σ = 3×10 −3
+0.05
+0.05
+0.56
−0.08
−0.50
Appendix
Table 5: Lowest-block gradient under element-wise noise, with and without the detach (Gemma-4-12B, image prompts, same numbering as Table 3). Noise rows give the cosine between the fp32 gradient with noise and without; two values are two noise seeds. The last rows compare bf16 with fp32 and give gradient norms in fp32.
Arm
Seed
Val. NLL
Center error, mean
Center error, median
In box
Median grad. norm
Max grad. norm
Standard
0
0.364
19.1
13.0
60%
7.62
23,307
Standard
1
0.320
14.1
6.7
84%
8.63
2,370
Standard
2
0.327
16.2
8.2
78%
7.61
1,346
Standard
3
0.334
15.6
8.1
78%
11.11
18,326
Detach
0
0.298
11.3
4.1
89%
0.63
26
Detach
1
0.291
10.2
4.1
88%
0.57
15
Appendix
Table 6: Final results of every run. Seeds are LoRA initialization seeds; the data order is the same in all runs.
Backward pass
bf16 states in
Agreement
Gain
Standard
layers 12–14
0.99 [0.96, 1.00]
21 [11, 206]
Standard
layers 15–18
0.93 [0.79, 1.00]
21 [11, 206]
Standard
layers 19–21
0.07 [−0.24, 0.75]
21 [11, 206]
Standard
all layers
0.16 [−0.25, 0.75]
21 [11, 206]
MLP output detached, image tokens, L19–21
all layers
0.94 [0.69, 0.98]
6.8 [4.8, 8.9]
Gate activation detached, image tokens, L19–21
all layers
0.86 [0.56, 0.97]
7.1 [6.0, 9.1]
Appendix
Table 7: Full version of Table 1.
MLP output zeroed at
In
Val. NLL
Change
Examples that get worse
Nothing (base model)
0.653
image tokens
layers 19–21
0.697
+0.044
49 of 80
text tokens
layers 19–21
1.331
+0.678
80 of 80
all tokens
layers 19–21
1.349
+0.696
80 of 80
image tokens
layers 4–6
1.274
+0.621
80 of 80
image tokens
layers 10–12
0.735
+0.082
58 of 80
Appendix
Table 8: Validation NLL of the base model with MLP outputs zeroed in the forward pass.
Why does full-pipeline FP4 training of large language models often diverge, even when forward activations and activation gradients remain stable? We address this question through a controlled study of MXFP4 quantization in transformer training, progressively enabling FP4 across forward propagation (Fprop), activation gradients (Dgrad), and weight gradients (Wgrad) while holding all other factors fixed. In full pretraining of Llama 3.1-8B on the C4 dataset, we observe that quantizing Wgrad is the primary driver of convergence degradation, whereas FP4 in Fprop and Dgrad alone introduces only modest additional token requirements. To interpret this behavior, we evaluate both structured and stochastic interventions under a controlled experimental setting. We find that stochastic rounding and randomized Hadamard rotations fail to stabilize training once Wgrad is quantized, whereas deterministic Hadamard rotations consistently restore stable optimization. These results suggest that FP4 training instability is driven by structured micro-scaling errors along sensitive gradient paths, rather than by insufficient stochasticity. We run experiments with native MXFP4 support on AMD Instinct MI355X GPUs, enabling controlled investigation of these effects without reliance on software emulation.
Musa Cim, Poovaiah Palangappa, Miro Hodak +3
1The Pennsylvania State University · 2Advanced Micro Devices, Inc.
Reverse-mode differentiation computes every weight gradient, writes it to memory, and only then lets the optimizer read it back. This two-phase schedule sets the memory ceiling of modern training: at the seam between the phases, every layer's gradient is live at once. We argue that this materialized gradient is an artifact of how differentiation is staged, not a quantity that learning requires -- and we eliminate it. FORGE folds the optimizer step into the backward pass and applies it one tile at a time, entirely in registers, so each gradient tile is consumed the instant it is produced and never becomes a tensor. The fusion changes only when the update happens, not what it computes: in full precision the fused step is provably exact -- the identical optimizer update, for every element-wise rule -- and that exactness survives tensor- and sequence-parallel sharding; in the bf16 and 8-bit regimes used in practice it is faithful rather than bit-identical, its deviation bounded and, for the weight store, rendered unbiased by stochastic rounding. Because each gradient tile is born and consumed in the same registers, it is never converted down to bf16 to be stored and read back; FORGE thus preserves the full-precision fidelity that both bf16 and 8-bit optimizers lose to that conversion. Nor is the method tied to one architecture or one optimizer: linear layers are ubiquitous, and FORGE reclaims the gradient memory of any of them under any element-wise rule. Empirically FORGE more than halves the memory of an optimizer step and, at the small batch sizes typical of fine-tuning and continued pretraining, runs about 1.5x faster; integrated into tensor-parallel Megatron-LM it fits 8B training at four times the micro-batch a standard optimizer allows on the same GPUs.
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.
Junlin Chen, Daize Dong, Huanwei Di +9
Rutgers University · Carnegie Mellon University · Oracle +2