Sparse variational Gaussian processes: Titsias, Hensman and what came after
How a Gaussian process scales from thousands to millions of points without changing the model. Variational inference from scratch, inducing points, Titsias's collapsed bound, Hensman's stochastic version, how many inducing points you need, and the 2025 bounds that go beyond p(f | u). Every step derived.
An exact Gaussian process has to factorise an N×N matrix. That is fine for a thousand points, slow for ten thousand, and impossible for a million. Sparse variational GPs keep the model exactly as it is and approximate only the posterior, through the values of the function at M≪N chosen inputs, the inducing points. The cost drops from O(N3) to O(NM2), or to O(M3) per minibatch step. The approximation also comes with a number, a lower bound on the log evidence, that says how much was lost.
Drag the diamonds, change M, or press Greedy and then Optimise Z:
6
What to try. With six evenly spaced inducing points the sparse fit (teal) is far too smooth, and the bound F sits about a hundred nats below the exact log evidence. The grey bars under the plot show, at every training input, how much prior variance the inducing points fail to explain; the bound pays for each bar. Raise M: by M=14 the sparse fit is indistinguishable from the exact one and F is within two nats of the exact log evidence. The upper bound U closes in more slowly, because it replaces the unexplained covariance by its trace (Section 6). Greedy places points where the bars are tallest, and Optimise Z then climbs F by moving them; at M=14 the pair brings the gap below half a nat. Finally, drag one point out of the data into the empty stretch near x=0.5: the bars grow where it left, and the gap jumps from about 1.6 to 7.6 nats.
This is the second post in the Gaussian-process series, after Gaussian processes, from first principles. It re-derives everything it uses, apart from three Gaussian facts proved in that post (its Lemmas 5, 6 and 8) and in the Gaussian toolkit: conditioning a joint Gaussian, the Woodbury identity with the matrix determinant lemma, and the marginal and posterior of a linear-Gaussian model. Proofs are folded and written as numbered steps.
The plan:
what an exact GP costs, and why that bill is paid again at every training step;
variational inference from scratch: the KL divergence, the ELBO and why it underestimates variance;
inducing points, and what the Nyström matrix Qff keeps and loses;
two ways to approximate: change the prior (DTC, FITC) or change the posterior (variational);
Titsias’s collapsed bound, derived and read three ways;
an upper bound, so you know how far from the truth you are;
predictions and a numerically stable implementation;
Hensman’s stochastic version: minibatches, non-Gaussian likelihoods, whitening and natural gradients;
how many inducing points you need, and where to put them;
a map of the field after 2013;
the 2025 bounds that relax q(f∣u)=p(f∣u);
a practical recipe.
Notation
Plain italic letters are scalars, bold italic lower case are column vectors, bold upright capitals are matrices. In this post f is shorthand for fX, the latent function values at the training inputs (the primer’s notation).
Symbol
Meaning
X∈RN×D, y∈RN
training inputs (rows xi⊤), observations
f=f(X)∈RN
latent values at the training inputs
σn2
noise variance; y=f+ε, ε∼N(0,σn2I)
M, Z∈RM×D
number of inducing points, inducing inputs (rows zj⊤)
u=f(Z)∈RM
inducing variables
Kff, Kfu, Kuu
k(X,X), k(X,Z), k(Z,Z); Kuf=Kfu⊤
A=KfuKuu−1
interpolation weights, N×M, rows ai⊤
Qff=KfuKuu−1Kuf
Nyström approximation of Kff, entries qij
C=Kff−Qff, ci=kii−qii
covariance of f given u, its diagonal
t=trC=∑ici
total prior variance the inducing variables leave unexplained
q(u)=N(m,S)
variational distribution over u
Σ=(Kuu+σn−2KufKfu)−1
appears in the optimal q∗(u)
L(q), F, U
ELBO of a given q; collapsed (Titsias) bound; upper bound
KL[q∥p]
Kullback–Leibler divergence
N(a∣μ,Σ) is the Gaussian density in a. For symmetric matrices, P⪰R means P−R is positive semi-definite.
1. The exact GP and its bill
With a zero-mean prior f∼GP(0,k) and Gaussian noise, the primer derives two formulas. The log marginal likelihood (the evidence) is
and the predictive distribution at a test input x∗ has mean k∗⊤(Kff+σn2I)−1y and variance k∗∗−k∗⊤(Kff+σn2I)−1k∗.
Both need the Cholesky factor of the N×N matrix Kff+σn2I: about N3/3 floating-point operations and N2 numbers of memory. In double precision:
N
memory for Kff
Cholesky flops
in practice
103
8 MB
3×108
instant
104
0.8 GB
3×1011
seconds
105
80 GB
3×1014
needs a large GPU cluster
106
8 TB
3×1017
out of reach
Learning the kernel hyperparameters θ (length-scales, amplitude, noise) means maximising logp(y) by gradient ascent, and every step repeats the factorisation. So the target is a method that
costs O(N) in the number of data points, or less per step;
keeps the same model, so that the hyperparameters we learn mean what they meant before;
reports how much accuracy it gave up.
Variational inference with inducing points does all three.
2. Variational inference from scratch
The problem it solves
Write z for whatever is unknown and y for the data. Bayes’ rule gives the posterior
p(z∣y)=p(y)p(y∣z)p(z),p(y)=∫p(y∣z)p(z)dz.
Often the posterior is intractable because the integral has no closed form. For GP regression it has one, but it costs O(N3). Variational inference (VI) turns both cases into optimisation: pick a family Q of distributions we can handle, and find the member closest to the posterior.
“Closest” needs a notion of distance between distributions.
Definition 1 (Kullback–Leibler divergence)
For densities q and p on the same space, with p>0 wherever q>0,
KL[q∥p]=∫q(z)logp(z)q(z)dz=Eq[logq(z)−logp(z)].
The integral runs over the set where q>0. If p=0 somewhere q>0, the divergence is +∞.
It measures, on average under q, how much more probable q thinks a point is than p does. It is not symmetric: KL[q∥p]=KL[p∥q] in general. But it is never negative.
Proposition 1 (Gibbs’ inequality)
KL[q∥p]≥0, with equality if and only if q=p almost everywhere.
Proof
Step 1. Flip the ratio. On the set {q>0},
−KL[q∥p]=Eq[logq(z)p(z)].
Step 2. Jensen’s inequality. The logarithm is concave, so E[logW]≤logE[W] for any positive random variable W. With W=p(z)/q(z) and z∼q:
Step 3. Bound the last integral.p is a density, so its integral over any set is at most 1, and log of a number at most 1 is at most 0. Hence −KL≤0.
Step 4. Equality. Jensen’s inequality for a strictly concave function is an equality only if W is constant q-almost everywhere, say p=λq. Step 3 is an equality only if ∫q>0p=1. Together these force λ=1, so p=q almost everywhere.
Now the central identity of variational inference.
Theorem 1 (The evidence decomposition)
For any density q(z) that is positive wherever the posterior is,
Step 1. The product rule, pointwise. For every z, p(y,z)=p(z∣y)p(y), so
logp(y)=logp(y,z)−logp(z∣y).
Step 2. Add and subtract logq(z).
logp(y)=[logp(y,z)−logq(z)]+[logq(z)−logp(z∣y)].
Step 3. Average over q. The left side does not depend on z, so its expectation under q is itself. The expectation of the first bracket is L(q); the expectation of the second is the KL divergence by definition.
Three consequences follow at once, and the rest of the post uses all of them.
It is a lower bound. By Gibbs’ inequality the KL term is non-negative, so L(q)≤logp(y): the name ELBO stands for evidence lower bound.
Maximising it is the right goal.logp(y) does not depend on q. So raising L(q) by some amount lowers KL[q∥p(⋅∣y)] by exactly that amount.
It can replace the evidence when learning hyperparameters. When the model has hyperparameters θ, maximising L(q,θ) jointly over q and θ approximates type-II maximum likelihood. The gap is the KL term, so the approximation is good when the KL term is small.
Corollary 1 (The ELBO as fit minus complexity)
L(q)=Eq[logp(y∣z)]−KL[q(z)∥p(z)].
Proof
Step 1. Split the joint: logp(y,z)=logp(y∣z)+logp(z).
Step 2. Substitute into L(q) and group the last two terms:
The first term rewards explaining the data; the second penalises moving away from the prior. That reading is the same one the GP evidence has (data fit against complexity), and it will reappear in the inducing-point bound.
Remark (Why KL(q ‖ p) and not KL(p ‖ q))
We minimise KL[q∥p(⋅∣y)], an expectation under q, because we can sample from q and evaluate it, but not the posterior. The choice has a consequence. Where the posterior is tiny and q is not, log(q/p) is huge, so the optimum keeps q small wherever p is small. The resulting q is zero-forcing: it sits inside the posterior and tends to be too narrow. The reverse divergence KL[p∥q] (used by expectation propagation) behaves the opposite way and covers all of p.
The next example makes “too narrow” exact. It is also the clearest preview of the 2025 bound in Section 11.
Example 1 (Mean-field VI underestimates variance)
Let the target be p=N(μ,Σ) in D dimensions, with precision Λ=Σ−1. Approximate it with a fully factorised Gaussian q=N(m,diag(s1,…,sD)) by minimising KL[q∥p]. The optimum is m=μ and sd=1/Λdd, and 1/Λdd≤Σdd.
For two variables with unit variances and correlation 0.9, Λ11=1/(1−0.81)≈5.26. So q has standard deviation 0.44 where the truth has 1. The approximation matches the conditional variance of each coordinate given the others, not its marginal variance.
Proof
Step 1. The Gaussian KL. For q=N(m,S) and p=N(μ,Σ) (proved in the toolkit),
KL[q∥p]=21[tr(ΛS)+(m−μ)⊤Λ(m−μ)−D+log∣Σ∣−log∣S∣].
Step 2. The mean. Only the quadratic term depends on m. It is non-negative because Λ is positive definite, and zero at m=μ.
Step 3. The variances. With S=diag(sd), tr(ΛS)=∑dΛddsd and log∣S∣=∑dlogsd. So the KL separates into 21∑d(Λddsd−logsd) plus constants.
Step 4. Minimise each term.dsd(Λdds−logs)=Λdd−1/s, which vanishes at s=1/Λdd. The second derivative 1/s2 is positive, so this is the minimum.
Step 5. Compare with the marginal variance. By the Cauchy–Schwarz inequality applied to the vectors Σ1/2ed and Σ−1/2ed:
Hence 1/Λdd≤Σdd, with equality only when coordinate d is uncorrelated with the rest.
Note (What VI means for a GP)
In GP regression with Gaussian noise the posterior is already Gaussian, so VI is not about approximating a strange shape. It is about cost. We will restrict the posterior to those that are fully determined by M numbers, the function values at M inputs, and let VI pick the best such posterior and tell us its distance from the exact one.
3. Inducing points
Definition 2 (Inducing inputs and inducing variables)
Choose M inputs Z=[z1,…,zM]⊤, the inducing inputs. The inducing variables are the function values there, u=f(Z)∈RM.
The inducing variables are not data and not new parameters of the model. They are values of the same random function f, at places of our choosing, and nothing is observed there. Because f is a GP, f and u are jointly Gaussian:
[fu]∼N(0,[KffKufKfuKuu]).
Lemma 1 (The function given the inducing variables)
p(u)=N(u∣0,Kuu),p(f∣u)=N(f∣Au,Kff−Qff),
with A=KfuKuu−1 and Qff=KfuKuu−1Kuf.
Proof
Step 1. The marginal of u. Any sub-vector of a Gaussian vector is Gaussian with the matching blocks of the mean and covariance, so u∼N(0,Kuu).
Step 2. Conditioning. For a joint Gaussian with zero mean, the conditional of the first block given the second has mean Σ12Σ22−1u and covariance Σ11−Σ12Σ22−1Σ21, the Schur complement (the primer’s Lemma 5, Gaussian conditioning). Here Σ11=Kff, Σ12=Kfu, Σ22=Kuu.
Step 3. Name the pieces. The mean is KfuKuu−1u=Au, and the covariance is Kff−KfuKuu−1Kuf=Kff−Qff.
Three readings of this lemma carry the whole post.
The mean interpolates.Au is what noise-free GP regression would predict at X if we had observed the values u at Z. Row i of A holds the kernel weights that turn the inducing values into a guess for f(xi).
Qff is a low-rank stand-in for Kff. It is the Nyström approximation (Williams and Seeger, 2001), built from the M columns of the kernel at Z. Its rank is at most M.
C=Kff−Qff is what the inducing variables cannot pin down. Its diagonal entry ci is the prior variance of f(xi) that remains after u is known. These are the grey bars in the figure.
Proposition 2 (What the Nyström matrix keeps and loses)
Qff⪰0 and C=Kff−Qff⪰0. In particular 0≤ci≤kii for every i, and ci=0 whenever xi is one of the inducing inputs.
Proof
Step 1. Qff is positive semi-definite. For any v, v⊤Qffv=(Kufv)⊤Kuu−1(Kufv)≥0, because Kuu−1 is positive definite.
Step 2. C is positive semi-definite. By the lemma, C is the covariance of f given u, and every covariance matrix is positive semi-definite.
Step 3. The diagonal. Diagonal entries of a positive semi-definite matrix are non-negative: qii≥0 and ci≥0. Since ci=kii−qii, also ci≤kii.
Step 4. At an inducing input. If xi=zj, then f(xi)=uj is known exactly once u is, so its conditional variance ci is zero.
Example 2 (One inducing point)
With a single inducing input z and the squared-exponential kernel k(x,x′)=σf2exp(−(x−x′)2/(2ℓ2)),
One inducing point explains the variance of nearby inputs and almost none of the inputs more than about 2ℓ away. With length-scale ℓ on a domain of width W, you need on the order of W/ℓ well-spread points before every ci is small. The figure uses ℓ=0.07 on [0,1], which is why about fourteen are needed.
4. Two ways to approximate
The exact prior can be written as p(f)=∫p(f∣u)p(u)du. Before 2009 most sparse GPs approximated the factor p(f∣u), and so changed the prior. Quiñonero-Candela and Rasmussen (2005) unified them this way.
DTC (deterministic training conditional). Replace p(f∣u) by a point mass at Au. The prior on f becomes N(0,Qff), a degenerate rank-M Gaussian, and the evidence becomes N(y∣0,Qff+σn2I).
FITC (fully independent training conditional; Snelson and Ghahramani, 2006). Keep only the diagonal of the conditional covariance: N(f∣Au,diagC). The prior becomes N(0,Qff+diagC), which has the correct variances but the wrong correlations.
Each is a new GP with a new, Z-dependent kernel. Fitting Z and θ by maximising its evidence turns the inducing inputs into extra model parameters. Then nothing stops them from fitting the data better than the original model could: FITC is known to underestimate the noise and to overfit (Bauer, van der Wilk and Rasmussen, 2016).
The variational route keeps p(f) exact and approximates the posterior instead. Then:
the hyperparameters belong to the original model;
Z are variational parameters, which can only move the approximation closer to the true posterior;
the objective is a lower bound on the true evidence, so its value is a certificate.
5. Titsias’s bound
The augmented model
Add u to the model:
p(y,f,u)=p(y∣f)p(f∣u)p(u).
Integrating out u returns p(y,f)=p(y∣f)p(f), so the augmentation changes nothing: the evidence p(y) is the same. We now approximate the posterior over (f,u).
The variational family
Titsias (2009) chose
q(f,u)=p(f∣u)q(u).
Given u, the function is distributed exactly as under the prior. All the information the data carry has to pass through the M inducing variables. The exact posterior has this form only when u is a sufficient statistic for f, which is why it is an approximation.
Lemma 2 (The ELBO for the inducing-point family)
For q(f,u)=p(f∣u)q(u),
L(q)=Eq(f,u)[logp(y∣f)]−KL[q(u)∥p(u)].
Proof
Step 1. Write the ELBO with z=(f,u).
L(q)=Eq(f,u)[logp(f∣u)q(u)p(y∣f)p(f∣u)p(u)].
Step 2. Cancel. The factor p(f∣u) appears above and below:
L(q)=Eq(f,u)[logp(y∣f)]+Eq(f,u)[logq(u)p(u)].
Step 3. The second term depends only on u. Its expectation under q(f,u) equals its expectation under the marginal q(u), which is −KL[q(u)∥p(u)].
Note (Why the cancellation is the whole trick)
p(f∣u) is an N-dimensional Gaussian with an N×N covariance. Evaluating its density would cost O(N3), which is exactly what we are avoiding. Because the same factor sits in the model and in q, its density never has to be evaluated. We only need its moments, and only on the diagonal, as the next two lemmas show.
Lemma 3 (Expected Gaussian log-likelihood)
If f∼N(μ,P), then
E[logN(y∣f,σn2I)]=logN(y∣μ,σn2I)−2σn21trP.
Proof
Step 1. Write the log-density.logN(y∣f,σn2I)=−2Nlog(2πσn2)−2σn21∥y−f∥2. Only the norm is random.
Step 2. Split the residual.y−f=(y−μ)−(f−μ), so
∥y−f∥2=∥y−μ∥2−2(y−μ)⊤(f−μ)+∥f−μ∥2.
Step 3. Take expectations. The middle term has mean zero because E[f]=μ. The last has mean E∑i(fi−μi)2=∑iPii=trP.
Step 4. Reassemble.E[logN]=−2Nlog(2πσn2)−2σn21∥y−μ∥2−2σn21trP, and the first two terms are logN(y∣μ,σn2I).
Only the trace of the covariance enters: the expected log-likelihood is the log-likelihood at the mean, minus a penalty for the spread of f.
The optimal q(u) and the collapsed bound
Theorem 2 (Titsias (2009))
Over all densities q(u), the ELBO of the family p(f∣u)q(u) is maximised by
q∗(u)∝N(y∣Au,σn2I)p(u),
and its maximum value is
F=logN(y∣0,Qff+σn2I)−2σn21tr(Kff−Qff)
Proof
Step 1. Do the inner expectation over f. For fixed u, f∼p(f∣u)=N(Au,C). The expected-log-likelihood lemma gives
Step 2. Put it into the ELBO. Write the KL as an expectation and collect everything under one Eq(u):
L(q)=Eq(u)[logq(u)N(y∣Au,σn2I)p(u)]−2σn2t.
Step 3. Normalise the numerator. Let Z0=∫N(y∣Au,σn2I)p(u)du and q∗(u)=N(y∣Au,σn2I)p(u)/Z0, a probability density. Then the numerator is Z0q∗(u), and
L(q)=logZ0−KL[q∥q∗]−2σn2t.
Step 4. Maximise. By Gibbs’ inequality the KL term is at least zero, with equality exactly at q=q∗. So q∗ is the maximiser and the maximum is logZ0−t/(2σn2).
Step 5. Compute Z0. It is the marginal of y in the linear-Gaussian model u∼N(0,Kuu), y∣u∼N(Au,σn2I). That marginal is N(0,AKuuA⊤+σn2I) (the primer’s Lemma 8, linear-Gaussian model), and
Step 1. It is a linear-Gaussian posterior.q∗ is proportional to a Gaussian prior on u times a Gaussian likelihood with design matrix A. So it is Gaussian, with precision Kuu−1+σn−2A⊤A and mean S∗σn−2A⊤y (the primer’s Lemma 8, in information form).
Step 2. Factor the precision. With A⊤A=Kuu−1KufKfuKuu−1,
Step 3. Invert.(PRP)−1=P−1R−1P−1, so S∗=KuuΣKuu.
Step 4. The mean.m∗=σn−2KuuΣKuuKuu−1Kufy=σn−2KuuΣKufy.
Every matrix here is M×M or M×N. Nothing N×N is ever formed.
Reading the bound
The first term is the DTC evidence.logN(y∣0,Qff+σn2I) is the log evidence of the low-rank model from Section 4, with its usual data-fit and complexity parts.
The second term is what makes it honest.−t/(2σn2)=−∑ici/(2σn2) charges, at every training input, the prior variance the inducing points leave unexplained, measured in units of noise variance. Inducing points that leave data uncovered are penalised. In the figure this is the sum of the grey bars, divided by 2σn2.
The optimal q∗(u) is the DTC posterior over u. The variational solution predicts like DTC, but it learns hyperparameters and Z with the extra trace term.
Proposition 3 (The gap is a KL divergence)
logp(y)−F=KL[p(f∣u)q∗(u)p(f,u∣y)]≥0.
Proof
Step 1. Apply the evidence decomposition of Section 2 to the augmented model, with z=(f,u) and q(f,u)=p(f∣u)q∗(u).
Step 2. The augmented model has the same evidence p(y), and L(q)=F at this q by the theorem. Rearranging the decomposition gives the identity, and Gibbs’ inequality gives the sign.
Matthews, Hensman, Turner and Ghahramani (2016) proved more: the same number is the KL divergence between the approximating process and the posterior process, over the whole function, not only at X and Z. So moving Z to raise F always brings the approximation closer to the true posterior. It cannot overfit in the way FITC’s evidence can.
Proposition 4 (More inducing points never hurt)
If Z=X, then F=logp(y).
Adding an inducing input to Z cannot lower the optimal bound F.
Proof
Step 1. The case Z=X. Then Kfu=Kuu=Kff, so Qff=Kff and C=0. The trace term vanishes and the first term is logN(y∣0,Kff+σn2I)=logp(y).
Step 2. Embed the old family in the new one. Let u′=(u,unew). In the new family choose q(u′)=p(unew∣u)q(u). Then q(f,u′)=p(f,unew∣u)q(u).
Step 3. Same ELBO. The ratio inside the new ELBO is
the same as before. So every ELBO value reachable with Z is reachable with the larger set.
Step 4. Conclude. The maximum over a larger set is at least the maximum over a smaller one.
6. A sandwich: the upper bound
A lower bound alone cannot say how close it is to the truth. Titsias (2014) gave an upper bound that costs the same O(NM2); Burt, Rasmussen and van der Wilk (2019) used it to prove their convergence results.
Step 1. Split the exact covariance.Kff+σn2I=(Qff+σn2I)+C with C⪰0 (Section 3).
Step 2. The determinant can only grow. If P⪰R≻0, then R−1/2PR−1/2⪰I has all eigenvalues at least 1, so ∣P∣≥∣R∣. Hence
−21log∣Kff+σn2I∣≤−21log∣Qff+σn2I∣.
Step 3. Bound C by a multiple of the identity.C is positive semi-definite, so its eigenvalues are non-negative and sum to t. Its largest eigenvalue is therefore at most t, and C⪯tI.
Step 4. So the exact covariance is dominated.Kff+σn2I⪯Qff+(σn2+t)I.
Step 5. Inversion reverses the order. If P⪯R (both positive definite), then P−1⪰R−1. Hence
−21y⊤(Kff+σn2I)−1y≤−21y⊤(Qff+(σn2+t)I)−1y.
Step 6. Add the pieces. The exact logp(y) is the sum of the two left-hand sides and −2Nlog2π; replacing each by its upper bound gives U.
So F≤logp(y)≤U, and U−F bounds the KL divergence of the approximation. Both depend on how small t is. Burt et al. (2019, Lemma 1) turn this into an explicit bound:
KL≤2σn2t(1+σn2+t∥y∥2).
To make the approximation good, make t small: place inducing points so that the training inputs’ prior variance is explained. That is what Greedy does in the figure.
7. Predictions and an implementation you can trust
The variational posterior is a GP. At a test input, the inducing variables carry everything the data said.
Proposition 6 (The predictive distribution)
With q(u)=N(m,S), ku=k(Z,x∗) and a∗=Kuu−1ku,
q(f∗)=N(f∗∣a∗⊤m,k∗∗−ku⊤Kuu−1ku+a∗⊤Sa∗).
At the optimum q∗ this is mean σn−2ku⊤ΣKufy and variance k∗∗−ku⊤(Kuu−1−Σ)ku.
Proof
Step 1. The conditional at the test point. Exactly as in the lemma of Section 3, p(f∗∣u)=N(a∗⊤u,k∗∗−ku⊤Kuu−1ku).
Step 2. Integrate out u.q(f∗)=∫p(f∗∣u)q(u)du is a linear-Gaussian marginal: the mean is a∗⊤m and the variance is the conditional variance plus a∗⊤Sa∗ (the primer’s Lemma 8).
Step 3. Substitute the optimum. From the corollary, Kuu−1m∗=σn−2ΣKufy and Kuu−1S∗Kuu−1=Σ. So a∗⊤m∗=σn−2ku⊤ΣKufy and a∗⊤S∗a∗=ku⊤Σku.
Far from every inducing point ku≈0, so the prediction returns to the prior: mean 0, variance k∗∗. That is the right behaviour in a gap of the data, and the wrong one if the inducing points do not cover the data, which the bound punishes.
The formulas above invert Kuu and Σ−1 directly, which is numerically fragile: Kuu is often badly conditioned. Production code (for example GPflow’s SGPR) works with two M×M Cholesky factors instead.
Proposition 7 (A stable form of the bound and the predictions)
Let LL⊤=Kuu, A^=L−1Kuf/σn (M×N), B=I+A^A^⊤ with LBLB⊤=B, and b=LB−1A^y/σn. Then
and with g1=L−1ku, g2=LB−1g1, the optimal predictive has mean g2⊤b and variance k∗∗−g1⊤g1+g2⊤g2.
Proof
Step 1. Rewrite Qff.Qff=KfuL−⊤L−1Kuf=σn2A^⊤A^, so Qff+σn2I=σn2(IN+A^⊤A^).
Step 2. The determinant. Sylvester’s identity gives ∣IN+A^⊤A^∣=∣IM+A^A^⊤∣=∣B∣. To see it, take the determinant of the block matrix [IMA^⊤−A^IN] in two ways, eliminating either block by its Schur complement: one way gives ∣IN+A^⊤A^∣, the other ∣IM+A^A^⊤∣. So log∣Qff+σn2I∣=2Nlogσn+2∑jlog(LB)jj.
Step 3. The quadratic form. The Woodbury identity (the primer’s Lemma 6 with Σw=I, Φ=A^ and unit noise) gives (IN+A^⊤A^)−1=IN−A^⊤B−1A^. Hence
Step 4. The trace term.trQff=σn2tr(A^⊤A^)=σn2tr(A^A^⊤), so −tr(Kff−Qff)/(2σn2)=−trKff/(2σn2)+21tr(A^A^⊤). Steps 2 to 4 assemble into the stated F.
Step 5. Σ in factored form.Σ−1=Kuu+σn−2KufKfu=L(I+A^A^⊤)L⊤=LBL⊤, so Σ=L−⊤B−1L−1.
Step 6. The predictive mean.σn−2ku⊤ΣKufy=σn−2g1⊤B−1(σnA^y)=g1⊤LB−⊤LB−1A^y/σn=g2⊤b.
Step 7. The predictive variance.ku⊤Kuu−1ku=g1⊤g1 and ku⊤Σku=g1⊤B−1g1=g2⊤g2.
In NumPy, with a kernel function k(A, B) that returns the matrix of kernel values (the figure above runs the same lines in JavaScript):
import numpy as npfrom scipy.linalg import cholesky, solve_triangulardef sgpr(X, y, Z, k, sn, jitter=1e-6): """Titsias's collapsed bound F and a predictor, in O(N M^2) time and O(N M) memory.""" N, M = len(X), len(Z) L = cholesky(k(Z, Z) + jitter * np.eye(M), lower=True) # K_uu = L L^T A = solve_triangular(L, k(Z, X), lower=True) / sn # \hat{A}, M x N B = np.eye(M) + A @ A.T LB = cholesky(B, lower=True) b = solve_triangular(LB, A @ y, lower=True) / sn trace_Kff = sum(k(X[i:i+1], X[i:i+1])[0, 0] for i in range(N)) # only the diagonal is needed F = (-0.5 * N * np.log(2 * np.pi) - N * np.log(sn) - np.log(np.diag(LB)).sum() - 0.5 * y @ y / sn**2 + 0.5 * b @ b - 0.5 * trace_Kff / sn**2 + 0.5 * np.sum(A * A)) def predict(Xs): g1 = solve_triangular(L, k(Z, Xs), lower=True) g2 = solve_triangular(LB, g1, lower=True) mean = g2.T @ b var = np.array([k(x[None], x[None])[0, 0] for x in Xs]) - np.sum(g1**2, 0) + np.sum(g2**2, 0) return mean, var return F, predict
The dominant costs are forming A^ and A^A^⊤, both O(NM2), plus two O(M3) Cholesky factorisations. For N=106 and M=103 that is about 1012 flops, minutes on a CPU. But A^ alone holds 109 numbers, 8 GB. The collapsed bound still touches every data point at every step, which is what Hensman’s method removes.
8. Hensman: stochastic variational GPs
Why the collapsed bound does not minibatch
Stochastic gradient methods need an objective that is a sum over data points: then a random minibatch, rescaled, gives an unbiased estimate of it and of its gradient. F is not such a sum. Its quadratic term y⊤(Qff+σn2I)−1y couples every pair of points, because optimising q(u) analytically has already mixed all the data into q∗.
Hensman, Fusi and Lawrence (2013) undo that step. They keep q(u)=N(m,S) explicit and optimise m and S by stochastic gradients along with everything else.
Proposition 8 (The SVGP bound)
For a likelihood that factorises over data points, p(y∣f)=∏ip(yi∣fi), and q(u)=N(m,S):
Step 1. Start from the lemma of Section 5.L=Eq(f,u)[logp(y∣f)]−KL[q(u)∥p(u)].
Step 2. Only the marginal of f matters. The first term depends on f alone, so it is an expectation under q(f)=∫p(f∣u)q(u)du. That is a linear-Gaussian marginal: q(f)=N(Am,C+ASA⊤).
Step 3. The log-likelihood is a sum.logp(y∣f)=∑ilogp(yi∣fi), and the expectation of a sum is the sum of expectations.
Step 4. Each term needs one marginal.logp(yi∣fi) depends only on fi, whose marginal under q(f) has mean (Am)i=ai⊤m and variance Cii+(ASA⊤)ii=ci+ai⊤Sai.
For a Gaussian likelihood each term has a closed form, by the expected-log-likelihood lemma in one dimension:
The KL term, between two M-dimensional Gaussians, is
KL=21[tr(Kuu−1S)+m⊤Kuu−1m−M+log∣Kuu∣−log∣S∣].
Proposition 9 (SVGP contains Titsias’s bound)
For a Gaussian likelihood, maxm,SL(m,S)=F, attained at (m∗,S∗). For any other (m,S), L(m,S)≤F.
Proof
Step 1. Titsias’s theorem maximised L over all densities q(u) and found the maximiser q∗, which is Gaussian (corollary).
Step 2. Gaussians are a subset of all densities, and q∗ belongs to that subset. So the maximum over Gaussians is the same value F, at the same point, and every other Gaussian does no better.
So SVGP gives up nothing at its optimum. Away from the optimum it is a looser bound, the price of being able to minibatch.
Minibatches
Pick a random minibatch B of size B. Then
L^=BNi∈B∑Eq(fi)[logp(yi∣fi)]−KL[q(u)∥p(u)]
has expectation L over the random choice of batch, and so does its gradient. One step costs O(BM2) for the marginals and O(M3) for the KL and the Cholesky factor of Kuu, independent of N. The parameters are m, a lower-triangular factor of S, Z and θ.
Any likelihood
Nothing in the bound assumed a Gaussian likelihood except the closed form above. For classification, counts or robust regression, only the one-dimensional expectations change (Hensman, Matthews and Ghahramani, 2015). Gauss–Hermite quadrature with J nodes ξj and weights wj computes them accurately:
EN(f∣μ,v)[g(f)]≈π1j=1∑Jwjg(μ+2vξj).
It comes from the substitution f=μ+2vξ, which turns the Gaussian weight into e−ξ2/π. Twenty nodes are typically plenty. This is how GP classification scales to millions of points.
Whitening
The parameters (m,S) live on the scale of Kuu, which changes whenever a hyperparameter does. Optimising both at once is like steering while someone moves the road. Whitening changes variables to remove that coupling.
Proposition 10 (The whitened parametrisation)
Write u=Lv with LL⊤=Kuu, so that p(v)=N(0,I), and let q(v)=N(m~,S~). Then, with a~i=L−1k(Z,xi),
Step 1. The prior on v.v=L−1u has covariance L−1KuuL−⊤=I.
Step 2. The KL is unchanged by an invertible linear map. Both densities pick up the same Jacobian factor ∣L∣−1, which cancels in the ratio. So KL[q(u)∥p(u)]=KL[q(v)∥N(0,I)], which is the Gaussian KL with Λ=I.
Step 3. The marginals.q(u)=N(Lm~,LS~L⊤). Substituting into Hensman’s marginal, ai⊤L=k(xi,Z)Kuu−1L=k(xi,Z)L−⊤=a~i⊤, which gives both moments.
No Kuu−1 remains. When a length-scale changes, the prior on v stays fixed, so (m~,S~) stay meaningful. In practice whitening makes the optimisation much better conditioned, and libraries use it by default.
Natural gradients
Ordinary gradients on (m,S) ignore the geometry of distributions. A small change to S can be a large change to q, and the reverse. Natural gradients precondition by the Fisher information, and for this model they do something remarkable.
Proposition 11 (One natural-gradient step solves the Gaussian case)
Write q(u) in exponential-family form with natural parameters η=(S−1m,−21S−1), and let η∗ be those of q∗. For a Gaussian likelihood the natural gradient of the ELBO is η∗−η. So the update η←η+ρ(η∗−η) with step size ρ=1 lands exactly on the optimum.
Proof
Step 1. Exponential-family facts.q(u)=h(u)exp(⟨η,T(u)⟩−A(η)) with T(u)=(u,uu⊤). The mean parameters are μ=Eq[T(u)]=∇A(η), and the Fisher information is F(η)=∇2A(η)=∂μ/∂η, a symmetric matrix.
Step 2. The natural gradient is the gradient in mean parameters. By the chain rule, ∇ηL=F∇μL. So F−1∇ηL=∇μL.
Step 3. The ELBO as a KL to q∗. Step 3 of Titsias’s proof gave L(q)=const−KL[q∥q∗], and q∗ is in the same family. Writing both log-densities out,
Step 4. Differentiate in μ. Here η is a function of μ. Write J=∂η/∂μ. Then
∇μ[⟨η∗−η,μ⟩+A(η)]=(η∗−η)−J⊤μ+J⊤∇A(η)=η∗−η,
because ∇A(η)=μ.
Step 5. Take the step.η+1⋅(η∗−η)=η∗.
With minibatches the natural gradient is noisy, so ρ<1. Salimbeni, Eleftheriadis and Hensman (2018) recommend natural-gradient steps for q(u) and Adam for θ and Z. That combination is far more robust than Adam on everything.
9. How many inducing points, and where
How many
The figure’s answer was “about the domain width divided by the length-scale”, and Burt, Rasmussen and van der Wilk (ICML 2019; JMLR 2020) made it precise. The KL divergence of the approximation is controlled by t, the total unexplained variance (Section 6). For well-placed inducing points, t is controlled by how fast the eigenvalues of the kernel’s integral operator decay under the input distribution.
Smooth kernels need very few. For the squared-exponential kernel with Gaussian-distributed inputs in D dimensions, M=O(logDN) inducing points suffice to make the KL divergence small with high probability. As N grows, M barely has to.
Rough kernels need more. For Matérn kernels the eigenvalues decay polynomially, and M must grow polynomially in N; the smoother the kernel, the slower.
Concentrated inputs help. Inputs packed into a small region need fewer inducing points than inputs spread thinly.
Where
Greedy conditional variance. Repeatedly add the training input with the largest current ci. This is a pivoted Cholesky factorisation of Kff, it attacks t directly, and it costs O(NM2). Burt et al. (2020) show that this kind of initialisation, close to sampling from a determinantal point process, achieves their bounds. It is the Greedy button above.
k-means. Cluster centres of the inputs are a common, cheap alternative.
Then optimise.Z are variational parameters, so gradient ascent on F or L can only improve the approximation.
Remark (VFE and FITC behave differently)
Bauer, van der Wilk and Rasmussen (2016) compared the two in detail. FITC tends to underestimate the noise variance and can overfit badly, because its inducing inputs act as model parameters. The variational bound (VFE) behaves well as M grows, but with too few inducing points it overestimates the noise: inflating σn2 shrinks the trace penalty t/(2σn2). Section 11 shows a bound that reduces this bias.
10. After 2013: a map of the field
The ideas above are the core. Most later work changes one ingredient: what u is, how q is structured, or how the bound is computed.
Inter-domain inducing variables
u need not be function values. Any linear functional works, for example um=∫f(x)gm(x)dx; only Kuu and Kfu change, by integrating the kernel against the gm (Lázaro-Gredilla and Figueiras-Vidal, 2009). With Fourier features on an interval, variational Fourier features make Kuu diagonal plus low rank, and much of the cost can be precomputed (Hensman, Durrande and Solin, 2017). On the sphere, spherical harmonics make Kuu exactly diagonal by the Funk–Hecke theorem (Dutordoir, Durrande and Hensman, 2020); the harmonics themselves are introduced in Fourier and wavelets on the sphere.
Decoupled and orthogonal bases
The mean of q usually needs many more basis functions than its covariance. Decoupled representations give each its own inducing set (Cheng and Boots, 2017), and orthogonally decoupled ones make the two sets complementary (Salimbeni et al., 2018). SOLVE-GP (Shi, Titsias and Mnih, 2020) splits f into a part spanned by the inducing points and an independent orthogonal remainder with its own inducing points, which gives tighter bounds at similar cost.
Nearest neighbours instead of low rank
Low-rank approximations struggle when the length-scale is short compared with the domain, because M must then grow with the volume. Sparse-within-sparse GPs (Tran et al., 2021) let each data point use only its nearest inducing points. The variational nearest-neighbour GP (Wu, Pleiss and Cunningham, 2022) puts a Vecchia-style prior with a sparse precision on u, with cost O(K3) per point for K neighbours, and can use one inducing point per observation.
Tighter bounds with conjugate gradients
The quadratic term of F is where the low-rank approximation loses most. Artemev, Burt and van der Wilk (2021) replace it with a bound tightened by a few conjugate-gradient iterations on the exact Kff+σn2I, which reduces hyperparameter bias.
Sampling whole functions
Bayesian optimisation and Thompson sampling need posterior functions, not marginals. Pathwise conditioning (Wilson et al., 2020) draws them by Matheron’s rule. A cheap random-feature prior sample is corrected by an inducing-point update, so the cost stays linear in the number of evaluation points. The rule itself is derived in the primer, Section 6.
Numerical stability
Inducing points that nearly coincide make Kuu singular. Jitter helps but biases the result. Terenin et al. (2024) give conditions on the minimum separation of inducing points under which the computations are provably stable, and build such sets with cover trees for low-dimensional problems.
Or skip sparsity
On a GPU, exact GPs reach a million points with conjugate gradients and preconditioning, using only matrix-vector products (Gardner et al., 2018; Wang et al., 2019). When the hardware is there and the length-scale is short, exact inference can beat a sparse approximation.
11. 2025: beyond p(f | u)
For sixteen years the family q(f,u)=p(f∣u)q(u) was taken as fundamental: it is what makes the N×N density cancel. In 2025 three papers relaxed it.
The weakness is visible in the bound. Given u, each fi keeps its prior conditional variance ci, as if yi had never been observed. But yi is a direct, noisy measurement of fi, and it should shrink that variance.
Theorem 3 (A tighter collapsed bound (Titsias, ICML 2025))
Let q(f∣u)=N(f∣Au,C1/2VC1/2) with V=diag(v1,…,vN), vi>0: the prior conditional mean, with a rescaled covariance. For a Gaussian likelihood, the optimal scales are
vi∗=(1+σn2ci)−1,
the optimal q(u) is unchanged, and the collapsed bound is
with F≤Fnew≤logp(y), and Fnew>F whenever some ci>0.
Proof
We assume C is invertible to keep the algebra short; the paper treats the general case.
Step 1. The ELBO of the new family. With q(f,u)=q(f∣u)q(u), the log-ratio inside the ELBO is logp(y∣f)+logq(f∣u)p(f∣u)+logq(u)p(u). Taking expectations,
Step 7. Maximise over q(u). The remaining terms are those of Titsias’s proof, Steps 2 to 5, so the optimal q(u) is the same q∗ and contributes logN(y∣0,Qff+σn2I).
Step 8. Compare.V=I recovers the 2009 family, with gi(1)=−ci/(2σn2). And log(1+a)≤a for a≥0, with equality only at a=0, so each new term is at least the old one. Finally Fnew is an ELBO, so it is at most logp(y).
Note (The optimal scale is one observation’s worth of shrinkage)
vi∗ci=ci+σn2ciσn2=(ci1+σn21)−1. That is the posterior variance of a Gaussian quantity with prior variance ci after one noisy observation with noise variance σn2: precisions add. The new family lets each fi learn from its own yi what u could not tell it. Because V is diagonal it ignores the correlations among the residuals, just as the mean-field example of Section 2 ignored correlations. The same idea, one level down.
What changes in practice:
Hyperparameters. The penalty grows like log(1+ci/σn2) instead of ci/σn2, so there is less pressure to inflate σn2 to hide unexplained variance. Titsias reports less biased hyperparameters and often better predictions.
Predictions. Test points get no extra parameters and q∗(u) is unchanged, so Section 7’s predictive formulas still apply.
Code. In the stochastic SVGP bound the per-point term −2σn2ci becomes −21log(1+ci/σn2); the rest is untouched, minibatching included. The figure’s readout shows how much of the 2009 gap this closes.
Two companion papers develop the idea. Bui, Ashman and Turner (TMLR 2025) independently relax the same assumption, choosing conditional posteriors with smaller variances than the prior at the training points, at unchanged cost. Bui and Titsias (2025) replace the diagonal V with a block-diagonal one, which provably tightens the bound further, and revisit Power-EP, which unifies VFE- and FITC-like methods, with these structured posteriors.
12. A practical recipe
N up to about 104: use the exact GP. With a GPU and conjugate gradients, exact inference goes much further.
Gaussian likelihood, and A^ fits in memory: use the collapsed bound (SGPR), with the 2025 regulariser where your library has it. M from a few hundred to a few thousand.
Larger N, streaming data, or a non-Gaussian likelihood: use SVGP with minibatches, whitening, natural gradients for q(u) and Adam for θ and Z.
Initialise Z with greedy conditional variance or k-means, then optimise.
Check the gap. Compute U−F on a subset. If it is large, increase M before trusting the hyperparameters.
Short length-scales on a large domain: consider nearest-neighbour variants (VNNGP) or inter-domain features rather than a huge M.
Numerics: factorise Kuu in double precision with a small jitter, and keep inducing points from collapsing onto each other.
Questions
Question 1
With no inducing points (M=0), what is F, and what does it mean?
Answer
With no u, Qff=0 and t=trKff, so F=logN(y∣0,σn2I)−trKff/(2σn2). The model explains the data as pure noise, and pays for all the prior variance of f at the data, unexplained. It is the ELBO of the approximation q(f)=p(f), which ignores the data entirely.
Question 2
Show that at an inducing input zj the predictive variance of f(zj) is Sjj.
Answer
At x∗=zj, ku is the j-th column of Kuu, so a∗=Kuu−1ku=ej and k∗∗−ku⊤Kuu−1ku=kjj−kjj=0. The variance is ej⊤Sej=Sjj: of course, since f(zj)=uj.
Question 3
Why does the 2009 bound push the noise variance up when M is too small?
Answer
σn2 appears in the penalty −t/(2σn2). When the inducing points leave a lot of variance unexplained (t large), raising σn2 shrinks the penalty, at some cost in the DTC evidence. The optimiser trades data fit for a smaller penalty by calling the unexplained signal “noise”. The 2025 penalty 21∑ilog(1+ci/σn2) grows only logarithmically in ci/σn2, so the incentive is weaker.
Question 4
For GP classification with a Bernoulli likelihood, which parts of the SVGP objective change, and which stay?
Answer
Only the N one-dimensional expectations Eq(fi)[logp(yi∣fi)] change, now computed by Gauss–Hermite quadrature. The marginals q(fi), the KL term, whitening, minibatching and the predictive distribution of f∗ are all unchanged. To predict the class probability, average the likelihood over q(f∗), again by quadrature.
Question 5
What does one SVGP step cost with minibatch size B, and which term dominates when B≈M?
Answer
The marginals cost O(BM2) (one triangular solve per point) and the Cholesky factor of Kuu plus the KL cost O(M3). With B≈M both are O(M3), so the inducing points, not the data, set the cost. That is why M in the low thousands is the practical limit, and why structured Kuu (inter-domain features) or local methods are attractive.
References
M. K. Titsias. Variational learning of inducing variables in sparse Gaussian processes. AISTATS, 2009. PMLR
J. Hensman, N. Fusi, N. D. Lawrence. Gaussian processes for big data. UAI, 2013. arXiv:1309.6835
J. Hensman, A. G. de G. Matthews, Z. Ghahramani. Scalable variational Gaussian process classification. AISTATS, 2015. arXiv:1411.2005
A. G. de G. Matthews, J. Hensman, R. E. Turner, Z. Ghahramani. On sparse variational methods and the Kullback–Leibler divergence between stochastic processes. AISTATS, 2016. arXiv:1504.07027
J. Quiñonero-Candela, C. E. Rasmussen. A unifying view of sparse approximate Gaussian process regression. JMLR, 2005. JMLR
E. Snelson, Z. Ghahramani. Sparse Gaussian processes using pseudo-inputs. NeurIPS, 2006.
C. K. I. Williams, M. Seeger. Using the Nyström method to speed up kernel machines. NeurIPS, 2001.
M. Bauer, M. van der Wilk, C. E. Rasmussen. Understanding probabilistic sparse Gaussian process approximations. NeurIPS, 2016. arXiv:1606.04820
M. K. Titsias. Variational inference for Gaussian and determinantal point processes. NeurIPS Workshop on Advances in Variational Inference, 2014. (The upper bound of Section 6, as cited by Burt et al.)
D. R. Burt, C. E. Rasmussen, M. van der Wilk. Rates of convergence for sparse variational Gaussian process regression. ICML, 2019. arXiv:1903.03571
D. R. Burt, C. E. Rasmussen, M. van der Wilk. Convergence of sparse variational inference in Gaussian processes regression. JMLR, 2020.
H. Salimbeni, S. Eleftheriadis, J. Hensman. Natural gradients in practice: non-conjugate variational inference in Gaussian process models. AISTATS, 2018. arXiv:1803.09151
M. Lázaro-Gredilla, A. Figueiras-Vidal. Inter-domain Gaussian processes for sparse inference using inducing features. NeurIPS, 2009.
J. Hensman, N. Durrande, A. Solin. Variational Fourier features for Gaussian processes. JMLR, 2017. arXiv:1611.06740
V. Dutordoir, N. Durrande, J. Hensman. Sparse Gaussian processes with spherical harmonic features. ICML, 2020.
C.-A. Cheng, B. Boots. Variational inference for Gaussian process models with linear complexity. NeurIPS, 2017.
H. Salimbeni, C.-A. Cheng, B. Boots, M. Deisenroth. Orthogonally decoupled variational Gaussian processes. NeurIPS, 2018.
J. Shi, M. K. Titsias, A. Mnih. Sparse orthogonal variational inference for Gaussian processes. AISTATS, 2020. PMLR
G.-L. Tran, D. Milios, P. Michiardi, M. Filippone. Sparse within sparse Gaussian processes using neighbor information. ICML, 2021. PMLR
L. Wu, G. Pleiss, J. P. Cunningham. Variational nearest neighbor Gaussian process. ICML, 2022. arXiv:2202.01694
A. Artemev, D. R. Burt, M. van der Wilk. Tighter bounds on the log marginal likelihood of Gaussian process regression using conjugate gradients. ICML, 2021.
J. T. Wilson, V. Borovitskiy, A. Terenin, P. Mostowsky, M. P. Deisenroth. Efficiently sampling functions from Gaussian process posteriors. ICML, 2020. arXiv:2002.09309
A. Terenin, D. R. Burt, A. Artemev, S. Flaxman, M. van der Wilk, C. E. Rasmussen, H. Ge. Numerically stable sparse Gaussian processes via minimum separation using cover trees. JMLR, 2024. JMLR
J. R. Gardner, G. Pleiss, D. Bindel, K. Q. Weinberger, A. G. Wilson. GPyTorch: blackbox matrix-matrix Gaussian process inference with GPU acceleration. NeurIPS, 2018. arXiv:1809.11165
K. A. Wang, G. Pleiss, J. R. Gardner, S. Tyree, K. Q. Weinberger, A. G. Wilson. Exact Gaussian processes on a million data points. NeurIPS, 2019. arXiv:1903.08114
M. K. Titsias. New bounds for sparse variational Gaussian processes. ICML, 2025. arXiv:2502.08730
T. D. Bui, M. Ashman, R. E. Turner. Tighter sparse variational Gaussian processes. TMLR, 2025. arXiv:2502.04750
T. D. Bui, M. K. Titsias. Sparse Gaussian processes: structured approximations and Power-EP revisited. 2025. arXiv:2507.02377
F. Leibfried, V. Dutordoir, S. T. John, N. Durrande. A tutorial on sparse Gaussian processes and variational inference. 2020. arXiv:2012.13962
D. M. Blei, A. Kucukelbir, J. D. McAuliffe. Variational inference: a review for statisticians. JASA, 2017. arXiv:1601.00670
C. M. Bishop. Pattern Recognition and Machine Learning, Chapter 10. Springer, 2006.