All existing softmax/cross-entropy implementations have a subtle bug, says Google's Jon Barron

jon_barron · x · 2026-10-24

Jon Barron shares a new result: all existing implementations of softmax and cross-entropy — JAX, PyTorch, textbooks — contain two subtle bugs. A simple rewrite fixes both and eliminates "slingshot" spikes during grokking.

The first bug, "Softmax Collapse" (identified by Prieto et al. 2025), occurs when one logit dominates: its gradient silently rounds to zero while others don't, so gradients no longer sum to zero. The post includes a full JAX rewrite of logsoftmax and crossentropy that keeps gradients well-behaved across float64/32/bfloat16 precisions.

Related event: Google researcher says all softmax and cross-entropy implementations have two numerical bugs(6 posts)→

Original post →

More from Research

Research channel →