Skip to content
EventPast event

DeepMind finds Softmax numerical precision bug and proposes a fix

4 reports4 reporting sourcesLatest report

Start here

AI overview

Jonathan T. Barron, a chief research scientist at Google DeepMind, and others submitted a paper to arXiv on October 22, pointing out that the standard implementations of Softmax and cross-entropy widely used in mainstream frameworks such as PyTorch, JAX and TensorFlow, as well as in textbooks, have two numerical precision bugs. The first is Softmax Collapse: the standard implementation first subtracts the maximum score to prevent overflow; when the model is overconfident in the correct class and, under fp32, the correct class's logit leads the other classes by more than about 16.6, the extremely small number in the denominator is rounded to zero, the correct class's gradient is erroneously zeroed, and gradients for other classes remain. The paper uses this to explain the phenomenon of sudden spikes in training loss, and points out that the slingshot effect previously treated as a feature of "grokking" is actually caused by this bug. The team proposes a fix that preserves the original mathematical definition and requires no increase in floating-point precision, switching cross-entropy to log-sum-exp; Gemini participated in the discovery and fixing of the bug, and Xinzhiyuan says Gemini Flash 3.7 was the first to discover and fix it.

Generated by AI from reports · Updated 2026-10-26

Progress timeline

Oct 28
Oct 27
Oct 26
  1. WeChat · AI Era (Xinzhiyuan)Selected
    DeepMind paper reveals floating-point rounding bug in Softmax and cross-entropy; Gemini Flash 3.7 was the first to discover and fix it

    Jon Barron's team at Google DeepMind submitted the paper "Fixing Softmax and Cross-Entropy" to arXiv, pointing out that the standard Softmax and cross-entropy implementations in PyTorch, JAX and textbooks have a floating-point rounding bug. The standard implementation first subtracts the maximum score to prevent overflow; when the model is sufficiently confident, the extremely small numbers in the denominator are rounded to zero, and the correct gradient disappears accordingly. The paper calls this Softmax collapse, and the slingshot effect previously regarded as a grokking feature is actually caused by this bug. The fix is to use log-sum-exp to compute the margin for cross-entropy and return softplus, and in distillation scenarios to use expm1 and log1p in log space to eliminate ghost gradients. In the modular addition (a + b mod 31) task, under bfloat16 precision the standard code's test accuracy is only 93.3% and highly unstable, while after the fix it reaches 100.0%.

Oct 25
  1. Sina TechSelected
    Google DeepMind team discloses hidden numerical bug in Softmax in frameworks such as PyTorch and JAX; Gemini participated in the discovery and fix

    A paper submitted to arXiv on October 22 by Google DeepMind principal research scientist Jonathan T. Barron and others points out that the standard implementations of Softmax and cross-entropy widely used by mainstream frameworks such as PyTorch, JAX, and TensorFlow have two numerical precision bugs, and gives a fix that does not require increasing floating-point precision. The first, Softmax Collapse, occurs when a model is overconfident about the correct class; the standard implementation incorrectly zeroes the gradient of the correct class, and the paper uses this to explain the Slingshot phenomenon in which training loss suddenly spikes; the second, Softmax Cancellation, appears in scenarios such as knowledge distillation where teacher and student outputs are close, and a nonzero residual gradient is still computed when the student has already reached the distillation target. On the fp32 mod-31 addition Grokking task, standard cross-entropy achieved an average test accuracy of 94.3%±5.4% over 5 experiments, while the fixed version reached 100% in all.

  2. WeChat · Synced (Jiqizhixin)
    PyTorch and JAX are both named! Softmax exposed a hidden bug, Gemini takes credit

    A paper by Google DeepMind researcher Jonathan T. Barron and others (submitted to arXiv on October 22) points out that the standard implementations of Softmax and cross-entropy widely used by mainstream frameworks such as PyTorch, JAX, and TensorFlow have two numerical precision bugs. The first bug is Softmax Collapse: under fp32, when the Logit Margin exceeds about 16.6, the gradient of the correct class is erroneously zeroed out; the second bug is Softmax Cancellation, which appears in knowledge distillation, where a nonzero residual gradient is still computed even when the student and teacher Logits are identical. The paper argues that the former can explain the loss spikes in Grokking training (the Slingshot mechanism); in the mod-31 addition experiment, under fp32 the standard cross-entropy achieved an average test accuracy of 94.3%±5.4% over 5 experiments, while the fixed version reached 100% in all cases, and the fix only requires adjusting the computation method, with no need to increase floating-point precision.

  3. Sina Mobile
    PyTorch and JAX are both named! Softmax exposed a hidden bug, Gemini takes credit

    Jonathan T. Barron, Principal Research Scientist at Google DeepMind, and his team point out that the standard implementations of Softmax and cross-entropy commonly used by frameworks such as PyTorch, JAX, and TensorFlow have two numerical precision bugs, and they provide fixes that preserve the original mathematical definition and do not require increasing floating-point precision. Softmax Collapse occurs when the logit of the correct class leads other classes by more than a critical value (about 16.6 in fp32): the gradient of the correct class is erroneously zeroed and gradients of other classes remain; Softmax Cancellation occurs in knowledge distillation when the student and teacher outputs are nearly identical, where a gradient that should be zero retains a nonzero value due to floating-point rounding. In the paper, on a modulo-31 addition task, standard cross-entropy averaged 94.3%±5.4% test accuracy over 5 experiments, while the fixed version reached 100% in all; on a modulo-97 sum-of-squares task, the standard implementation's test accuracy dropped from 61% to 23% at about 1250 training steps.

Oct 24

Related discussion

Total 58 items