The KL Divergence Is Never Negative, Except in PyTorch
Although KL divergence is theoretically non-negative, PyTorch has long produced negative values, and a study of 18 KL families on 8.5 million inputs found widespread errors in values and gradients on both CPU and GPU.
Key points
- •PyTorch users have reported negative KL divergence values for years.
- •The study tested 18 closed-form KL families and F.kl_div using 8.5 million inputs.
- •Widespread errors in values and gradients were found on both CPU and GPU.