Introduction
Probabilistic programming systems (PPS) aim to automate statistical inference, yet they often face a divide between exact algorithms (like Kalman filters) and approximate methods (like Variational Inference). While modern deep learning leverages tensors for their parallelization and automatic differentiation capabilities, standard tensors are limited to discrete data. This paper introduces Funsors (functional tensors), a new software abstraction that bridges this gap by unifying discrete tensors with continuous probability distributions.
The Funsor Framework
Funsors are defined as a first-order language of arrays and indices. The framework relies on three "algebraically closed" atomic types: Tensor (for discrete data), Gaussian (for multivariate normal distributions), and Delta (for point masses).
The core innovation lies in Nonstandard Interpretations. Rather than a single evaluation path, Funsors use a dispatch mechanism to apply different strategies:
- EXACT: Eagerly computes algebraic results.
- LAZY: Constructs a computation graph for deferred optimization.
- OPTIMIZE: Employs variable elimination to minimize contraction costs.
- MONTECARLO / MOMENTMATCHING: Automatically approximates intractable integrals using sampling or Gaussian moments.
Parallel Inference and the Markov Product
A significant contribution of this work is the Markov Product, a novel operation that unifies independent repetitions ("plates") and sequential dependencies (Markov chains). By formalizing these dependencies, the system can utilize parallel-scan algorithms to perform filtering in $O(\log T)$ time, where $T$ is the sequence length. This transforms traditionally sequential tasks into highly parallelizable operations suitable for modern GPUs.
Experimental Results
The authors evaluated Funsors across diverse datasets, including GPS tracking of harbor seals, EEG time-series, and high-dimensional BART ridership data.
Key findings include:
- Massive Speedups: For hierarchical HMMs, the parallel-scan implementation achieved speedups of over 100x compared to sequential variable elimination.
- Logarithmic Scalability: Experiments with synthetic "fake seal" data confirmed that computation time scales logarithmically with sequence length, allowing for the analysis of much longer sequences on GPUs.
- Mixed Inference Success: In the BART ridership task, the framework successfully combined black-box variational inference with exact marginalization of latent states, handling over 78 million observations.
- SLDS Precision: The
MOMENTMATCHINGinterpretation allowed for high-precision handling of Switching Linear Dynamical Systems, which are typically analytically intractable.
Conclusion
Funsors provide a powerful Intermediate Representation (IR) for probabilistic programming, treating continuous variables with the same algebraic elegance as discrete tensors. While currently limited to first-order logic and a specific set of distributions, future work aims to extend the language to support complex control flows and a broader range of continuous distributions.
Summary updated