NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Embracing the chaos: analysis and diagnosis of numerical instability in variational flows

Zuheng Xu, Trevor Campbell

TL;DR

Deep variational flows suffer from severe numerical instability, causing floating-point errors to compound exponentially with flow length. Surprisingly, this paper reveals that downstream tasks like sampling and ELBO estimation remain highly accurate despite this chaos. By leveraging shadowing theory from dynamical systems, the authors provide the first rigorous error bounds for these tasks and introduce a practical diagnostic tool to validate flow results.

What Problem Does This Paper Address?

Variational flows (such as normalizing flows) construct complex probability distributions by passing a simple reference distribution through a sequence of invertible, parametrized transformations (layers). To model highly intricate target distributions, practitioners often chain together tens, hundreds, or even thousands of these layers.

However, composing so many transformations introduces a major challenge: numerical instability. Tiny round-off errors from standard 64-bit floating-point arithmetic quickly magnify along the flow. Standard layer-wise error analysis suggests that this trajectory error grows exponentially, implying that deep flows should produce "garbage" samples and highly inaccurate density evaluations.

Yet, in practice, deep flows often work remarkably well. This paper addresses this fundamental paradox: Why do numerically unstable flows still yield accurate statistical results?

MixFlow forward and backward orbit errors showing exponential growth across different datasets.

Methods

The authors resolve this paradox by treating variational flows as discrete-time dynamical systems and applying shadowing theory.

Instead of comparing a numerically computed trajectory (a "pseudo-orbit") to the exact trajectory starting at the exact same initial point, shadowing theory asks a different question: Does there exist some exact trajectory starting from a slightly different initial point that stays close to our numerical trajectory? If so, the numerical trajectory is said to be "shadowed" by a true orbit.

Visualization of a pseudo-orbit (blue) being closely tracked by a true shadowing orbit (grey), despite diverging from the intended exact orbit (red).

Using this framework, the authors:

  1. Derive Global Error Bounds: They prove new theoretical bounds for sample generation, density evaluation, and ELBO estimation. For trajectory-averaged flows (MixFlows), they show that sampling error is bounded by a constant independent of flow length, while density and ELBO errors grow at most linearly—far better than the feared exponential explosion.
  2. Develop a Diagnostic Procedure: They introduce a practical algorithm based on a "Finite Shadowing Theorem." By computing the minimum eigenvalue of a specially constructed block-tridiagonal matrix ($AA^T$), users can calculate the exact size of the shadowing window ($\epsilon$) for their specific flow to verify if their results are reliable.

Datasets

The authors evaluated their theory and diagnostic tool on both synthetic and real-world targets using MixFlow and Hamiltonian Variational Flow (HamFlow) architectures:

  • Synthetic Targets: The standard Banana distribution and a four-component Cross Gaussian mixture.
  • Real-World Posteriors:
  • A 21-dimensional Bayesian linear regression problem using the Oxford Parkinson’s Disease Telemonitoring Dataset (voice measurements to predict disease progression scores).
  • A 9-dimensional Bayesian hierarchical logistic regression problem using a Bank Marketing Dataset (predicting term deposit subscriptions).

Key Insights and Ideas

  • The Shadowing Paradox: The core "aha!" moment is that while numerical errors prevent us from computing the intended trajectory, the trajectory we do compute is almost perfectly identical to a different, valid exact trajectory. Because we sample from a broad reference distribution anyway, shifting the initial point slightly doesn't invalidate the downstream statistical properties.
  • Smoothness is Essential for Density Evaluation: The bounds reveal that density evaluation error depends heavily on the local Lipschitz constants (smoothness) of the learned flow.
  • MixFlow vs. HamFlow Behavior: MixFlows learn smooth densities, meaning their log-density evaluation errors remain small (0.1% to 1%). Conversely, HamFlows exhibit drastic fluctuations in their learned log-densities. Consequently, HamFlow's log-density evaluation error explodes exponentially, even though its ELBO estimates remain perfectly stable.

Key Results

  • Negligible Statistical Error: Despite exponential trajectory divergence, the relative sample average computation error across all test functions hovered around a mere 1% (Figure 4).
  • Tight Shadowing Windows: The diagnostic tool showed that the shadowing window size ($\epsilon$) grows only linearly with flow length and remains incredibly small—less than $10^{-10}$ for a MixFlow with over 1,000 transformations (Figure 7). This mathematically justifies why simply ignoring numerical error and using exact formulas still yields clean results.
MixFlow relative log-density evaluation error remaining low across variations.

Limitations and Future Work

  • Post-Training Scope: The current analysis and diagnostic tool only apply to downstream tasks after a discrete-time flow has been trained. It does not address how numerical instability affects the gradients and dynamics during the training phase itself.
  • Continuous-Time Flows: The theory is tailored to discrete-time flows and does not yet extend to continuous normalizing flows or Neural ODEs.
  • Computational Scaling: While computing the minimum eigenvalue of the block-tridiagonal matrix takes only a few minutes for low-dimensional problems, more specialized sparse matrix algorithms will be required to scale the diagnostic tool to massive, high-dimensional deep learning models.

Summary updated

BibTeX
@inproceedings{xu2023embracing,
  author = {Zuheng Xu and Trevor Campbell},
  title = {{Embracing the chaos: analysis and diagnosis of numerical instability in variational flows}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=87Nu9SagB7},
}
Figure