Megadose Built for builders and researchers.

The KL Divergence Is Never Negative, Except in PyTorch

· HN · ArXiv ·
The authors report that stable formulas and analytic gradients remove over 97% of significant KL errors without increasing precision.

Across 8.5 million test inputs, they found widespread errors in PyTorch KL values and gradients on CPU and GPU when comparing nearby distributions. In ordinary parameter ranges, over 85% of tested FP32 scalar values had at least 1% relative error near a divergence of 10⁻⁷. Evaluating the same formulas at higher precision still left substantial errors. The paper reports effects on parameter fitting, distillation and model interpretability scores that all but vanished with the repaired code.

HN · ArXiv's note

score 5

Categories: Research

Discussions

  • hn · 77 points · 31 comments
  • hn · 81 points · 31 comments
  • hn · 83 points · 33 comments
  • hn · 85 points · 33 comments
  • hn · 85 points · 33 comments
  • hn · 86 points · 33 comments
  • hn · 86 points · 35 comments
  • hn · 86 points · 36 comments
  • hn · 88 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 91 points · 37 comments
  • hn · 92 points · 38 comments
  • hn · 92 points · 38 comments
  • hn · 93 points · 38 comments
  • hn · 93 points · 39 comments
  • hn · 93 points · 39 comments
  • hn · 93 points · 39 comments
  • hn · 93 points · 39 comments
  • hn · 93 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 94 points · 39 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 95 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 96 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments
  • hn · 97 points · 40 comments