What matters in AI.

Subscribe

A paper finds incorrect values in PyTorch KL code

In tests on 8.5 million inputs, more than 85% of 32 bit values had 1% error or more near 0.0000001.

Researchers put a paper on arXiv, a site for papers, about the KL divergence. This number shows how far 2 sets of probabilities are from each other. In maths it is not negative, but PyTorch users saw negative values for years. The authors did tests on 18 formula families and the PyTorch function F.kl_div. They find large errors in values and in gradients, the numbers that give the direction for training.

How it fails

Many AI tasks compare sets that are near each other. For these, the usual KL formulas decrease in precision. The usual advice is to set negative values to 0. The authors tell that the sign is only the part that you can see of an error.

The numbers

  • With one more level of precision, 7% to 51% of values are not correct in 22 of 23 setups.
  • The errors change results: a maximum of 97% disagreement on top selections after distillation, and 19% to 59% of GPT-2 circuit edge scores.
  • Repaired code removes more than 97% of important errors. The full repairs make 567 million F.kl_div parts correct.

What is not known

The source does not tell if the PyTorch makers know of this or will use the repairs. The authors give out code and data, so that other teams can do the tests again.

Insight: A negative sign shows only some of the errors

About 30% of the 32 bit values become negative at lower values, but more than 85% have 1% error near 0.0000001. To set negative values to 0 removes the one alarm that you can see. This reads as a step that removes the alarm while incorrect values go on into training. Teams that use KL code get value from tests of it.

Sources

  1. The KL Divergence Is Never Negative, Except in PyTorcharxiv.org
AI MATTER · NEWS · AI MATTER · NEWS ·24 NOV2026

Posted

Tags

Learn the terms in this story

More in Benchmarks

All Benchmarks news