DeepMind finds Softmax numerical precision bug and proposes a fix
Start here
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
- WebAI Era (Xinzhiyuan)· Media coverageAI textbooks are all wrong! Underlying formula's shocking bug exposed, Gemini is first to self-repair(opens the original post in a new tab)
- WeChat · AI Era (Xinzhiyuan)SelectedDeepMind 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%.
- X@tantiechui· Discussionhttps://mp.weixin.qq.com/s/vc8f6yQAnVJvowYU2aEhFA(opens the original post in a new tab)
- X@zhuoivanlalala· Discussionhttps://mp.weixin.qq.com/s/x8RGmsO8DWq8-_m_teDKfA(opens the original post in a new tab)
- WebSynced (Jiqizhixin)· Media coveragePyTorch and JAX are both called out! Softmax exposes a hidden bug, Gemini takes credit(opens the original post in a new tab)
- X@EitanTurok· Discussion@jon_barron is this bug just in jax? what about pytorch?(opens the original post in a new tab)
- Sina TechSelectedGoogle 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.
- 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.
- Sina MobilePyTorch 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.
Related discussion
- Older than 72 hours · Not included in the 72-hour figures
- X@O_Hampiholi · Ojaas HampiholiTwo numerical bugs sit in standard softmax and cross-entropy code, a DeepMind paper argues. When a loss spikes, do you…(opens the original post in a new tab)
1 comments·Oct 31 23:40Collect
- X@michael45248969 · michael zhangDeepMind Reveals Numerical Flaws in Softmax and Cross-Entropy; Gemini Helps Repair AI Training Infrastructure 👇 Full c…(opens the original post in a new tab)
- X@j0OmcPKEmMMkNWX · 本間宏紀@理論を重んじるデータサイエンティストHearing that the implementation of the softmax function had a numerical bug that no one noticed until Barron, Gnanapragasam, and Tschannen pointed it out in October 2026 would probably surprise many people. Alongside the cross-entropy loss, it is one of the…(opens the original post in a new tab)
25 likes·Oct 29 22:34Collect
- X@nithin_r_g · Nithin@difficultyang turns out standard softmax and cross entropy have numerical bugs that mess up gradient calculations so c…(opens the original post in a new tab)
- X@BriceTian · Tian Zhang (Brice)Two numerical bugs are hiding in the standard softmax/cross-entropy everyone trains with. In bf16, once the target logi…(opens the original post in a new tab)
1 comments·Oct 31 23:40Collect
- X@cv_usk · cv uskDid softmax and cross-entropy have numerical bugs nobody actually fixed? A new paper from Google DeepMind says yes. Ti…(opens the original post in a new tab)
- X@mmaaz_98 · MaazI saw the recent softmax bug which was found by Gemini, and tried to reproduce it with a property-based test in Hypothe…(opens the original post in a new tab)
300 likes · 10 comments·Oct 29 22:34Collect
- X@difficultyang · difficultyangSo the log_softmax bug https://arxiv.org/abs/2610.31642 that's been making the rounds. TorchLean also had the same prob…(opens the original post in a new tab)
340 likes · 13 comments·Oct 31 23:40Collect
- XX @grok · Grok@ychisbest @Neosoulbe Yes, basically true, but the headline is clickbait. A paper by Jon Barron and others at DeepMind points out that the commonly used softmax/cross-entropy implementations in PyTorch, JAX and textbooks have two floating-point precision bugs, and gradients go wrong at high confidence. Gemini…(opens the original post in a new tab)
- X@jupiter186 · jupiterPyTorch and JAX's softmax hides two bugs: DeepMind's new paper explained (Chinese and English subtitles) https://mp.weixin.qq.com/s/dB_Q2F4Pkl-8UMVMCu7b5w(opens the original post in a new tab)
- X@Neosoulbe · 于真真The sky is falling! The sky is falling!! The sky is falling!! — Something big is here, the new AI awakening policy — Google DeepMind shockingly drops a bombshell: the underlying formulas of all the major open-source AI frameworks (PyTorch, JAX) and of humanity's standard math textbooks for decades are all wrong! This has been hidden under the noses of all humanity…(opens the original post in a new tab)
9 likes · 3 comments·Oct 28 12:34Collect
- X@cv_usk · cv uskDid softmax and cross-entropy actually have numerical bugs that were never fixed? It's a Google DeepMind paper. Title: A Fix for Softmax and Cross-Entropy URL: https://ar…(opens the original post in a new tab)