AIToday
Large Language ModelsQiita 機械学習Published: Oct 26, 2026, 22:01 JST

DeepMind's Barron flags two Softmax bugs in standard ML code

Send on LINE
DeepMind's Barron flags two Softmax bugs in standard ML code

3 Key Points

  1. What happened

    Barron, Gnanapragasam and Tschannen published "A Fix for Softmax and Cross-Entropy" (arXiv:2610.31642). Softmax Collapse zeroes the correct-class gradient under strong confidence; Softmax Cancellation leaves a non-zero gradient in distillation when student and teacher match. A Mac reproduction confirmed both in PyTorch and JAX.

  2. Why it matters

    The paper's fix is a few-line function that restores the intended gradients.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The paper targets a piece of numerical plumbing that most practitioners never inspect: the handoff between Softmax and Cross-Entropy, where the gradient simplifies to "probability minus the correct-class indicator." The authors show that the standard trick of subtracting the maximum logit before exponentiating, while numerically safe on its own, creates a path for rounding to erase the correct-class gradient once confidence passes a precision-dependent threshold. Their fix avoids ever forming "1 plus a tiny number" by computing the log-sum-exp only over non-correct logits and wrapping the loss in softplus.

The Mac reproduction adds independent evidence that the bugs are not theoretical. In PyTorch on CPU and Apple GPU (MPS), the standard cross-entropy produced a gradient sum of +3.0e-08 instead of zero for a confident example, while the fixed version returned exactly zero. In a distillation setup where student and teacher started with identical weights, the standard implementation drifted apart within three steps even in fp64, whereas the fixed version stayed put.

The practical takeaway hinges on where the loss is computed. Because Hugging Face transformers casts logits to fp32 before the loss, the reproduction found only a small share of tokens beyond the cliff in pretrained LLMs; but when bf16 logits go straight into the loss, up to 47% of tokens for an 8B model on code data sat beyond the cliff, meaning their correct-class gradients rounded to zero. That distinction, rather than the existence of the bugs alone, is likely to determine whether a given training pipeline is exposed.

FAQ
What exactly are the two bugs?
Softmax Collapse zeroes the correct-class gradient when the model is very confident, breaking the zero-sum property of gradients. Softmax Cancellation leaves a non-zero gradient in distillation even when student and teacher logits are identical, due to rounding differences between forward and backward softmax computations.
Does this affect LLM training or LoRA?
The reproduction found that with losses computed in fp32 (the default in Hugging Face transformers), tokens beyond the precision cliff were 0–0.03% for Qwen3-0.6B and 0.2–0.5% for an 8B model. LoRA training for 600 steps showed no loss spikes and nearly identical loss between standard and fixed versions.
Is the fix available in PyTorch or JAX?
The paper includes a JAX implementation of about 30 lines. The author ported it to PyTorch for the reproduction; no repository link is given in the paper.
Qiita 機械学習Read Original Article
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleResolution autoformalizes singularity math for $135,000