Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Sparse variational Markov GP

SparseMarkovGPPrior is the inducing-time-grid analogue of MarkovGPPrior. It wraps any SDEKernel and a sorted inducing grid Z of length M, exposing the standard SVGP building blocks (KZZ,KxZ,diag Kxx)(K_{ZZ}, K_{xZ}, \mathrm{diag}\,K_{xx}) derived from the SDE autocovariance k(τ)=Hexp⁡(Fτ)P∞H⊤k(\tau) = H \exp(F\tau) P_\infty H^\top.

Because the predictive-block contract matches the dense SparseGPPrior, the existing variational guides (FullRankGuide, MeanFieldGuide, WhitenedGuide) plug straight in. The sparse_markov_elbo function delivers a Gaussian-likelihood closed-form ELBO and accepts a gaussx integrator for non-conjugate likelihoods.

Cost: O(M3+NM)O(M^3 + N M) per ELBO evaluation. A truly linear-in-NN Kalman-aware ELBO (BayesNewton / MarkovFlow style) is a follow-up.

/home/azureuser/localfiles/pyrox/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Synthetic regression data

Noisy mixture of two sinusoids on an irregular time grid.

<Figure size 880x330 with 1 Axes>

Sparse Markov GP setup

Pick M = 12 evenly-spaced inducing times and a Matern-3/2 SDE prior. The variational guide is a FullRankGuide over the inducing function values u=f(Z)u = f(Z).

M (inducing) = 12
N (data)     = 80
prior marginal variance = 1.000
initial ELBO = -771.188

Conjugate update — closed-form q(u) for Gaussian likelihood

For Gaussian observations the optimal q(u)=N(mq,Sq)q(u) = \mathcal{N}(m_q, S_q) is closed-form (Titsias 2009):

Sq=(σ−2KZZ−1KZXKXZKZZ−1+KZZ−1)−1,mq=σ−2SqKZZ−1KZX (y−μ).S_q = (\sigma^{-2} K_{ZZ}^{-1} K_{ZX} K_{XZ} K_{ZZ}^{-1} + K_{ZZ}^{-1})^{-1},\qquad m_q = \sigma^{-2} S_q K_{ZZ}^{-1} K_{ZX}\,(y - \mu).

This sidesteps the need to optimise the ELBO and gives the optimal q(u)q(u) at the prescribed inducing locations directly. We use it here to demonstrate the sparse_markov_elbo / SparseConditionedMarkovGP API on a fitted guide.

closed-form ELBO = -101.641

Posterior at the fitted guide

SparseConditionedMarkovGP.predict(t_star) produces the mean / variance at arbitrary test times via the standard SVGP predictive (cost O(M3+∣t∗∣ M)O(M^3 + |t_*|\,M)).

<Figure size 935x396 with 1 Axes>

Comparison: sparse vs dense Markov GP

At the closed-form q(u)q(u) and well-spaced inducing points, the SVGP posterior should approximate the dense-Markov posterior. The remaining difference is the inducing-set bias from working with M=12M = 12 pseudo-points instead of all N=80N = 80 data points.

<Figure size 935x396 with 1 Axes>
max |sparse mean − dense mean| = 0.2002

Sweep: how many inducing points do we need?

Increase M and re-fit the closed-form q(u)q(u). Past a kernel-dependent threshold, the sparse posterior is indistinguishable from the dense one.

<Figure size 935x396 with 1 Axes>

Summary

  • SparseMarkovGPPrior(sde_kernel, Z) exposes the SVGP predictive blocks for any state-space kernel.
  • sparse_markov_elbo(...) plugs into the existing variational-guide infrastructure with a closed-form Gaussian-likelihood path and a numerical (gaussx-integrator) path for non-conjugate likelihoods.
  • For Gaussian observations the optimal q(u)q(u) is closed-form (used here for demonstration); for non-conjugate likelihoods, optimise sparse_markov_elbo via standard SVI (see markov_gp_training.ipynb for the optax-LBFGS pattern wrapping the SDE forward pass under JIT, which is the canonical way to train through the dynamic-stop expm in SDEKernel.discretise).
  • At MM large enough to span the posterior support of the kernel, the sparse posterior collapses to the dense one. Reducing MM trades fidelity for the O(M3)O(M^3) ELBO cost.
  • This surface is the SVGP-style foundation. A truly linear-in-NN Kalman-aware ELBO that exploits the Markov factorisation of q(u)q(u) is a follow-up.