[Paper Review] Swift: compiled inference for probabilistic programming languages
Swift is a compiler for the BLOG probabilistic programming language that eliminates runtime interpretation overhead through static optimizations, efficiently manages dynamic dependencies and variable-sized possible worlds, and achieves 12x to 326x speedups over existing PPL inference engines on diverse inference workloads.
A probabilistic program defines a probability measure over its semantic structures. One common goal of probabilistic programming languages (PPLs) is to compute posterior probabilities for arbitrary models and queries, given observed evidence, using a generic inference engine. Most PPL inference engines--even the compiled ones--incur significant runtime interpretation overhead, especially for contingent and open-universe models. This paper describes Swift, a compiler for the BLOG PPL. Swift-generated code incorporates optimizations that eliminate interpretation overhead, maintain dynamic dependencies efficiently, and handle memory management for possible worlds of varying sizes. Experiments comparing Swift with other PPL engines on a variety of inference problems demonstrate speedups ranging from 12x to 326x.
Motivation & Objective
- To reduce the significant runtime interpretation overhead inherent in existing probabilistic programming language (PPL) inference engines, especially for contingent and open-universe models.
- To enable efficient compilation of probabilistic programs by statically analyzing and optimizing dynamic dependencies and memory allocation across possible worlds.
- To maintain correctness and expressiveness while achieving high performance through static compilation, avoiding the performance penalties of runtime interpretation.
- To demonstrate that compiled inference can outperform existing generic inference engines across a broad range of probabilistic inference problems.
Proposed method
- Compiles BLOG programs into efficient low-level code that eliminates the need for runtime interpretation of probabilistic constructs.
- Applies static analysis to identify and encode dynamic dependencies between random variables and evidence at compile time.
- Generates code that manages memory for possible worlds of varying sizes using optimized allocation strategies.
- Introduces a compilation pipeline that preserves the semantics of the original probabilistic program while enabling high-performance execution.
- Uses a combination of type inference and control-flow analysis to guide optimizations and ensure correctness in the compiled output.
- Employs a custom intermediate representation that tracks possible world creation and evidence propagation for efficient inference.
Experimental results
Research questions
- RQ1Can static compilation eliminate the performance overhead of runtime interpretation in probabilistic programming languages?
- RQ2How effectively can a compiler manage dynamic dependencies and variable-sized possible worlds in contingent and open-universe models?
- RQ3What performance improvements can be achieved by compiling a PPL like BLOG compared to existing inference engines?
- RQ4Does the compiled approach scale effectively across diverse probabilistic inference problems with varying complexity?
Key findings
- Swift achieves speedups of 12x to 326x over existing PPL inference engines on a range of inference problems.
- The elimination of interpretation overhead leads to substantial performance gains, particularly in models with complex dynamic dependencies.
- Memory management for possible worlds of varying sizes is efficiently handled through static compilation and optimized allocation strategies.
- The approach maintains correctness and expressiveness while significantly outperforming both interpreted and compiled inference engines in benchmark workloads.
- The performance gains are most pronounced in contingent and open-universe models, where interpretation overhead is typically highest.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.