From high-level inference algorithms to efficient code

Rajan Walia, Praveen Narayanan, Jacques Carette, Sam Tobin-Hochstadt, Chung-chieh Shan
5/17/2018
cs.PLmath.PR

Official code: hakaru-dev/hakaru (319 stars, BSD-3-Clause, last commit 2026-03-31). 1 more implementation below.

Abstract

Probabilistic programming languages are valuable because they allow domain experts to express probabilistic models and inference algorithms without worrying about irrelevant details. However, for decades there remained an important and popular class of probabilistic inference algorithms whose efficient implementation required manual low-level coding that is tedious and error-prone. They are algorithms whose idiomatic expression requires random array variables that are latent or whose likelihood is conjugate. Although that is how practitioners communicate and compose these algorithms on paper, executing such expressions requires eliminating the latent variables and recognizing the conjugacy by symbolic mathematics. Moreover, matching the performance of handwritten code requires speeding up loops by more than a constant factor. We show how probabilistic programs that directly and concisely express these desired inference algorithms can be compiled while maintaining efficiency. We introduce new transformations that turn high-level probabilistic programs with arrays into pure loop code. We then make great use of domain-specific invariants and norms to optimize the code, and to specialize and JIT-compile the code per execution. The resulting performance is competitive with manual implementations.

View on arXivView PDF

Code Implementations(2)

hakaru-dev/hakaruOfficial100%
BSD-3-Clause

A probabilistic programming language

31929TeX, PerlDec 19, 20146 months agoBSD-3-Clause
bayesian-statisticshaskellmachine-learningmapleprobabilistic-programming
rjnw/shamOfficial100%
MIT

A DSL for runtime code generation in racket

706C++, RacketNov 1, 20164 years agoMIT
compiler-tooljitracketracket-ffiracket-library

Cite this paper

@article{walia2018from,
  title  = {From high-level inference algorithms to efficient code},
  author = {Rajan Walia and Praveen Narayanan and Jacques Carette and Sam Tobin-Hochstadt and Chung-chieh Shan},
  year   = {2018},
  eprint = {1805.06562},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1805.06562}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1805.06562.svg)](https://codeofpaper.com/paper/1805.06562)

Discussion