Massively Parallel Expectation Maximization For Approximate Posteriors

Thomas Heap, Sam Bowyer, Laurence Aitchison · DOI

Abstract

Bayesian inference for hierarchical models is often computationally prohibitive. While Variational Inference (VI) and Reweighted Wake-Sleep (RWS) are popular, they rely on gradient-based optimization which suffers from slow convergence and sensitivity to hyperparameters and reparameterization. We present QEM, a gradient-free alternative that leverages massively parallel importance weighting (MPIW) to estimate posterior moments. QEM achieves faster convergence, handles discrete latent variables naturally, and is invariant to reparameterization. Evaluation across five diverse datasets demonstrates that QEM consistently outperforms massively parallel VI and RWS in both speed and accuracy.

Introduction

Hierarchical models are essential for capturing structure in data, such as students nested within schools or sightings across species. However, estimating latent variables in these models remains a significant computational bottleneck. Current state-of-the-art methods like Variational Inference (VI) and Reweighted Wake-Sleep (RWS) frame inference as an optimization problem solved via gradient descent. This approach introduces several challenges: slow convergence, extreme sensitivity to learning rate hyperparameters, and a lack of invariance to reparameterization (e.g., scaling variables).

In this work, we introduce QEM (Expectation Maximization for Approximate Posteriors), a gradient-free algorithm that combines the classic EM framework with modern massively parallel computing to address these limitations.

Methodology: QEM and Massively Parallel Importance Weighting

QEM sidesteps gradient descent by using a two-step iterative process to update the approximate posterior:

  1. The E-Step (Expectation): We employ Massively Parallel Importance Weighting (MPIW). For each of the $n$ latent variables, MPIW draws $K$ samples. By exploiting the conditional independence structure of the model, MPIW efficiently reasons over all $K^n$ possible sample combinations. This allows for high-quality, low-variance estimates of posterior moments (e.g., mean and variance) without the need for the reparameterization trick.
  2. The M-Step (Maximization): The parameters of the approximate posterior are updated directly to match the moments calculated in the E-step. To ensure stability, an Exponential Moving Average (EMA) is used to smooth moment estimates across iterations.

This approach is inherently reparameterization invariant. Because QEM matches moments directly rather than following a gradient through a potentially warped loss landscape, its performance is unaffected by the scaling of latent variables. Furthermore, because it does not require differentiable paths, QEM naturally supports models with discrete latent variables.

Experimental Evaluation

We evaluated QEM against massively parallel implementations of VI and RWS across five hierarchical models: Bus Breakdown (NYC bus delays), MovieLens100K (recommendations), Bird Occupancy (discrete latent variables), Radon (environmental modeling), and Covid (time-series infection rates).

Key Results

QEM demonstrated superior performance across all benchmarks in terms of both iteration efficiency and wall-clock time.

Convergence of ELBO and predictive log-likelihood across five datasets as a function of iterations.

As shown in the iteration-wise analysis, QEM (pink line) typically reaches a stable, high-quality solution in fewer steps than MP RWS or MP VI. This efficiency is even more pronounced when considering actual execution time.

Wall-clock time comparison showing QEM's superior convergence speed across all benchmarks.

In the MovieLens task, for instance, QEM converged in approximately 20 seconds, whereas RWS and VI required 50 and 60 seconds, respectively. Beyond speed, QEM achieved higher Evidence Lower Bounds (ELBO) and better predictive log-likelihoods in most cases. When compared to ground-truth moments from Hamiltonian Monte Carlo (HMC) runs, QEM's estimates were consistently more accurate than those from VI.

Discussion and Future Work

QEM offers a robust, "tuning-free" path to Bayesian inference by eliminating the need for learning rate optimization. Its ability to handle discrete variables and its invariance to scaling make it a versatile tool for complex hierarchical modeling. While the implementation of massively parallel moment estimation is complex, the benefits in speed and stability are significant. Future work involves integrating QEM into general-purpose Probabilistic Programming Languages (PPLs) to democratize access to these massively parallel benefits.

Summary updated

BibTeX
@inproceedings{heap2025massively,
  author = {Thomas Heap and Sam Bowyer and Laurence Aitchison},
  title = {{Massively Parallel Expectation Maximization For Approximate Posteriors}},
  booktitle = {AABI Proceedings Track},
  year = {2025},
  url = {https://openreview.net/forum?id=1TZ7tDW2WQ},
}
Figure