Scalable Normalizing Flows for Permutation Invariant Densities

Marin Bilos, Stephan Günnemann

Modeling sets of exchangeable data—such as point clouds, items in a shopping cart, or spatial events—is a fundamental challenge in machine learning. To effectively generate or evaluate the likelihood of such data, models must be permutation invariant. Continuous Normalizing Flows (CNFs) are highly expressive tools for this task, using Ordinary Differential Equations (ODEs) to smoothly transform a simple base distribution into a complex target distribution. Because CNFs allow for unrestricted transformations, permutation equivariant layers like Deep Sets or Self-Attention can be easily integrated to model complex interactions between points.

However, a major computational bottleneck exists: training a CNF requires calculating the change in log-density, which relies on computing the trace of the transformation's Jacobian matrix. For a set of $n$ points in $d$ dimensions, computing this exactly scales quadratically as $\mathcal{O}(n^2d^2)$, which is prohibitively slow. The standard workaround, Hutchinson's stochastic trace estimator, introduces noise, destabilizes training, and still requires the slow exact computation during inference for true likelihoods.

A Linear-Time Exact Trace Architecture

To overcome this bottleneck, the authors propose a novel architectural design for permutation equivariant functions that inherently possesses a closed-form trace computable in linear time $\mathcal{O}(nd)$.

They achieve this by decoupling the neural network transformations into nested parts, ensuring specific blocks of the Jacobian are zeroed out:

Jacobian decoupling for exact trace computation
  1. Between-points interactions: The model masks out a point's contribution to itself. For instance, in a Self-Attention layer, the diagonal of the attention similarity matrix is set to $-\infty$. This ensures a point doesn't attend to itself, resulting in a zero trace for this specific interaction (a volume-preserving flow).
  2. Within-point interactions: To allow features within a single point to interact without ruining the trace, the authors use Masked Autoencoders for Distribution Estimation (MADE). This ensures the Jacobian of the individual point feature transformation has zeros on the diagonal.
  3. Per-dimension transformations: Finally, a Jacobian decoupling trick is applied to compute the exact trace of the remaining 1D transformations cheaply.

The result is an exact-trace CNF that retains the universal expressiveness of standard Deep Sets or Attention layers but entirely bypasses the quadratic computational bottleneck.

Experimental Validation and Key Insights

The authors evaluated their models across a mix of sanity-check tasks (e.g., max value regression, counting unique digits), synthetic spatial point processes (Thomas, Matérn), and real-world benchmarks (user location check-ins, crime locations, and coal mining disasters). They also tested scalability on large sets like discretized MNIST and ModelNet40 point clouds.

Relative log-likelihood performance across datasets

Exact Trace Does Not Restrict Expressiveness: One might assume that heavily masking self-interactions and using constrained MADE layers would hurt the model's ability to learn complex distributions. Surprisingly, the exact-trace models matched or exceeded the performance of unrestricted, computationally heavy approximate models. On the Check-ins NY dataset, the proposed CNF achieved a negative log-likelihood of -2.30, significantly outperforming the Inhomogeneous Poisson baseline's -1.61.

Stability Translates to Speed: Because the exact trace removes the variance introduced by stochastic estimators, the ODE solvers require significantly fewer evaluation steps to converge—roughly half the number of evaluations compared to approximate models. This directly translates to faster wall-clock training and inference times. Furthermore, the exact trace computation proved to be orders of magnitude faster than both naive exact computation and Hutchinson's estimator across various dimension sizes.

Tractable Spatial Point Processes: Traditionally, modeling complex spatial point processes where the presence of one point influences another required approximations like pseudo-likelihoods or Monte Carlo methods. By using CNFs with exact likelihoods, this architecture provides a clean, tractable way to model these interacting systems directly.

Limitations and Future Directions

While highly effective, the authors note that using only the volume-preserving (zero trace) part of their flow fails to capture the inhomogeneous base density of a process; the full exact-trace model is required for complete modeling. They also experimented with "induced attention" to reduce memory footprints for very large sets, but found it generally performed worse than standard self-attention and added an extra hyperparameter.

Because this approach is orthogonal to recent advances in ODE regularization (techniques to reduce ODE "stiffness") and new types of equivariant layers, combining this exact-trace architecture with newer techniques could yield even better performance and scalability in the future.

Summary updated

BibTeX
@inproceedings{bilos2021scalable,
  author = {Marin Bilos and Stephan Günnemann},
  title = {{Scalable Normalizing Flows for Permutation Invariant Densities}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=_vR9tq485H},
}
Figure