Skip to main content
QUICK REVIEW

[Paper Review] A Compilation Target for Probabilistic Programming Languages

Brooks Paige, Frank Wood|arXiv (Cornell University)|Mar 3, 2014
Bayesian Modeling and Causal InferenceComputer Science10 references43 citations
TL;DR

This paper introduces Probabilistic C, a portable, efficient intermediate representation for probabilistic programming that compiles to machine code using standard C compilers and POSIX system primitives like fork, processes, and shared memory. It enables scalable, parallel forward inference via sequential Monte Carlo and particle MCMC by leveraging operating system functionality, establishing a new path for systems-level optimization of probabilistic programming workloads.

ABSTRACT

Forward inference techniques such as sequential Monte Carlo and particle Markov chain Monte Carlo for probabilistic programming can be implemented in any programming language by creative use of standardized operating system functionality including processes, forking, mutexes, and shared memory. Exploiting this we have defined, developed, and tested a probabilistic programming language intermediate representation language we call probabilistic C, which itself can be compiled to machine code by standard compilers and linked to operating system libraries yielding an efficient, scalable, portable probabilistic programming compilation target. This opens up a new hardware and systems research path for optimizing probabilistic programming systems.

Motivation & Objective

  • To design a portable, efficient intermediate representation for probabilistic programming that can be compiled to machine code using standard compilers.
  • To enable scalable, parallel forward inference (e.g., SMC, particle MCMC) using only standard POSIX operating system primitives.
  • To establish a foundation for systems research on optimizing probabilistic programming performance through low-level hardware and OS optimizations.
  • To decouple inference strategy from high-level language design by providing a low-level compilation target.
  • To explore the performance trade-offs between process-based parallelism and alternative concurrency models in probabilistic inference.

Proposed method

  • Probabilistic C is a C library that extends standard C with macros for observe (conditioning on data likelihood) and predict (outputting posterior samples).
  • It uses the POSIX fork system call to implement parallel execution of program traces, enabling particle-based inference over execution paths.
  • The main function is wrapped via a macro to run the original program in a loop, simulating multiple particle executions for SMC and particle MCMC inference.
  • Inference is performed by spawning multiple processes, each executing a trace, with likelihoods computed via observe and results collected via predict.
  • The system relies on standard C compilers and POSIX-compliant OS libraries, ensuring portability across architectures.
  • It supports general-purpose probabilistic models, including Gaussian and HMMs, by combining random number generation with log-likelihood observation and posterior prediction.

Experimental results

Research questions

  • RQ1Can forward inference in probabilistic programming be efficiently and portably implemented using only standard POSIX system primitives like fork and shared memory?
  • RQ2Is process-based parallelism via fork a viable and performant foundation for scalable probabilistic inference systems?
  • RQ3How do system-level characteristics such as page size, memory management, and process scheduling affect the performance of probabilistic inference?
  • RQ4Can systems optimizations targeting process multiplexing and memory layout improve performance for probabilistic programming workloads?
  • RQ5What are the trade-offs between using processes (via fork) versus threads or user-level abstractions (e.g., delimited continuations) in terms of performance, portability, and statistical correctness?

Key findings

  • Probabilistic C successfully compiles to efficient, portable machine code using standard C compilers and POSIX system libraries.
  • The use of fork enables native parallelism for particle-based inference, supporting scalable execution on multi-core systems.
  • Performance is influenced by OS-level characteristics such as page size, with smaller pages potentially improving efficiency due to reduced copying overhead during stochastic variable assignment.
  • The system demonstrates that forward inference strategies like SMC and particle MCMC can be implemented efficiently using only standard OS primitives, without requiring language-level extensions.
  • Process synchronization overhead at observe barriers is a performance bottleneck, suggesting potential for optimized queue-based synchronization models.
  • The approach enables future systems research into architecture-specific optimizations, such as tuned page replacement policies for rapid process multiplexing across cores.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.