An unofficial, read-only Hacker News reader.

The KL Divergence Is Never Negative, Except in PyTorch (opens external site)

97 points by Anon84 5 days ago | arxiv.org | 40 comments on HN

View full thread · View on Hacker News

Comment thread (7)

  1. it is sort of surprising how many parts of pytorch seem (sort of) buggy / numerically not great... I think they just have sooo many operations that some are (relatively) unused and don't receive as much attention. (though kl-divergence seems pretty important (??))

    I wonder if it's also because ML stuff is just pretty insensitive to numerical issues, so users don't notice it.

    Replies (4)
    1. What other parts of pytorch are buggy?
      Replies (1)
      1. "buggy" probably is probably too strong of a word. Maybe "weird edge cases in ops that aren't commonly used" is more accurate.

        Like I think L-BFGS has less support than the other optimizers, since no one really uses it on large models. But its implementation could have been improved a lot for people who do use it on small models. (IDK stuff is probably better now with AI-assisted dev vs. when I last looked)

    2. Its really buggy with a mix of devices especially when they aren't all CUDA. I have run into a lot of problems just having an AMD card in the machine even if I am not trying to use it! Image creation and editting has been broken ever since I added a 9070 XT to my PC, its mere presence is enough to break pytorch for anything image related.
    3. I've been using pytorch since the beginning, and it's pretty rare that I'd reach for the inbuilt KL-divergence. Not because I don't use it, but because there are so many ways to evaluate it, and I'll often hand-roll the one that seems easiest given the project. I suspect others would do the same thing.

      And yeah, ML is pretty resistant to this sort of bug.

    4. I'm reminded of this article that explains that the realities of floating point numbers can introduce non-linearity into an otherwise linear neural network:

      https://openai.com/index/nonlinear-computation-in-deep-linea...

      In this case, the "bug" actually allows the neural net to be more powerful than designed.

      Replies (1)
      1. That's also the premise of Tom7's video "GradIEEEnt half decent: The hidden power of imprecise lines" https://youtu.be/Ae9EKCyI1xU?si=iFcuTv9CxTKPB5Bf & accompanying paper https://tom7.org/grad/