HomeArticle

All AI textbooks are wrong, a staggering critical bug in the underlying formula has been exposed, and Gemini takes the lead in self-repair.

新智元2026-10-26 20:56
The tragedy of history is that machines are always losing numbers.

Every major AI framework is wrong! 

PyTorch is wrong, JAX is wrong. Even the standard formulas in textbooks are wrong. 

Jon Barron, Principal Research Scientist at Google DeepMind, has dropped this bombshell! 

This week, Google DeepMind demonstrated a problem: every standard version of this algorithm in PyTorch, JAX, and various textbooks has been quietly rounding a certain number to zero this whole time. 

The more confident the model is, the easier the correct training signal vanishes out of thin air. This causes the optimizer to lose control, leading to drastic fluctuations in the training curve. 

But the most chilling, and also the most exciting part is: This underlying logic flaw hidden under the noses of all humanity was spotted by AI (Gemini) itself.

This time, humans are only responsible for post-hoc review and typesetting. 

The Vanishing Number, The Collapsing Model Calibration

This bug is hidden in the most basic operations of AI: Softmax and Cross-Entropy. 

If you have ever been exposed to machine learning, you are definitely familiar with these two terms. 

Softmax is responsible for converting the raw outputs (logits) of the model into probabilities. Cross-Entropy is responsible for calculating the error, telling the model how wrong its predictions are. 

All classifiers, all large language models, call this pair of functions billions of times every day. 

How could they go wrong? 

The problem lies in the limit and rounding-off. 

To prevent calculation overflow, all existing standard frameworks (whether PyTorch or JAX) perform a standard operation: 

Subtract the maximum score first.

After this subtraction, the denominator becomes a structure similar to "1 + an extremely small number". 

This "extremely small number" depends on the model's level of confidence. 

The more confident the model is, the higher the score of the correct answer is compared to other answers, the smaller this number will be. 

But there is a key detail hidden here: mathematical equivalence does not mean complete equivalence in computer floating-point arithmetic.

In the world of computer floating-point numbers, if you add a sufficiently small number to 1.0, the computer will think "this is too small to bother calculating", and directly round the result to the exact 1.0. 

Under the bfloat16 format, this cliff appears at a value of around 5.5. Under fp32, it appears at around 16.6. 

What happens once you cross this cliff? 

The correct gradient instantly becomes absolute zero.

The model is still learning, but the feedback signal about the correct answer is directly erased by the computer's rounding mechanism. 

DeepMind's paper refers to this as Softmax Collapse. 

And the optimizer will make things even worse. 

The principle of the mainstream optimizer Adam is to divide each step of update by the average value of recent gradients. When the gradient becomes zero for a long time due to the bug, this average will also approach zero infinitely. 

When the real gradient finally appears again, Adam will divide this gradient by an extremely small number. 

The result is that the model takes a huge leap forward, and the loss function spikes instantly. 

The academic community has observed this phenomenon before, and gave it a nice name "Slingshots", thinking that it is some kind of advanced feature in the process of model "Grokking". 

It turns out that this is not a feature, but a bug. 

In addition to collapse, there is also Softmax Cancellation. 

During knowledge distillation, if the student model completely replicates the teacher model, the gradient should theoretically be zero. 

However, because the standard code calculates the probabilities separately and then subtracts them, the rounding error will leave a "ghost gradient". The student model will deviate from the correct answer for no apparent reason. 

All of this is entirely because an extremely small number was discarded. 

The team of Jonathan T. Barron from DeepMind submitted a paper on arXiv: *Fixing Softmax and Cross-Entropy*. 

The next day, Barron dropped the blockbuster news on the X platform: 

It turns out that all existing implementations of Softmax and Cross-Entropy (including JAX, PyTorch, textbooks, etc.) have a subtle bug — actually two.

A simple rewrite can fix them and eliminate the "Slingshots" effect during grokking.

For Cross-Entropy (fixing collapse): Take the target out of the sum, directly calculate the margin with log-sum-exp, then return the softplus of the negative margin. The core principle: never add an extremely small number to 1.

For distillation (fixing cancellation): Perform calculations using expm1 and log1p in the log space. In this way, when the student perfectly matches the teacher, the gradient is perfectly absolute zero, without any ghost residuals. 

The paper provides intuitive data tests: 

In the modular addition (a + b mod 31) task, using the standard code, the test accuracy under bfloat16 precision is only 93.3% (and extremely unstable). 

After switching to the fixed code, the accuracy directly soars to 100.0%, as stable as a mountain.

In the distillation test, the fixed code keeps the divergence between the student model and the teacher model at zero, and the accuracy maintains a perfect 100%. 

But what really blew up the entire tech circle is a sentence Barron added in the comment section: 

This bug was first discovered and fixed by Gemini Flash 3.7. Most of the experiments in the paper were completed by Flash 3.8. Gemini 4 Argon wrote the first draft of the paper and charts.

I was just extremely strict with nitpicking until the content was solid.

On October 24, independent engineer Satyajit Ghana fully reproduced this issue in PyTorch. 

He reproduced both bugs with the printed values on the CPU, ported the fix, and confirmed the results under fp32 precision in the paper. 

His conclusion is resounding: "Regardless of other details, the mechanism has been fully confirmed." 

Tragedies in History: Machines Keep Losing Numbers

Numbers being silently discarded is not the first time. Every time it happens, the cost is extremely painful. 

In 1965, Professor William Kahan from the University of Toronto issued a warning in *Communications of the ACM*.

He pointed out that when computers add up thousands of numbers, each addition will produce a rounding error. After adding a million numbers, you may lose 6 significant digits. 

His solution is extremely simple: add an extra variable to store the error lost last time, and add it back the next time. This is the famous "Kahan Summation Algorithm". 

Professor Kahan left a prophetic sarcasm in the article: "Double precision will soon be generally accepted as a substitute for ingenuity in solving numerical problems."