Paper explainersRead the paper ↗

Machine learning / Numerical precision

The gradient
that rounds
to zero.

How can a classifier with a finite lead become perfectly certain? One addition inside softmax can erase the signal that tells it how to learn.

Precision experiment

Find the precision cliff

Number format
Target gradient magnitude · log scale
The fixed gradient decreases smoothly as the margin grows. The standard gradient abruptly vanishes. FP32 gradient magnitude against logit margin. The standard gradient drops to zero at 16.6. The fixed gradient continues to decrease smoothly.
Logit margin m
18.0

Drag the margin or switch formats to move the rounding cliff.

Standard |g|0
Fixed |g|1.52e−8

FP32 at margin 18. Open in a browser to change the margin or precision.

Hard targets

Softmax
collapse

How much does a confident model still have to learn?

Imagine two classes with scores, or logits, of 18 and 0. The first is the correct class. Its lead is the margin m = 18. Softmax converts those scores to probabilities, and cross-entropy measures the penalty for giving the correct answer less than full probability.

Write s = exp(−m) for the rival’s weight after shifting the largest score to zero. At this margin, s is about 1.52 × 10−8. The correct class gets probability 1/(1 + s). In FP32, the next representable number above 1 is 1 + 2−23. Our rival’s weight is less than half that gap. Adding it to 1 gives exactly 1 again.

Watch the green point. As the lead grows from 16 to 18, the exact sum crosses the rounding midpoint. The orange point marks the FP32 result.

Keep the rival’s weight in the numerator.

The loss gradient tells the optimizer which score to move. For the correct class it equals the predicted probability minus one. A rounded probability of one therefore gives a gradient of zero. Rearrange the same derivative before evaluating it and the rival’s weight survives.

Standard1/(1 + s) − 10
Fixed−s/(1 + s)−1.52 × 10−8

The rival still has a positive gradient of about 1.52 × 10−8. Its negative counterpart matters because adding the same constant to both logits leaves the probabilities unchanged. The gradient along that shared direction must be zero. You can check it by adding the two gradients.

With more classes, sum all rival weights into s. The paper computes the target loss with log1p(s), which accurately evaluates log(1 + s) even for tiny inputs. Forming the loss from differences between rival and target logits makes the target derivative the negative sum of the rivals’ derivatives. For standalone log-softmax the authors isolate the largest class, sum the remaining weights, then use log1p for the normalizer. Exponentiating gives softmax. The ordinary max shift already prevents exponential overflow. This rearrangement also preserves the tail until underflow. §2, Eqs. 3–7 ↗

How the interactive figure is calculated

The two logits are [m, 0] with the first entry as the target. The figure rounds the margin, exponential, sum, division, and final subtraction to the selected binary precision. The curves show magnitudes. Exact zero has its own row because it has no logarithm. The marked cliff occurs at approximately p ln 2, where p is the number of significand bits including the leading bit (8, 24, or 53). This is an illustrative scalar calculation. Reduction order can matter for many-class kernels.

Soft targets

Softmax
cancellation

What if the teacher and student already agree?

A teacher can supply an entire distribution p over classes. A student predicts its own distribution q, and its gradient on each logit is q − p. At a perfect match, every entry should be zero. Near a match, subtracting two rounded probabilities can discard most of their difference. At an exact match, a teacher’s forward softmax and a student’s backward log-softmax can even round differently.

Take the paper’s FP32 teacher scores [2, 1, 0]. Nudge the student by [−10−7, +10−7, 0] before FP32 rounding. Look at the third class. Its score stayed put, but changing the other two scores changed its share of total probability.

Student logit gradients Reported in §3 · units of 10−8
ClassStandardFixedFP64 reference
First−5.960−4.596−4.596
Second+1.452+4.144+4.144
Third−0.1123+0.4513+0.4513

The standard third gradient points the wrong way. To recover the sign, the authors start with the small differences between logits. They calculate the log probability ratio r = log(q/p) and recover the difference as p · expm1(r). This function preserves a tiny change in an exponential. Identical logits give r = 0 and a zero update, even though the cross-entropy itself can be positive.

How to get the log ratio without subtracting probabilities

Let δ be the student logits minus the teacher logits, and subtract their teacher-weighted mean to obtain d = δ − Σj pjδj. The log ratio for class k is then dk − log1p(Σj pj expm1(dj)). All terms vanish at a match. The implementation uses direct probability differences for large log ratios and removes any residual gradient sum. It needs access to the teacher logits. §3, Eq. 9 ↗

Training experiments

What changed
in training?

A precision cliff can become a training spike.

In the authors’ modular-arithmetic experiments, examples cross the cliff after memorization. While gradients are tiny, Adam’s running estimate of their squared magnitude decays. If margins slip back across the cliff, the returning gradients can produce an outsized update. The authors observed repeated loss spikes with the standard loss and smooth trajectories with the fix. §4, Fig. 2 ↗

Where should the margin settle if it can pass the cliff? With weight decay, the authors predict a rough balance near log(1/ε), where ε is Adam’s denominator constant. Smaller ε lets smaller gradients drive updates before weight decay balances them. Their modular addition runs make the dependence visible.

Final margin on addition modulo 31 FP32 · weight decay λ = 1 · Table 1
Adam εStandardFixedlog(1/ε)
10−813.017.918.4
10−1215.127.427.6
10−1612.736.836.8

Distillation offers a separate test. The researchers initialized a student with an exact copy of the teacher’s weights. After 2,000 Adam steps, their fixed gradient kept the student at the teacher’s predictions in all three tested precisions. The standard BF16 run drifted and lost accuracy. These experiments probe unusually confident models and unusually close teachers. The paper leaves the impact in typical large-scale training open. §7, Fig. 7 ↗