Pathwise Conditioning of Gaussian Processes

James T. Wilson, Viacheslav Borovitskiy, Alexander Terenin, Peter Mostowsky, Marc Peter Deisenroth

TL;DR

Conventional Gaussian process (GP) sampling requires decomposing an $N \times N$ covariance matrix, leading to a prohibitive $\mathcal{O}(N^3)$ computational bottleneck that prevents drawing continuous, differentiable sample paths. By reformulating conditioning at the level of random variables rather than probability distributions via Matheron’s update rule, this paper introduces a pathwise conditioning framework that decouples global prior simulation from local data-driven updates. This enables drawing continuous, automatically differentiable sample functions that evaluate in $\mathcal{O}(1)$ time and achieve massive speedups in downstream applications.

What Problem Does This Paper Address?

Gaussian processes are non-parametric probabilistic models widely used across machine learning. Traditionally, researchers adopt a distributional view: to query a GP posterior at test inputs $X_*$, one computes the conditional Gaussian distribution $\mathcal{N}(\mu_{*|y}, \Sigma_{*|y})$. Drawing sample realizations from this distribution requires calculating a matrix square root (such as a Cholesky factor) of $\Sigma_{*|y}$, which scales cubically $\mathcal{O}(|X_*|^3)$ with the number of test points.

This distribution-first view breaks down in several key settings:

  1. Continuous and adaptive sampling: In Bayesian optimization, downstream optimizers rely on gradient descent to find function extrema, which requires evaluating and differentiating continuous sample paths rather than evaluating a pre-chosen discrete grid.
  2. Sequential trajectory simulation: Simulating multi-step dynamical systems requires conditioning on past simulated points, compounding cubic costs into slow, iterative updates.
  3. Variance starvation: Existing weight-space approximations (such as random Fourier features) attempt to model both the prior and data updates using the same global basis, resulting in erratic extrapolations and vanishing predictive uncertainty as sample size approaches the feature dimension.

Methods

The authors build on Matheron’s update rule (historically known in geostatistics as "conditioning by Kriging"): for two jointly Gaussian vectors $a$ and $b$, the conditional random variable can be written directly as: $$(a \mid b = \beta) \stackrel{d}{=} a + \Sigma_{a,b}\Sigma_{b,b}^{-1}(\beta - b)$$

Translating this to Gaussian processes, the conditioned sample path satisfies: $$(f \mid y)(\cdot) \stackrel{d}{=} f(\cdot) + k(\cdot, X_n) (K_{n,n} + \sigma^2 I)^{-1}(y - f_n - \varepsilon)$$ where $f(\cdot)$ is a draw from the GP prior, $f_n = f(X_n)$, and $\varepsilon \sim \mathcal{N}(0, \sigma^2 I)$.

The core algorithmic innovation is decoupling the prior from the update:

  • Simulating the prior $f(\cdot)$: Priors typically represent smooth, stationary global behaviors. They are approximated as finite-dimensional Bayesian linear models $\tilde{f}(\cdot) = \sum_{i=1}^\ell w_i \phi_i(\cdot)$ using Random Fourier Features (RFF), truncated Karhunen–Loève (KL) expansions, or solutions to stochastic PDEs. Sampling weights $w$ takes $\mathcal{O}(\ell)$ time, after which the function can be evaluated in $\mathcal{O}(1)$ time and differentiated analytically.
  • Applying the update: Observations exert local influence. The update is computed using the canonical kernel basis $k(\cdot, X_n)$ (or sparse inducing points $Z \in \mathbb{R}^m$, or via iterative solvers like preconditioned conjugate gradients).
  • Non-Gaussian likelihoods: Addressed by pairing the update with sparse Gaussian pseudo-data or variational inducing variables.

Datasets

The authors validate their framework across diverse synthetic and empirical benchmarks:

  • Synthetic GP Regression: 4D functions drawn from known Matérn-5/2 priors to assess runtime, scalability, and 2-Wasserstein error metrics.
  • Black-Box Optimization Benchmark: Synthetic functions sampled from Matérn-5/2 priors in $d=2$ and $d=8$ dimensions evaluated on multi-candidate Thompson sampling.
  • Boundary Value Benchmark: 2D domains with Dirichlet boundary conditions (a rectangular domain and a non-trivial "infinity" symbol domain).
  • FitzHugh–Nagumo Model: A 2-dimensional nonlinear stochastic differential equation (SDE) modeling neuronal membrane potential dynamics.
  • Cart-Pole Benchmark: The PILCO policy search control task, evaluated under both standard (low initial variance) and challenge (highly diffuse initial state) settings.
  • MNIST: $28 \times 28$ grayscale handwritten digit dataset, used to evaluate a deep convolutional GP autoencoder.

Key Insights and Ideas

  • Sample First, Condition Later: Traditional conditioning computes the posterior distribution and then samples from it. Pathwise conditioning draws an entire function from the prior first, then deterministically shifts it by the data residual.
  • Basis Decoupling Resolves Variance Starvation: Forcing global basis functions (like RFFs) to capture local data constraints degrades posterior uncertainty estimates. Decoupling the representation—using Fourier features for the prior and canonical covariance kernels $k(\cdot, x)$ for the data—eliminates variance starvation.
  • Contraction Bounds: The paper proves that if the basis functions lie locally in the kernel's RKHS, the 2-Wasserstein error between the decoupled approximate posterior and the true GP posterior contracts to zero at the same rate as the true posterior variance (i.e., prior approximation error washes out as $n \to \infty$).

Key Results

  • Dynamical Systems: Simulating 1,000 rollouts ($T = 1,000$ steps) of the stochastic FitzHugh–Nagumo model took 10 hours using standard location-scale sampling versus 20 seconds with pathwise conditioning—a 1,800× speedup while maintaining matching empirical trajectory distributions.
  • Thompson Sampling: In 8D optimization, decoupled pathwise Thompson sampling enabled efficient multi-start gradient descent, dramatically outperforming location-scale methods (which struggled without pathwise gradients) and standard RFFs (which suffered from variance starvation).
  • Reinforcement Learning: On the diffuse-initialization cart-pole challenge, standard PILCO (moment matching) failed completely, whereas pathwise PILCO achieved near 100% success rates.
  • Deep Convolutional GPs: The pathwise framework enabled training a 7-layer deep convolutional GP autoencoder on MNIST end-to-end on a single GPU in just 40 minutes for $10^4$ steps.

Limitations and Future Work

  • Policy Divergence / Catastrophic Forgetting: In RL experiments, pathwise sampling exhibited higher variance during policy optimization than moment matching, occasionally leading to policy divergence after finding successful solutions.
  • Basis Construction Overhead: Non-Euclidean geometries or non-stationary kernels require computing eigenfunctions of differential operators (e.g., via numerical Helmholtz solves), which can be computationally intensive to set up.
  • Iterative Solvers and Caching: While preconditioned conjugate gradient (CG) methods scale well to massive datasets, precomputing inverses for fast repeated path updates (the CG+ approach) is sensitive to numerical round-off error.

Summary updated

BibTeX
@article{wilson2021pathwise,
  author = {James T. Wilson and Viacheslav Borovitskiy and Alexander Terenin and Peter Mostowsky and Marc Peter Deisenroth},
  title = {{Pathwise Conditioning of Gaussian Processes}},
  journal = {J. Mach. Learn. Res.},
  year = {2021},
  url = {https://openreview.net/forum?id=Bu9ORLD2QT},
}
Figure