Pathwise Gradient Variance Reduction with Control Variates in Variational Inference

Kenyon Ng, Susan Wei

In the world of Bayesian Deep Learning, Variational Inference (VI) is the workhorse that allows us to approximate complex posterior distributions. To make it work, we need to optimize the Evidence Lower Bound (ELBO) using gradients. While the "reparameterization trick" (pathwise gradient estimator) revolutionized the field by providing lower-variance gradients than older methods, researchers are still hunting for ways to make those gradients even cleaner.

A recent paper, "Pathwise Gradient Variance Reduction with Control Variates in Variational Inference," takes a hard look at whether sophisticated variance reduction techniques actually help us train models faster in the real world.

TL;DR

The authors propose using Zero-Variance Control Variates (ZVCV)—a method based on Stein operators—to reduce the noise in pathwise gradient estimators without requiring strict assumptions about the variational distribution. However, their empirical results deliver a sobering "reality check": while these techniques successfully reduce gradient variance, the computational overhead often makes them slower in "wall-clock time" than simply increasing the number of Monte Carlo samples.

What Problem Does This Paper Address?

When we perform stochastic VI, we estimate the gradient of an expectation. Because we can't solve this expectation analytically, we use Monte Carlo sampling. This introduces variance (noise). High variance means the optimizer (like Adam) takes a jagged, inefficient path toward the solution, requiring more iterations to converge.

To fight this, researchers use Control Variates (CV)—extra terms added to the gradient that have an expected value of zero but are negatively correlated with the noise, effectively "canceling it out."

The gap the authors identified is twofold:

  1. Restrictiveness: Existing state-of-the-art CV methods (like QuadCV) often require knowing the mean and covariance of the variational distribution, which isn't possible for complex models like Normalizing Flows.
  2. Efficiency: It’s unclear if the time spent calculating these complex "noise-cancelers" is actually better spent just drawing more samples.

Methods

The paper explores three main approaches to gradient estimation:

  1. NoCV (Vanilla): The standard reparameterization trick.
  2. QuadCV (The Baseline): A method that uses a quadratic approximation of the log-joint probability. It’s powerful but computationally heavy and limited to simpler distributions (like Gaussians).
  3. ZVCV-GD (The Proposal): The authors introduce a method using Stein Operators. By applying a Stein operator to a set of polynomials, they generate control variates that are guaranteed to have zero expectation.
  4. The "GD" Twist: Usually, finding the best coefficients for these control variates requires inverting a massive matrix—a nightmare in high dimensions. The authors instead use a few steps of Gradient Descent (GD) inside each training iteration to "learn" the best coefficients on the fly.

Datasets

The authors tested these methods across a variety of Bayesian modeling tasks:

  • a1a: Used for Bayesian Logistic Regression.
  • frisk: A hierarchical Poisson model used to analyze "stop-and-frisk" data.
  • redwine: Used to train a Bayesian Neural Network (BNN) for predicting wine quality.

They evaluated these across different "variational families," ranging from simple Mean-field Gaussians to complex Real NVP (Normalizing Flows).

Key Insights and Ideas

  • The Flexibility of Stein Operators: Unlike previous methods, ZVCV-GD doesn't care if your distribution is a simple bell curve or a complex Normalizing Flow. If you can sample from it and compute its gradient, ZVCV can be applied.
  • The Wall-Clock Trap: This is the "aha moment" for practitioners. In many papers, "performance" is measured by how much variance is reduced per iteration. This paper measures performance against wall-clock time. They found that the time taken to compute the control variates often negates the benefits of the cleaner gradient.
  • The Power of $L$: One of the most surprising findings was how effective simply increasing the number of samples ($L$) is. Moving from 10 samples to 50 samples often provided better convergence than adding a complex control variate, with much less implementation complexity.

Key Results

  • Variance Reduction: Both QuadCV and ZVCV-GD successfully reduced gradient variance. QuadCV was generally the "cleanest" but also the most computationally expensive.
  • Convergence Speed: In terms of wall-clock time, NoCV (Vanilla) was often the winner. While the CV methods reached a slightly higher ELBO (better fit) in some cases, they took 50% to 100% longer to get there.
  • Normalizing Flows: For Real NVP models, ZVCV-GD provided a marginal improvement, but again, the extra computation time made it hard to justify for general use.

Limitations and Future Work

The authors are refreshingly honest about the limitations:

  • Overfitting in the Inner Loop: When optimizing the control variate coefficients ($\beta$) via gradient descent, there is a risk of overfitting to the current minibatch, which can actually increase noise.
  • Diminishing Returns: In high-dimensional spaces (like large BNNs), the number of control variates needed grows, making the method increasingly expensive.

Future Direction: The authors suggest that ZVCV might find its true home in Generative Models or Implicit Variational Inference, where the distributions are so complex that standard methods fail entirely, and the high cost of variance reduction might finally be a price worth paying.

Summary updated

BibTeX
@inproceedings{ng2024pathwise,
  author = {Kenyon Ng and Susan Wei},
  title = {{Pathwise Gradient Variance Reduction with Control Variates in Variational Inference}},
  booktitle = {AI},
  year = {2024},
  doi = {10.1007/978-981-96-0351-0\_9},
}

Loading related content...

Figure