On numerical issues of divergences between nearly equal distributions
Abstract
Barron et al. (2026) recently identified numerical issues in the softmax and soft cross-entropy loss. We show that similar issues are present in standard divergence operations between categorical distributions. This includes the forward and reverse Kullback-Leibler (KL) divergence and generalized Jensen-Shannon divergence (JSD), as well as Monte Carlo KL estimates and entropy. When the distributions are nearly equal, rounding and cancellation issues affect the forward and gradient computations. These issues can affect settings using divergences in optimization objectives, such as knowledge distillation, reinforcement learning, and proximal methods. We propose numerically stable reformulations and provide example implementations for each setting, validated by property-based tests.
Create a lesson
Metadata
- Categories
- cs.LG, cs.NA, math.NA, stat.ML
Related papers
Near-Zero Forgetting Is Not Enough: Out-of-Distribution Robustness in Continual Learning of Pretrained VLAs
Shared title terminologycs.LGAdrià Ruiz, Bartłomiej Twardowski, Tinne Tuytelaars et al.
Flagging Batch Shift in Flow Cytometry using Jeffreys Divergence between Gaussian Mixtures
Shared title terminologycs.LGJonathan Legrand, Aguirre Mimoun, Audrey Bidet et al.
Conformalized Tree-Based Gradient Ensembles for Out-of-Distribution Detection and Plausible Recourse
Shared title terminologycs.LGMariam Zakaria Moussa Ali
Reinforcing Diffusion Models by Instantaneous Trajectory Distribution Matching
Shared title terminologycs.LGYihong Luo
The KL Divergence Is Never Negative, Except in PyTorch
Shared title terminologycs.LGZhen Yang, Wei Tang, Chu Chen et al.
Near-Far Attention: Region-Aware Sparse Retrieval for Long-Context LLM Decoding
Shared title terminologycs.LGYuanShuo Wang, Jianchao Tan, Lei Gong et al.