Fast Parallel SAME Gibbs Sampling on General Discrete Bayesian Networks

Daniel Seita, Haoyu Chen, John CannyarXiv 2015

TL;DR

This paper introduces a high-performance, parallel Gibbs sampler for discrete Bayesian networks that leverages State Augmented Marginal Estimation (SAME) to achieve faster convergence and higher-quality parameter estimates. By combining GPU acceleration with clever graph-coloring parallelization, the authors' implementation (part of the BIDMach library) outperforms the industry-standard JAGS sampler by up to two orders of magnitude while handling datasets far too large for traditional tools.

What Problem Does This Paper Address?

Performing inference on Bayesian networks—calculating the probability of hidden variables given observed data—is a cornerstone of machine learning. However, exact inference is computationally prohibitive (exponential time). Researchers usually choose between fast but biased approximate methods (like Variational Bayes) or accurate but slow Markov Chain Monte Carlo (MCMC) methods like Gibbs sampling.

Historically, Gibbs sampling has been considered too slow for "Big Data." It often struggles with slow convergence and high variance in high-dimensional spaces. The authors aim to bridge this gap, making Gibbs sampling a viable, high-speed option for large-scale, general discrete Bayesian networks.

Methods

The authors propose three main pillars to modernize Gibbs sampling:

  1. SAME (State Augmented Marginal Estimation): Instead of sampling from the standard posterior, SAME replicates latent states $m$ times, all tied to the same parameters. This "sharpens" the distribution's peaks, helping the sampler concentrate on global modes. Effectively, it acts as a temperature control that can be used to anneal the sampler toward high-quality Maximum A Posteriori (MAP) estimates.
  2. Chromatic Partitioning: To parallelize the process, the authors use graph coloring on the "moralized" version of the Bayesian network. Nodes with the same color are conditionally independent given their neighbors, allowing all nodes of one color to be sampled simultaneously across multiple CPU or GPU cores.
  3. Matrix-Based GPU Acceleration: The sampler is implemented in the BIDMach library. It treats the sampling process as a series of large-scale matrix multiplications, which are highly optimized for GPUs. It also uses a minibatch system and matrix caching to process data that is much larger than the available GPU memory.
Figure 1: This visualizes our Gibbs sampler at work. The original data is split into four minibatches of equal sizes (for caching purposes), with each having some known data (shaded gray) and unknown data (white). For each minibatch, the sampler replicates the data three times (m = 3), samples the unknown values, and then uses those with the prior to update its estimate of the CPTs.

Datasets

The implementation was evaluated on three distinct datasets:

  • Synthetic "Koller" Data: A small, 5-variable network from standard textbooks used to verify correctness and the impact of the SAME parameter $m$.
  • Synthetic MOOC Data: Data generated via forward sampling from parameters learned from real-world student data, used to test performance across different levels of data sparsity.
  • Real MOOC Data: A dataset from the Dynamic Learning Maps (DLM) project containing responses from 4,367 students to 319 questions, mapped to 15 latent concepts. This dataset is extremely sparse (only 2.2% of values are known).

Key Insights and Ideas

  • SAME as Annealing: The replication factor $m$ in SAME is formally equivalent to temperature. Increasing $m$ reduces the variance derived from discrete sample quantization, essentially allowing the sampler to "zoom in" on the most likely parameter values.
  • Throughput vs. Latency: By fusing graphical structures and SAME-replicated states into large matrices, the authors hide GPU kernel overhead. This shifts the bottleneck from the complexity of the graph to the raw computational throughput of the hardware.
  • Out-of-Memory Scaling: Unlike traditional samplers that build explicit graph structures in memory (like JAGS), this approach maintains only model-related state. This allows it to scale to millions of instances by streaming data from disk or network storage.

Key Results

The authors compared their BIDMach implementation against JAGS, the state-of-the-art tool for Bayesian graphical models:

  • Speed: On the synthetic Koller data, BIDMach was roughly 4x faster than JAGS on a CPU. When moving to the GPU and larger datasets, the gap widened significantly. On the MOOC dataset, BIDMach (GPU) was approximately 29x to 66x faster than JAGS.
  • Scalability: When the MOOC data was replicated 40 times to simulate a larger dataset, JAGS ran out of memory (OOM) on a 64GB machine. BIDMach handled the same data using only 11.4% of the system RAM.
  • Accuracy: As shown in Figure 2, both samplers converge to similar KL-divergence values (a measure of how close the estimated distribution is to the true one), but BIDMach achieves this much faster in terms of wall-clock time.
Figure 2: Plots of our KLavg curves as a function of the iteration, on Koller data (these must be viewed in color). Both BIDMach and JAGS converge to the true CPTs quickly, but JAGS appears to benefit more from the extra data replication with SAME parameters m = 5 and m = 10.

Limitations and Future Work

  • Local Optima: While SAME helps find modes, setting the replication factor $m$ too high can turn the sampler into a version of Expectation-Maximization (EM), which is prone to getting stuck in poor local optima.
  • GPU Memory: While the system handles large datasets via minibatches, the primary limiting factor for the model size (number of variables and CPT sizes) remains the physical memory of the GPU.
  • Future Directions: The authors suggest exploring the application of this fast sampler to a wider variety of real-world datasets and potentially extending the framework to handle non-discrete variables.

Summary updated

BibTeX
@misc{seita2015fast,
  author = {Daniel Seita and Haoyu Chen and John Canny},
  title = {{Fast Parallel SAME Gibbs Sampling on General Discrete Bayesian Networks}},
  year = {2015},
  eprint = {1511.06416},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1511.06416},
}
Figure