Stabilizing the Kumaraswamy Distribution

Max Wasserman, Gonzalo Mateos · Submission to ICLR 2025 · Withdrawn

In probabilistic machine learning, modeling variables that live within a bounded range—such as probabilities between 0 and 1 or physical constraints—is a common requirement. The Beta distribution has traditionally been the go-to choice for this task. However, it harbors a major flaw for modern deep learning: it lacks a simple, "closed-form" way to transform a random seed into a sample, a technique known as the reparameterization trick. This limitation makes the Beta distribution slow and cumbersome to use in large-scale models that rely on efficient gradient descent.

The Kumaraswamy (KS) distribution is a highly expressive alternative that boasts a simple, closed-form inverse Cumulative Distribution Function (CDF), making it perfectly suited for the reparameterization trick. Yet, despite its theoretical advantages, its adoption in the machine learning community has remained surprisingly limited.

Comparison of sampling and gradient times across different bounded distributions. The Beta distribution is notably slower than the Kumaraswamy (KS) distribution.

The "Certainty Paradox" and Catastrophic Cancellation

If the KS distribution is so efficient, why isn't it widely used? The authors discovered that standard implementations in major frameworks like PyTorch and TensorFlow suffer from severe numerical instabilities.

The core issue is catastrophic cancellation. When the distribution's parameters become large—which naturally occurs as a model learns and becomes more "certain" of its predictions—the underlying math requires subtracting two nearly identical numbers. This leads to precision errors, infinite values (inf), and NaN (Not a Number) outputs that instantly crash the training process. The authors term this the "Certainty Paradox": as the model's confidence grows and the distribution sharpens, the mathematical operations become increasingly precarious.

A common hack to avoid this is to clip parameters to a "safe" range. However, the authors demonstrate that in high-dimensional settings (like recommendation systems with millions of items), the probability of at least one variable failing approaches 100%. Clipping is simply not a viable strategy for large-scale AI.

Comparison of the standard PyTorch KS implementation, which suffers from massive sample underflow, against the proposed Stable KS.

Taming the Distribution: A Two-Pronged Solution

To resolve these deep-seated instabilities, the authors propose a robust stabilization strategy:

  1. Unconstrained Logarithmic Parameterization: Standard KS parameters ($a$ and $b$) must be strictly positive. The authors re-derive the log-pdf, CDF, and inverse CDF using $\log a$ and $\log b$. This unconstrained parameterization is a much more natural fit for neural networks, which inherently output real numbers across the entire number line.
  2. The log1mexp Trick: The authors isolate the specific mathematical terms causing the instability—namely those in the form $\log(1 - \exp(x))$—and replace them with a specialized numerical function called log1mexp. This function dynamically switches between different mathematical approximations depending on the input value, maintaining high precision even when $x$ is infinitesimally close to zero.

Applications and Key Results

With a stable, fast, and differentiable bounded distribution unlocked, the authors introduce two novel model architectures to test its capabilities:

  • Variational Bandit Encoder (VBE): Designed to handle the exploration-exploitation trade-off in multi-armed bandits. In a large-scale synthetic dataset with $10^4$ arms, the VBE-KS model achieved lower regret (made fewer mistakes) than Beta-based or tanh-Gaussian alternatives. Furthermore, thanks to the KS distribution's explicit reparameterization, the KS-based models were 8–22x faster than state-of-the-art Langevin Monte Carlo methods.
  • Variational Edge Encoder (VEE): A method for Graph Neural Networks (GNNs) to predict missing links while providing reliable uncertainty estimates. Tested on standard citation networks (Cora, Citeseer, and Pubmed), the VEE-KS model provided superior Brier Scores (a measure of calibration). This indicates a higher correlation between predicted uncertainty and actual error—meaning when the model claims to be "unsure" about a link, it is genuinely more likely to be wrong.

Additionally, the stabilized KS distribution allowed Variational Autoencoders (VAEs) to train successfully on image generation tasks (CIFAR-10), whereas standard PyTorch/TensorFlow implementations frequently crashed with NaN errors.

Limitations and Future Directions

While the stabilized KS distribution is a powerful new primitive for probabilistic modeling, it is not without limitations. The KS distribution is unimodal, meaning it cannot capture complex, multi-modal latent spaces without being incorporated into a mixture model. Furthermore, models utilizing it still rely on a $\beta_{KL}$ hyperparameter weight to balance the prior and the data, which often requires manual tuning. Finally, while the Variational Bandit Encoder performs exceptionally well empirically, establishing formal theoretical regret bounds remains an open challenge for future research.

By fixing the foundational numerical flaws of the Kumaraswamy distribution, this work provides researchers with a highly scalable, efficient tool for modeling bounded latent variables in modern deep learning.

Summary updated

BibTeX
@misc{wasserman2024stabilizing,
  author = {Max Wasserman and Gonzalo Mateos},
  title = {{Stabilizing the Kumaraswamy Distribution}},
  year = {2024},
  eprint = {2410.00660},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.00660},
}
Figure