InferSpark: Statistical Inference at Scale

Zhuoyue Zhao, Jialing Pei, Kenny Q. Zhu, Eric Lo, Chris Liu

TL;DR

InferSpark is a probabilistic programming framework that brings the flexibility of custom Bayesian modeling to the massive scale of Apache Spark. It allows researchers to define complex statistical models in just a few lines of Scala code and automatically generates optimized, distributed inference algorithms that can handle datasets far beyond the reach of single-machine tools.

What Problem Does This Paper Address?

Statistical inference—the process of deducing the properties of an underlying distribution from data—is a cornerstone of modern data science. However, practitioners often face a "flexibility vs. scale" trade-off.

Standard machine learning libraries like Spark’s MLlib are highly optimized but offer a limited "menu" of fixed models (like standard LDA or linear regression). If you need a custom model, you have to derive the math and write complex distributed code from scratch, which is tedious and error-prone. On the other hand, Probabilistic Programming Languages (PPLs) like Infer.NET allow for easy custom model definition but are typically restricted to a single machine. When datasets grow large, these PPLs quickly run out of memory.

InferSpark bridges this gap by providing a PPL that compiles directly into distributed execution plans on Apache Spark.

Methods

The authors introduce a system that automates the "plumbing" of distributed statistical inference:

  1. Succinct Syntax: InferSpark extends Scala with a small set of probabilistic constructs. A model that takes over 500 lines of code in MLlib can be expressed in just 7 lines in InferSpark.
  2. Variational Message Passing (VMP): The system uses VMP as its primary inference engine. VMP is a deterministic, graph-based algorithm that is well-suited for distributed environments because it can be framed as a series of local message updates.
  3. The InferSpark Compiler: The framework parses the model definition into a "Bayesian Network Template." At runtime, it collects metadata (like data size) to instantiate a Message Passing Graph (MPG).
  4. Custom Partitioning Strategy: Standard graph partitioning in Spark's GraphX often performs poorly for inference because the graphs have a specific bipartite-like structure (connecting many observations to a few hidden variables). InferSpark uses a "tailor-made" partitioning strategy that minimizes vertex replication and shuffling, significantly boosting performance.

Datasets

The authors evaluated InferSpark using three different models across several real-world datasets:

  • Latent Dirichlet Allocation (LDA): Tested on subsets of Wikipedia (up to 1.3 million words).
  • Sentence-LDA (SLDA): Tested on Amazon reviews (up to 600k words).
  • Dirichlet Compound Multinomial LDA (DCMLDA): Tested on larger Wikipedia subsets (up to 2.6 million words).

Key Insights and Ideas

  • Abstraction is Power: By using a host language like Scala, InferSpark allows users to mix normal data preprocessing with probabilistic modeling in a single program.
  • Scaling Out vs. Scaling Up: The authors demonstrate that while a tool like Infer.NET is fast, it hits a "memory wall" very quickly. InferSpark’s ability to distribute the model across a cluster allows it to process datasets that are physically impossible to fit on a single commodity server.
  • The "Aha" Moment on Partitioning: The researchers found that standard 1D or 2D edge partitioning strategies in GraphX caused massive overhead for VMP. Their insight was to co-locate edges that link to the same observation, ensuring that most updates happen locally within a partition.

Key Results

  • Scalability: InferSpark successfully ran inference on models where Infer.NET failed due to memory limits (e.g., an LDA model with 96 topics on 3% of Wikipedia).
  • Linear Scale-out: The system showed near-linear speedup as more nodes were added to the cluster. For example, doubling the nodes roughly halved the total running time for LDA and SLDA.
  • Efficiency vs. Flexibility: While InferSpark is slower than the hand-optimized, fixed-model implementations in MLlib (which uses a simpler EM algorithm), it provides the only viable way to run custom models like SLDA or DCMLDA at Spark scale without months of manual engineering.

Limitations and Future Work

The current prototype of InferSpark has a few notable constraints:

  • Model Support: It is currently limited to Bayesian networks within the "exponential-conjugate family" (e.g., mixtures of Categorical distributions with Dirichlet priors).
  • Inference Algorithms: Only Variational Message Passing is supported. The authors plan to incorporate other popular algorithms like Gibbs Sampling (MCMC) and Belief Propagation in the future.
  • Variable Types: The system primarily handles discrete random variables; support for continuous variables and non-conjugate priors is a goal for future versions.

Summary updated

BibTeX
@inproceedings{zhao2019inferspark,
  author = {Zhuoyue Zhao and Jialing Pei and Kenny Q. Zhu and Eric Lo and Chris Liu},
  title = {{InferSpark: Statistical Inference at Scale}},
  booktitle = {BigComp},
  year = {2019},
  url = {https://openreview.net/forum?id=dyIgMvlo3M},
}
Figure