NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Efficiently sampling functions from Gaussian process posteriors.

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

Abstract

Gaussian processes are the gold standard for many real-world modeling problems, especially in cases where a model's success hinges upon its ability to faithfully represent predictive uncertainty. These problems typically exist as parts of larger frameworks, wherein quantities of interest are ultimately defined by integrating over posterior distributions. These quantities are frequently intractable, motivating the use of Monte Carlo methods. Despite substantial progress in scaling up Gaussian processes to large training sets, methods for accurately generating draws from their posterior distributions still scale cubically in the number of test locations. We identify a decomposition of Gaussian processes that naturally lends itself to scalable sampling by separating out the prior from the data. Building off of this factorization, we propose an easy-to-use and general-purpose approach for fast posterior sampling, which seamlessly pairs with sparse approximations to afford scalability both during training and at test time. In a series of experiments designed to test competing sampling schemes' statistical properties and practical ramifications, we demonstrate how decoupled sample paths accurately represent Gaussian process posteriors at a fraction of the usual cost.

Introduction

Gaussian Processes (GPs) are highly valued in machine learning for their ability to provide well-calibrated uncertainty estimates. However, their utility is often limited by computational bottlenecks. While significant progress has been made in scaling GP training to large datasets, drawing function samples from the posterior remains a challenge. Standard methods rely on a Cholesky decomposition of the posterior covariance matrix, which scales as $O(N_*^3)$ with the number of test locations $N_*$. This "cubic wall" makes it impractical to sample functions over dense grids or long time horizons, which is essential for tasks like Bayesian Optimization (Thompson Sampling) and simulating dynamical systems.

Existing approximations often fall short. Sparse GPs reduce training costs but still face cubic scaling at test time for sampling. Weight-space approximations, such as Random Fourier Features (RFF), offer $O(N_*)$ sampling but suffer from "variance starvation"—they fail to accurately represent the posterior as more data is added, leading to poor extrapolation.

Decoupled Sampling via Matheron’s Rule

This paper introduces Decoupled Sampling, a method that reduces the computational cost of posterior sampling to $O(N_*)$. The approach is based on Matheron’s Rule, a principle from geostatistics which states that a conditional Gaussian variable can be decomposed into the sum of a prior draw and a corrective update term:

$$\text{Posterior} = \text{Prior} + \text{Update}$$

The key innovation is the use of different mathematical bases for these two components to optimize efficiency and accuracy. The Prior is represented using Random Fourier Features (RFF), which are globally efficient for approximating stationary kernels. The Update is represented using the Canonical Basis (kernel functions centered at the GP's inducing points), which locally corrects the prior draw to match observed data.

Visualizing the decoupled decomposition: the posterior (right) is formed by combining a global prior (Fourier basis, left) with a local update (Canonical basis, middle).

By combining these, the resulting Decoupled Sparse Gaussian Process (DSGP) provides sample paths that are globally consistent with the prior and locally accurate to the data. Furthermore, because these samples are represented as a sum of analytic basis functions, they are pathwise differentiable, allowing for the use of gradient-based optimizers in downstream tasks.

Experimental Results

The authors evaluated Decoupled Sampling across several benchmarks, focusing on statistical accuracy and practical performance.

Accuracy and Scalability

Using the 2-Wasserstein distance to measure the discrepancy between approximate and true posterior distributions, the experiments showed that DSGP consistently outperforms pure weight-space methods. As the number of training locations increases, RFF-based methods exhibit increasing error due to variance starvation, whereas DSGP maintains a low and stable error rate.

Quantitative comparison of 2-Wasserstein distances across different training set sizes. Decoupled sampling (blue) maintains accuracy and avoids the 'variance starvation' seen in standard weight-space approximations (orange) as data density increases.

Practical Applications

In Thompson Sampling for Bayesian Optimization, DSGP matched or exceeded the performance of standard methods, particularly in high-dimensional spaces where pathwise differentiability is a significant advantage.

The method's efficiency was most striking in simulating Dynamical Systems. In a simulation of the FitzHugh-Nagumo neuron model, the standard iterative sampling approach required 10 hours to complete. In contrast, the decoupled approach achieved similar accuracy in just 20 seconds, representing a massive speedup for complex simulation tasks.

Conclusion

Decoupled sampling offers a robust solution to the cubic scaling problem of GP posterior sampling. By separating the prior from the data-driven update, it achieves the "best of both worlds": the global efficiency of weight-space approximations and the local accuracy of inducing point methods. This approach enables the use of GPs in large-scale applications that were previously computationally prohibitive.

Summary updated

BibTeX
@misc{wilson2020efficiently,
  author = {James T. Wilson and Viacheslav Borovitskiy and Alexander Terenin and Peter Mostowsky and Marc Peter Deisenroth},
  title = {{Efficiently sampling functions from Gaussian process posteriors.}},
  year = {2020},
  eprint = {2002.09309},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.09309},
}
Figure