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.