Simple, Distributed, and Accelerated Probabilistic Programming

Dustin Tran, Matthew D. Hoffman, Dave Moore, Christopher Suter, Srinivas Vasudevan, Alexey Radul, Matthew J. Johnson, Rif A. Saurous

Abstract

We describe a simple, low-level approach for embedding probabilistic programming in a deep learning ecosystem. In particular, we distill probabilistic programming down to a single abstraction—the random variable. Our lightweight implementation in TensorFlow enables numerous applications: a model-parallel variational auto-encoder (VAE) with 2nd-generation tensor processing units (TPUv2s); a data-parallel autoregressive model (Image Transformer) with TPUv2s; and multi-GPU No-U-Turn Sampler (NUTS). For both a state-of-the-art VAE on 64x64 ImageNet and Image Transformer on 256x256 CelebA-HQ, our approach achieves an optimal linear speedup from 1 to 256 TPUv2 chips. With NUTS, we see a 100x speedup on GPUs over Stan and 37x over PyMC3.

Introduction

For years, a "hard line" has existed between deep learning and probabilistic programming (PP). Deep learning researchers treat models as flexible, hardware-accelerated computational graphs, while the PP community has often treated models as "black boxes" where a user specifies a program and then runs a separate, automated "inference query."

This separation makes it incredibly difficult to scale probabilistic models. Traditional Probabilistic Programming Languages (PPLs) like Stan or PyMC3 struggle to exploit modern hardware like Tensor Processing Units (TPUs) or to implement "model-parallelism," where a single model is split across multiple chips. As models grow to billions of parameters, the "inference as a closed system" approach becomes a bottleneck for research flexibility and computational performance.

The Edward2 Library

Edward2 is a lightweight probabilistic programming library that distills the entire field down to a single abstraction: the random variable. By embedding this abstraction directly into the TensorFlow ecosystem, probabilistic models can scale across hundreds of TPUs and GPUs.

Random Variable Abstraction and Tracing

In Edward2, a random variable is a Python function wrapping a distribution. It can behave like a sample for generative processes or provide its log-density for inference. The core of the library is a tiny tracing mechanism that uses a Python context manager to intercept execution. This allows users to "mutilate" a program for causal inference, calculate log-joint densities, or align variables between a model and an inference network without changing the original model code.

Hardware-Native Design

Because it is built on TensorFlow, Edward2 leverages standard TF operations and TPU-specific ops to handle data and model parallelism. It supports both "Graph mode" for maximum performance and "Eager mode" for dynamic control flow, essential for algorithms like the No-U-Turn Sampler (NUTS).

Implementation of a distributed autoregressive flow in Edward2, demonstrating native TPU device placement.

Performance and Scaling

The system was evaluated using high-dimensional benchmarks including 64x64 ImageNet for model-parallel VAEs, 256x256 CelebA-HQ for data-parallel Image Transformers, and the Covertype dataset for Bayesian logistic regression using NUTS.

Linear Scaling on TPUs

A significant milestone for PPLs is the ability to scale in distributed environments. For both the VAE and the Image Transformer, Edward2 achieved optimal linear speedup as it scaled from 1 to 256 TPUv2 chips. This performance is achieved with negligible overhead compared to handwritten TensorFlow code.

Scaling performance on TPU v2 chips, showing linear speedup in examples processed per second.

GPU Acceleration

When running NUTS on GPUs, Edward2 demonstrated massive speedups: 100x faster than Stan and 37x faster than PyMC3 (both running on multi-threaded CPUs). This highlights the advantage of blurring the line between the model and the underlying computation graph.

Conclusion

Edward2 demonstrates that simplicity scales. By stripping away complex inference engines and focusing on the random variable, probabilistic models can live within the same ecosystem as modern optimizers and hardware. While it requires more manual effort for inference loop design compared to "plug-and-play" tools, it enables the pursuit of "giant" probabilistic models with over 1 trillion parameters and high-resolution image generation.

Summary updated

BibTeX
@inproceedings{tran2018simple,
  author = {Dustin Tran and Matthew D. Hoffman and Dave Moore and Christopher Suter and Srinivas Vasudevan and Alexey Radul and Matthew J. Johnson and Rif A. Saurous},
  title = {{Simple, Distributed, and Accelerated Probabilistic Programming}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=rkZ5rvWdbH},
}
Figure