Black Box Variational Inference with a Deterministic Objective: Faster, More Accurate, and Even More Black Box

Ryan Giordano, Martin Ingram, Tamara Broderick

TL;DR

Automatic Differentiation Variational Inference (ADVI) is popular but plagued by noisy stochastic optimization, sensitive hyperparameters, and severely underestimated posterior variances. DADVI (Deterministic ADVI) fixes this by replacing stochastic gradients with Sample Average Approximation (SAA)—optimizing an empirical objective over a small, fixed set of Monte Carlo draws ($N \approx 30$). This enables out-of-the-box second-order optimization, accurate variance corrections via Linear Response (LR), and quantifiable Monte Carlo error, often running faster and more reliably than standard ADVI even in high dimensions.

What Problem Does This Paper Address?

Black-box variational inference (BBVI) aims to make Bayesian inference push-button: users specify a model and data, and the software estimates the posterior without domain-specific derivation. ADVI is a dominant BBVI variant implemented across probabilistic programming languages (PPLs) like Stan and PyMC.

However, standard ADVI has two major weaknesses:

  1. Optimization brittleness: It maximizes the Evidence Lower Bound (ELBO) using stochastic gradient (SG) ascent. SG requires delicate learning-rate tuning, lacks unambiguous convergence criteria, and can fail silently or terminate prematurely.
  2. Variance underestimation: Mean-field variational Bayes (MFVB) assumes fully factorized posteriors, which notoriously underestimates posterior variances and ignores correlations.

While sensitivity analysis like Linear Response (LR) can restore accurate covariances to mean-field variational approximations, LR requires differentiating the first-order optimality condition via the implicit function theorem. Because SG iterates never reach an exact stationary point of a tractable objective, LR cannot be directly applied to standard ADVI.

Methods

Instead of drawing new Monte Carlo samples at every optimization step, DADVI uses the Sample Average Approximation (SAA):

  • Deterministic Surrogate Objective: Draws a single set of standard normal samples $\mathcal{Z} = \{Z_1, \dots, Z_N\}$ once at initialization. Using the reparameterization trick, the intractable expectation in the ELBO becomes a fixed, deterministic objective $\widehat{\mathcal{L}}_{\text{VI}}(\eta \mid \mathcal{Z})$.
  • Off-the-Shelf Second-Order Solvers: Because the objective is deterministic and smooth, DADVI can leverage robust, off-the-shelf second-order optimizers (such as Newton trust-region methods like trust-ncg) with clear, standard termination criteria.
  • Linear Response Covariances: Because the optimizer converges to a numerical local minimum ($\nabla_\eta \widehat{\mathcal{L}}_{\text{VI}}(\hat{\eta} \mid \mathcal{Z}) = 0$), the implicit function theorem applies. LR covariances are computed via Hessian-vector products ($\hat{H}^{-1} v$) using conjugate gradients with a specialized mean-field preconditioner, avoiding expensive $O(D_\eta^3)$ Hessian inversions.
  • Sandwich Monte Carlo Standard Errors: DADVI derives asymptotic standard errors for parameter estimates under the sampling distribution of $\mathcal{Z}$, letting practitioners assess whether Monte Carlo noise dominates posterior uncertainty.

Datasets

The authors evaluated DADVI against standard PyMC ADVI, RAABBVI (an automated, adaptive stochastic BBVI method), and ground-truth NUTS (MCMC):

  • ARM Benchmark: 53 textbook linear and generalized linear mixed models from Gelman & Hill (parameter dimension $D_\theta \in [2, 176]$).
  • Microcredit: A heavy-tailed, zero-inflated hierarchical model of seven randomized controlled trials ($D_\theta = 124$).
  • Occupancy: A multi-species ecological detection/occupancy model on eBird data ($D_\theta = 1,884$).
  • Tennis: A Bradley–Terry random-effects ranking model spanning 164,936 professional ATP matches ($D_\theta = 5,014$).
  • POTUS: A high-dimensional dynamic reverse-autoregressive US presidential election forecasting model ($D_\theta = 15,098$).

Key Insights and Ideas

  • Overcoming the "Curse of Dimensionality" in SAA: Classical stochastic optimization theory states that SAA sample sizes must scale linearly with dimension ($N = O(D)$). The authors prove that this bound is unduly pessimistic for typical Bayesian models:
  • For quadratic log-posteriors, errors on individual marginal means scale as $O_p(N^{-1/2})$, completely independent of dimension, and LR covariances are exact for any $N \ge 2$.
  • For global–local hierarchical models, the required sample size scales only logarithmically with the number of local parameters ($N = O(\log P)$), because local parameters decouple once the shared global parameters are identified.
  • The "Blessing" of Inexpressivity: SAA fails catastrophically for full-rank Gaussian VI when $D_\theta > N$. The optimizer trivially sends variance to infinity in subspaces orthogonal to the draws $\mathcal{Z}$, driving the objective to $-\infty$. Paradoxically, it is precisely the constraint of the mean-field family that prevents this collapse and allows tiny sample sizes ($N=30$) to work when $D_\theta > 15,000$.
  • Optimization Reliability vs. True ELBO: While stochastic ADVI occasionally reached slightly higher true ELBO values if run for tens of thousands of steps, lower ELBO values did not translate to more accurate posterior moments. DADVI avoided the wild convergence failures seen in stochastic methods.

Key Results

  • Computational Speed: DADVI (and DADVI + LRVB) converged faster than standard ADVI and RAABBVI across both wall-clock runtime and model evaluation counts on almost all benchmarks (e.g., up to an order of magnitude faster on POTUS and Tennis).
  • Posterior Accuracy:
  • Posterior means from DADVI were comparable to standard ADVI and RAABBVI, without suffering the catastrophic outliers where stochastic methods diverged by up to 100 posterior standard deviations.
  • Linear response posterior standard deviations ($\text{LRVB}$) consistently corrected the variance underestimation of MFVB, significantly outperforming mean-field ADVI, RAABBVI, and even full-rank ADVI on the ARM models.
  • Reliable MC Uncertainty: Sandwich standard error estimates of the optimization noise were well-calibrated (forming uniform p-value distributions against $N=\infty$ baselines) once $N \ge 32$.

Limitations and Future Work

  • Expressive Approximations Fail: DADVI cannot be naively extended to full-rank Gaussians or normalizing flows without requiring sample sizes on the order of parameter dimension ($N \ge D_\theta$), which causes memory and compute bottlenecks.
  • Worst-Case Uniform Error: While individual target quantities have dimension-independent error, the worst-case error across all dimensions still scales as $\sqrt{D_\theta / N}$. DADVI is therefore designed for settings where users care about a moderate number of pre-specified quantities of interest.
  • Theory-to-Practice Gap: Theoretical guarantees currently assume strict global-local or quadratic structure; establishing formal guarantees for non-linear models like POTUS remains open.

Summary updated

BibTeX
@article{giordano2024black,
  author = {Ryan Giordano and Martin Ingram and Tamara Broderick},
  title = {{Black Box Variational Inference with a Deterministic Objective: Faster, More Accurate, and Even More Black Box}},
  journal = {J. Mach. Learn. Res.},
  year = {2024},
  url = {https://openreview.net/forum?id=UehRlm1TeH},
}
Figure