Abstract
Universal Probabilistic Programming Languages (PPLs) provide the flexibility to express complex statistical models with varying numbers of random variables. However, executing these models efficiently on massively parallel hardware like GPUs has remained a significant challenge. This paper presents a novel compilation framework that bridges the gap between high-level universal PPLs and low-level GPU execution. By introducing PPL Control-Flow Graphs (PCFGs), the authors enable efficient Sequential Monte Carlo (SMC) inference on GPUs, achieving up to 6x speedups over existing state-of-the-art systems.
Introduction
Probabilistic Programming Languages (PPLs) automate the process of statistical inference, allowing researchers to focus on model definition. A long-standing trade-off exists between "universality"—the ability to handle any computable model—and performance. Universal PPLs typically rely on high-level language features like continuations or coroutines to manage execution "checkpoints" during inference. These features are difficult to map onto the rigid, block-based execution model of GPUs. Consequently, previous GPU-accelerated PPLs were often restricted to non-universal models or lacked support for Sequential Monte Carlo (SMC) inference.
The PCFG Compilation Strategy
The authors address this challenge through a three-tiered toolchain that transforms high-level probabilistic code into optimized C++ and CUDA.
The process begins with Miking CorePPL, an intermediate representation based on lambda calculus with probabilistic extensions (assume, observe, weight). The core innovation is the PPL Control-Flow Graph (PCFG). The compiler decomposes functions into basic blocks where checkpoints (points where the inference engine must pause for resampling or recording) are restricted to the "tail position" at the end of a block.
This structure allows the low-level RootPPL framework to manage program state explicitly. By stopping at the end of a block and consulting a manually managed call stack to determine the next block, the system can "pause" and "resume" execution efficiently across thousands of parallel "particles" on a GPU.
Evaluation and Models
The framework was evaluated using complex, real-world models:
- Phylogenetics: A Constant-Rate Birth-Death (CRBD) model used to estimate evolutionary rates from recursive tree structures, tested on Kingfisher and Tyrant flycatcher datasets.
- Epidemiology: A SEIR (Susceptible, Exposed, Infectious, Recovered) model of a dengue outbreak, tracking disease dynamics in both mosquito and human populations.
The use of weight and observe statements, as illustrated in the comparison of geometric distributions above, allows the model to incorporate evidence and shift probability mass, a process handled efficiently by the compiled SMC engine.
Key Results and Insights
The compiled CorePPL and hand-tuned RootPPL were compared against industry standards including Birch, WebPPL, and Pyro.
- Performance: On the CRBD model with one million particles, RootPPL on a GPU outperformed Birch (running on a 24-thread CPU) by approximately 6x.
- Scalability: The system successfully handled recursive models that caused significant overhead in Python-based PPLs like Pyro.
- Hardware Efficiency: Explicit memory management and data layout (memory coalescing) ensured that the thousands of parallel particles utilized GPU bandwidth effectively.
Conclusion and Future Work
This work demonstrates that universality in PPLs does not have to come at the cost of performance. By using PCFGs to manage control flow and checkpoints, universal models can be compiled for high-performance parallel execution.
Current limitations include a lack of dynamic heap-based memory management (garbage collection) and the inability to pass distributions as first-class objects. Future research will focus on addressing these memory challenges and extending the PCFG framework to support other inference methods, such as Markov Chain Monte Carlo (MCMC).
Summary updated