Introduction
Probabilistic Programming Languages (PPLs) have revolutionized the development of Bayesian models by allowing high-level specifications of complex stochastic processes. However, deploying these models on continuous data streams—such as live sensor feeds in robotics or avionics—presents a significant challenge: ensuring the program operates within fixed memory bounds. A common inference technique, "delayed sampling," combines symbolic math with approximate sampling to improve efficiency. Yet, because it maintains a dynamic graph of dependencies between random variables, it risks unbounded memory growth if dependencies are not properly managed. This paper introduces a static analysis framework to mathematically guarantee bounded-memory execution for such streaming programs.
The Memory Challenge in Delayed Sampling
Delayed sampling works by deferring the sampling of random variables as long as possible, maintaining them in a symbolic state within a Bayesian network. While efficient, this graph can grow indefinitely in a streaming context if the program continuously introduces new variables without "consuming" (observing or evaluating) old ones. Unlike standard garbage collection, memory growth here is a dataflow issue: even if a variable is no longer explicitly referenced in the code, its influence may remain trapped in a chain of symbolic dependencies that the inference engine must track.
Formalizing Bounded Memory
To address this, the authors identify two fundamental properties required for bounded memory:
- $m$-consumed property: Every random variable must be consumed (either observed or sampled) within a fixed number of steps $m$.
- Unseparated paths property: There must be a finite limit on the length of dependency chains maintained in the program's state. Even if variables are consumed, they might still form part of an ever-growing symbolic chain if not "separated" by specific observation patterns.
Static Analysis via Iterative Fixed-Point Analysis
The core contribution is a type-based static analysis that abstracts program execution into an abstract graph. Since streaming programs are typically recursive, the analysis employs an iterative fixed-point approach to determine if the dependency graph stabilizes.
As shown in the figure above, the analysis "simulates" the program's steps. It tracks how dependencies propagate from one iteration to the next. If the length of unseparated paths converges to a stable value within a few iterations, the program is verified as safe. If the paths continue to grow, the analysis flags a potential memory leak.
Evaluation and Results
The framework was evaluated on nine benchmarks from the ProbZelus streaming PPL, including Kalman filters, robot controllers, and multi-target trackers. The analysis correctly identified the memory behavior in eight of the nine cases. It successfully verified standard tracking models and correctly rejected "pathological" variants designed to leak memory, such as a Gaussian Random Walk.
The analysis is notably efficient; for all benchmarks where it converged, it did so within ten iterations. The single failure occurred on a SLAM (Simultaneous Localization and Mapping) benchmark. The analysis conservatively flagged it as unbounded because it could not prove that every element in a large map array would eventually be observed, highlighting a limitation in handling complex data structures.
Conclusion
This work provides a critical safety net for probabilistic streaming. By formalizing the conditions for bounded memory and providing an automated tool to check them, the authors move PPLs closer to being viable for safety-critical, real-time embedded systems. Future work aims to improve precision for arrays and handle more complex control flow, further expanding the range of verifiable models.
Summary updated