Jon Barron: every softmax and cross-entropy implementation has two subtle numerical bugs

jon_barron · x · 2026-10-27

Jon Barron (Google DeepMind) reports that all existing implementations of softmax and cross-entropy — JAX, PyTorch, textbooks included — harbor two subtle numerical bugs that produce false or vanishing gradients when logits nearly agree, causing "slingshots" during grokking. A simple rewrite fixes both.

Brandon Damos extends the analysis to distillation objectives:

Experiments show naive gradient error plateaus below logit gaps of 1e-5 (off by 5+ orders of magnitude), while the fixed versions track a high-precision reference down to 1e-12.

Original post →

More from Research

Research channel →