Mixed variational flows for discrete variables

Gian Carlo Diluvi, Benjamin Bloem-Reddy, Trevor Campbell

Abstract

Variational flows allow practitioners to learn complex continuous distributions, but approximating discrete distributions remains a challenge. Current methodologies typically embed the discrete target in a continuous space—usually via continuous relaxation or dequantization—and then apply a continuous flow. These approaches involve a surrogate target that may not capture the original discrete target, might have biased or unstable gradients, and can create a difficult optimization problem. In this work, we develop a variational flow family for discrete distributions without any continuous embedding. First, we develop a measure-preserving and discrete (MAD) invertible map that leaves the discrete target invariant, and then create a mixed variational flow (MAD Mix) based on that map. Our family provides access to i.i.d. sampling and density evaluation with virtually no tuning effort. We also develop an extension to MAD Mix that handles joint discrete and continuous models. Our experiments suggest that MAD Mix produces more reliable approximations than continuous-embedding flows while requiring orders of magnitude less compute.

Introduction

Normalizing flows are a powerful tool for modeling complex continuous distributions by transforming simple base distributions through a series of invertible mappings. However, applying these techniques to discrete variables, such as categorical or integer data, is inherently difficult. Because bijections between discrete sets are limited to permutations, they cannot effectively redistribute probability mass.

Traditional solutions often rely on "continuous relaxations" or "dequantization" to force discrete data into continuous spaces. While these methods are widely used, they frequently suffer from high computational costs, training instability due to "peaky" gradients, and inaccuracies stemming from the use of surrogate targets that fail to capture the true discrete structure.

Methodology: The MAD Map and MAD Mix

To address these limitations, the authors introduce the Measure-preserving And Discrete (MAD) map. Instead of embedding data into a continuous space, the MAD map augments the discrete target with auxiliary uniform variables. This enables a deterministic, invertible transformation that operates directly on discrete states.

The MAD map follows a three-step process:

  1. Mapping to $\rho$-space: The discrete variable and auxiliary uniform variable are combined into a single value $\rho$, representing its position within the Cumulative Distribution Function (CDF).
  2. State Update: An ergodic shift (addition modulo 1) is applied to $\rho$, which induces a change in the discrete state via an inverse-CDF move.
  3. Mapping back to $u$-space: The updated $\rho$ is transformed back into an independent auxiliary uniform variable.
The four-step process of the MAD map: (0) Initial state, (1) Mapping from u-space to rho-space, (2) Updating the discrete state x, and (3) Mapping back to u-space.

By stacking these maps, the researchers created MAD Mix, a "Mixed Variational Flow." Crucially, because the MAD map is designed to leave the target distribution invariant, the flow converges to the true target as the number of steps increases. For joint models, the MAD map can be combined with Hamiltonian-based flows to handle discrete and continuous variables simultaneously.

Key Insights and Advantages

MAD Mix offers several distinct advantages over traditional flow-based approaches:

  • No Training Required: Unlike traditional flows that require optimizing thousands of neural network parameters, MAD Mix's "parameters" are the target's own conditional distributions. This bypasses expensive training loops.
  • Tractable Density Evaluation: MAD Mix provides the sampling capabilities of a Gibbs sampler but adds the ability to calculate the Evidence Lower Bound (ELBO), allowing for direct assessment of model fit.
  • Stability through Invariance: By using measure-preserving maps, the algorithm avoids the gradient explosion issues common in continuous relaxations.

Experimental Results

The authors evaluated MAD Mix on a variety of tasks, including discrete toy examples, the Ising model, Gaussian Mixture Models (GMM) on high-dimensional datasets like Palmer Penguins and Waveform, and Spike-and-Slab regression for Bayesian variable selection.

Performance comparison of MAD Mix against baseline methods across various discrete and mixed-variable tasks, showing superior efficiency and accuracy.

The results demonstrate that MAD Mix consistently produces more reliable approximations than continuous-embedding flows. Notably, it achieved lower KL divergence and higher ELBO while requiring orders of magnitude less compute. In many instances, MAD Mix was run once to achieve high-quality results, whereas competitors required extensive architecture searches and tuning.

Conclusion

MAD Mix represents a significant advancement in variational inference for discrete and mixed variables. By operating directly on discrete states through measure-preserving maps, it provides a stable, efficient, and accurate alternative to continuous-embedding methods. While its performance is tied to the mixing properties of the underlying map, it offers a powerful new tool for researchers working with complex discrete distributions. Future work may explore more sophisticated maps to improve mixing in highly correlated systems.

Summary updated

BibTeX
@inproceedings{diluvi2024mixed,
  author = {Gian Carlo Diluvi and Benjamin Bloem-Reddy and Trevor Campbell},
  title = {{Mixed variational flows for discrete variables}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2024},
  url = {https://openreview.net/forum?id=EwchrLFGFA},
}
Figure