Reactive probabilistic programming

Guillaume Baudart, Louis Mandel, Eric Atkinson, Benjamin Sherman, Marc Pouzet, Michael Carbin

TL;DR

ProbZelus is the first synchronous probabilistic programming language designed specifically for reactive systems like robot controllers and fly-by-wire software. It introduces "inference-in-the-loop," allowing deterministic control logic to use real-time probabilistic estimates, and features a novel "Streaming Delayed Sampling" algorithm that enables exact inference over infinite streams in constant memory.

What Problem Does This Paper Address?

Modern safety-critical systems (e.g., autonomous vehicles, drones) rely on synchronous languages like Lustre or SCADE to ensure predictable, real-time behavior. However, these languages are strictly deterministic. In the real world, these systems must navigate uncertainty—noisy sensors, unpredictable environments, and partially unknown physical models.

While Probabilistic Programming Languages (PPLs) exist to handle uncertainty, they are typically designed for "one-off" computations on finite data. Applying them to reactive systems—which run indefinitely on infinite streams—poses two major hurdles:

  1. Inference-in-the-loop: The system needs to perform inference at every time step and immediately use those results to make control decisions.
  2. Memory Exhaustion: Standard inference techniques, like Delayed Sampling, often build dependency graphs that grow linearly over time, eventually crashing long-running reactive programs.

Methods

The authors present ProbZelus, an extension of the synchronous language Zelus.

Language Design & Semantics

ProbZelus uses a simple type system to separate deterministic code (standard control logic) from probabilistic code (models of uncertainty). It introduces three core constructs:

  • sample(d): Draws a value from a distribution.
  • observe(d, y): Conditions the model based on an actual observation $y$.
  • infer(m): The bridge that runs a probabilistic model $m$ and returns a distribution of results to the deterministic side.

Streaming Delayed Sampling (SDS)

The paper’s technical centerpiece is a new inference algorithm. Standard Delayed Sampling (DS) is a hybrid technique that uses symbolic math to solve parts of a model exactly (like a Kalman filter) while using particles for the rest. However, DS keeps every random variable in a growing Bayesian network.

SDS solves this by using a pointer-minimal graph representation. It identifies nodes that are no longer referenced by the program and prunes them once their influence has been mathematically propagated. This allows SDS to maintain the accuracy of symbolic inference while operating in constant memory for a large class of models.

Evolution of the delayed sampling graph. SDS prunes nodes that are no longer referenced, preventing linear memory growth.

Datasets

The authors evaluated ProbZelus on several reactive benchmarks:

  • Beta-Bernoulli & Gaussian-Gaussian: Classic parameter estimation tasks.
  • Kalman-1D & Outlier: Trajectory tracking, including scenarios with faulty sensors.
  • Robot Navigation: A closed-loop system where a robot uses a Linear-Quadratic Regulator (LQR) based on inferred state.
  • SLAM (Simultaneous Localization and Mapping): A robot building a map while tracking its position.
  • MTT (Multi-Target Tracker): Tracking a variable number of moving objects amidst "clutter" (false detections).

Key Insights and Ideas

  • Synchronous Inference: By treating inference as a stateful stream processor, ProbZelus allows "inference-in-the-loop." A controller can ask "Where am I?" at step $T$, get a distribution, and use the mean to decide "Where should I go?" at step $T+1$.
  • Symbolic Efficiency: SDS demonstrates that you don't always need thousands of particles for accuracy. If the model has conjugate relationships (e.g., Gaussian-Gaussian), SDS can compute the exact posterior with just a single particle.
  • Pruning for Longevity: The transition from linear to constant memory growth is the "aha moment" for reactive PPLs. Without this, PPLs are toys for reactive systems; with it, they are viable for long-term deployment.
Memory consumption comparison: Standard Delayed Sampling (DS) grows linearly, while Streaming Delayed Sampling (SDS) remains constant.

Key Results

  • Accuracy vs. Particles: On the robot navigation task, SDS achieved perfect accuracy with 1 particle, whereas a standard Particle Filter (PF) required over 100 particles to even approach similar error levels.
  • Massive Speedups: For complex tasks like SLAM, SDS reached target accuracy levels $10^4$ times faster than a standard particle filter, which often timed out before reaching the goal.
  • Bounded Resources: The experiments confirmed that SDS maintains constant memory and execution time per step, even after 500+ steps, whereas standard DS latency and memory grew uncontrollably.
Performance comparison showing SDS achieving higher accuracy with far fewer particles than a standard Particle Filter.

Limitations and Future Work

  • Unbounded Chains: SDS isn't magic. If a programmer keeps a reference to a variable that is never "realized" (sampled or observed), an unbounded dependency chain can still form, leading to memory growth. The authors suggest using a "sliding window" or manual eval calls to mitigate this.
  • Continuous Time: ProbZelus currently operates on discrete time steps. Extending this to continuous-time models (using Ordinary Differential Equations) is a noted area for future research.
  • Model Constraints: SDS relies on specific mathematical relationships (conjugacy) to perform symbolic pruning. Models that lack these properties will revert to behaving like standard particle filters.

Summary updated

BibTeX
@inproceedings{baudart2020reactive,
  author = {Guillaume Baudart and Louis Mandel and Eric Atkinson and Benjamin Sherman and Marc Pouzet and Michael Carbin},
  title = {{Reactive probabilistic programming}},
  booktitle = {PLDI},
  year = {2020},
  doi = {10.1145/3385412.3386009},
}
Figure