Skip to main content
QUICK REVIEW

[Paper Review] C3: Lightweight Incrementalized MCMC for Probabilistic Programs using Continuations and Callsite Caching

Daniel Ritchie, Andreas Stuhlmüller|arXiv (Cornell University)|Sep 7, 2015
Bayesian Modeling and Causal InferenceComputer Science9 references8 citations
TL;DR

C3 presents a lightweight, source-to-source transformation for probabilistic programming that accelerates Metropolis-Hastings inference by combining continuation-passing style (CPS) and callsite caching. This enables incrementalized re-execution of proposals, reducing proposal runtime by 20–100× and achieving constant-time updates in some models, with nearly 10× speedup on complex procedural modeling tasks.

ABSTRACT

Lightweight, source-to-source transformation approaches to implementing MCMC for probabilistic programming languages are popular for their simplicity, support of existing deterministic code, and ability to execute on existing fast runtimes. However, they are also slow, requiring a complete re-execution of the program on every Metropolis Hastings proposal. We present a new extension to the lightweight approach, C3, which enables efficient, incrementalized re-execution of MH proposals. C3 is based on two core ideas: transforming probabilistic programs into continuation passing style (CPS), and caching the results of function calls. We show that on several common models, C3 reduces proposal runtime by 20-100x, in some cases reducing runtime complexity from linear in model size to constant. We also demonstrate nearly an order of magnitude speedup on a complex inverse procedural modeling application.

Motivation & Objective

  • Address the inefficiency of existing lightweight MCMC frameworks that re-execute entire programs on every Metropolis-Hastings proposal.
  • Enable incrementalized proposal re-execution without sacrificing compatibility with fast deterministic runtimes or existing libraries.
  • Develop a source-to-source transformation that supports efficient, partial re-execution of probabilistic programs after random choice modifications.
  • Achieve significant performance improvements on common probabilistic models and complex real-world applications like inverse procedural modeling.
  • Provide a practical, open-source extension to WebPPL that integrates seamlessly with existing deterministic language toolchains.

Proposed method

  • Transform probabilistic programs into continuation-passing style (CPS) to allow re-execution to begin at any point in the call chain.
  • Implement callsite caching to avoid re-executing pure function calls when inputs and outputs remain unchanged across proposals.
  • Use a hybrid approach where random choice values are stored in a database (as in Lightweight MH), but re-execution is restricted to affected subtraces via CPS and caching.
  • Limit re-execution to only the parts of the program trace that depend on the changed random choice, leveraging Markov blanket structure implicitly.
  • Apply the CPS transformation and caching selectively at random choice points, avoiding full-program transformation overhead.
  • Integrate the system as a source-to-source compiler pass within the WebPPL probabilistic programming language.

Experimental results

Research questions

  • RQ1Can a lightweight, source-to-source transformation achieve incrementalized MCMC re-execution without requiring custom interpreters?
  • RQ2To what extent can continuation-passing style and callsite caching reduce proposal re-execution time in probabilistic programs?
  • RQ3Does the C3 approach enable constant-time updates in models where previous methods required linear-time re-execution?
  • RQ4How does C3 perform on complex, real-world applications such as inverse procedural modeling compared to baseline methods?
  • RQ5Can the performance gains of C3 be achieved while maintaining compatibility with existing deterministic language runtimes and libraries?

Key findings

  • C3 reduces proposal runtime by 20–100× on common models such as HMMs, topic models, Gaussian mixtures, and hierarchical linear regression.
  • In some models, C3 reduces the asymptotic complexity of proposal updates from linear in model size to constant time.
  • C3 achieves nearly a 10× speedup on a complex inverse procedural modeling application from computer graphics.
  • The combination of CPS and callsite caching allows re-execution to terminate early, skipping unaffected function calls and unwinding only from the relevant continuation.
  • Callsite caching alone reduces re-execution overhead by avoiding redundant function calls, while CPS enables targeted restarts from intermediate points.
  • The C3 system is implemented as an open-source extension to WebPPL, demonstrating practical integration with existing high-performance runtimes like V8.

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.