Abstract
In this paper, we investigate the impact of numerical instability on the reliability of sampling, density evaluation, and evidence lower bound (ELBO) estimation in variational flows. We first empirically demonstrate that common flows can exhibit a catastrophic accumulation of error: the numerical flow map deviates significantly from the exact map—which affects sampling—and the numerical inverse flow map does not accurately recover the initial input—which affects density and ELBO computations. Surprisingly though, we find that results produced by flows are often accurate enough for applications despite the presence of serious numerical instability. In this work, we treat variational flows as dynamical systems, and leverage shadowing theory to elucidate this behavior via theoretical guarantees on the error of sampling, density evaluation, and ELBO estimation. Finally, we develop and empirically test a diagnostic procedure that can be used to validate results produced by numerically unstable flows in practice.
1. Introduction
Modern variational flows, such as normalizing flows, have become a cornerstone of probabilistic machine learning, enabling the modeling of complex distributions by stacking hundreds or thousands of transformations. However, this depth introduces a significant challenge: numerical instability. Each layer in a flow introduces tiny rounding errors due to finite floating-point precision. Standard error analysis suggests that in chaotic systems, these errors should compound exponentially, eventually rendering the output of the flow meaningless.
In practice, however, a paradox emerges. Researchers have observed that even when a flow is so numerically unstable that it fails to satisfy its own invertibility requirements, it still generates high-quality samples and accurate Evidence Lower Bound (ELBO) estimates. This paper resolves this contradiction by treating variational flows as discrete-time dynamical systems and applying the lens of shadowing theory.
2. The Paradox of Numerical Chaos
Numerical instability in flows manifests in two primary ways. First, the forward numerical map deviates from the exact theoretical map, which should theoretically degrade sampling quality. Second, the numerical inverse map fails to recover the original input, which is critical for density estimation and ELBO calculation.
Our empirical analysis confirms that in standard deep flows, forward and backward trajectories deviate from exact paths exponentially quickly. After approximately 100 layers, the accumulated error often reaches the same scale as the data itself. Despite this "numerical chaos," the statistical properties of the model—such as sample averages and ELBO estimates—remain remarkably stable, often maintaining relative errors of less than 1%.
3. Shadowing Theory in Variational Flows
To explain why "garbage" trajectories yield "beautiful" statistics, we turn to Shadowing Theory. In the study of chaotic dynamical systems, a "pseudo-orbit" ( the path calculated with numerical error) may quickly veer away from the "exact orbit" starting at the same initial point. However, the shadowing property asserts that there often exists a different exact orbit, starting from a slightly different initial point, that stays very close to the numerical path for a long duration.
3.1 Theoretical Guarantees
By leveraging this property, we derive new error bounds for three core tasks:
- i.i.d. Sampling: Ensuring generated samples represent the target distribution.
- Density Evaluation: Validating the log-likelihood of data points.
- ELBO Estimation: Ensuring the variational objective remains a reliable proxy for the marginal likelihood.
Unlike traditional bounds that grow exponentially with the number of layers ($N$), these shadowing-based bounds are controlled by a "shadowing window" ($\epsilon$). Our analysis shows that $\epsilon$ typically grows much more slowly (often linearly) with $N$, explaining the sustained accuracy of deep flows.
4. Diagnostic Procedure
We provide a practical method for practitioners to verify the reliability of their flows. The diagnostic involves calculating the size of the shadowing window ($\epsilon$) by computing the minimum eigenvalue of a large, block-tridiagonal matrix derived from the Jacobians of the flow’s layers. This tool can verify the shadowing property in seconds for synthetic examples and a few minutes for complex, real-world models, serving as a vital sanity check for numerical integrity.
5. Empirical Validation
We validated our theory and diagnostic tool across several benchmarks, including synthetic targets (Banana and Cross distributions) and real-world Bayesian inference tasks (Linear and Logistic regression using the Oxford Parkinson’s Disease and Bank Marketing datasets).
Key Findings:
- Shadowing Window Scale: For flows exceeding 1,000 layers, the shadowing window ($\epsilon$) was often as small as $10^{-10}$ or $10^{-11}$, even when raw trajectory errors were massive.
- Architecture Comparisons: We compared MixFlows and Hamiltonian Variational Flows (HamFlows). MixFlows generally exhibited smoother log-densities and smaller shadowing errors, whereas HamFlows showed more drastic fluctuations.
- Statistical Stability: Across all test cases, the relative error for sample averages remained consistently low, confirming that trajectory error is a poor proxy for statistical error.
6. Conclusion and Future Work
This work demonstrates that numerical non-invertibility does not necessarily invalidate the statistical utility of variational flows. As long as a numerical path "shadows" some valid exact path, the resulting distribution remains accurate.
Future research should extend this analysis to the training phase, as our current work focuses on post-training reliability. Additionally, extending these theoretical guarantees to continuous-time models, such as Neural ODEs, and optimizing the computational efficiency of the diagnostic tool for high-dimensional models remain important next steps.
Summary updated