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.

Quasi-Newton inference for non-conjugate GPs

Quasi-Newton (QN) inference reaches the same Laplace approximation as LaplaceInference, but takes a different optimization path to get there.

  • Laplace: full Newton iteration. Each step requires the per-point Hessian and a Cholesky solve on K+diag(1/Λ)K + \mathrm{diag}(1/\Lambda). Cost per iter: O(N3)O(N^3). Convergence: 5–10 iterations on log-concave likelihoods.
  • Quasi-Newton: optimize the MAP via L-BFGS. Each step uses only the gradient of the (negative) log posterior; the Hessian is approximated implicitly via a low-rank update from the recent gradient history. Cost per iter: O(N2)O(N^2) (one Cholesky solve against the prior Cholesky, computed once). Convergence: typically 30–100 iterations.

At convergence both strategies report the exact Laplace covariance — the same Gaussian approximation. The trade-off is:

LaplaceQuasi-Newton
Per-iter costO(N3)O(N^3)O(N2)O(N^2) + amortized O(N3)O(N^3) for prior Cholesky
Iterations to converge5–1030–100
Total cost∼10 N3\sim 10\, N^3∼N3+100 N2\sim N^3 + 100\,N^2
Crossover where QN winsN2≳100 N3/10N^2 \gtrsim 100\,N^3 / 10, i.e. when prior solves dominate

In practice QN is the right choice when (a) NN is in the thousands so the per-iteration N3N^3 cost of Newton is the bottleneck, and (b) you can use an iterative prior solver (CG, BBMM via gaussx) so the O(N2)O(N^2) matvec replaces the dense factorization.

Caveat. L-BFGS doesn’t always converge cleanly to high precision — heavy-tail likelihoods and ill-conditioned priors cause it to plateau short of the optimum. If QN reports converged=False, the result is still a Gaussian approximation centered at the L-BFGS iterate (with exact Hessian there), but it’s not at the true MAP and won’t match Laplace bit-for-bit. Always check cond.converged.

/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

Bernoulli classification — Laplace vs Quasi-Newton

We expect the same posterior at convergence. The difference is only in the optimization path.

Laplace        iters=  6  conv=True  log_marg≈-25.691
Quasi-Newton   iters=200  conv=False  log_marg≈-25.692

max |q_mean diff|: 4.292e-06
max |q_var  diff|: 1.125e-03

Reading the numbers: if QN converged, the posterior should match Laplace to L-BFGS’s tolerance. The number of iterations is much higher (typically 5–20× more), but each iteration is cheaper. The reported log_marg should be within numerical noise of Laplace’s.

Convergence trace — why L-BFGS takes more iterations

Newton’s method has quadratic convergence on log-concave problems: error squares each step. L-BFGS has only superlinear convergence (somewhere between linear and quadratic), so iteration counts are inherently higher. The flip side: each L-BFGS step is much cheaper because we never solve the full Hessian system.

<Figure size 1210x385 with 2 Axes>

Both panels show the typical L-BFGS pattern: rapid early progress, then a long tail of small gradient steps. Newton-based Laplace would hit the noise floor in ~6 iterations rather than ~80.

Predictive comparison — same posterior, different path

<Figure size 1210x396 with 2 Axes>
<Figure size 880x330 with 1 Axes>

Differences between Laplace and QN are mostly L-BFGS residual error — how close the optimizer got to the true MAP. With more L-BFGS iterations or a tighter tolerance these shrink toward zero.

Summary

  • QN gives the same Laplace posterior, just via a gradient-only optimization path.
  • Iteration counts are higher (typically 5–20× more) but each iteration is cheaper because no per-step Hessian solve is needed.
  • The win is at large NN where the O(N3)O(N^3) Newton step dominates wall time. With an iterative prior solver, QN can scale further than Laplace.
  • Always check cond.converged — L-BFGS can plateau short of the optimum on hard problems. If it doesn’t converge, the posterior is still a valid Gaussian approximation centered at the L-BFGS iterate, just not at the MAP.
  • For small or moderate NN, Laplace is cheaper and tighter. QN is a scaling-friendly alternative, not a strict improvement.
cond = prior.condition_nongauss(BernoulliLikelihood(), y,
                                strategy=QuasiNewtonInference(max_iter=200, tol=1e-5))
m, v = cond.predict(X_star)

This concludes the five-strategy walkthrough. The full picture:

StrategyCurvatureBest for
Laplaceexact Hessian, pointlog-concave, small-NN, mode point estimates
Gauss-NewtonPSD-clipped Hessian, pointnon-log-concave, want robustness floor
Posterior Linearizationcavity-averaged grad/Hessianbetween Laplace and EP, IPLF
Expectation Propagationtilted-distribution momentsbest calibration, willing to pay for cubature
Quasi-NewtonL-BFGS history, Laplace at optimumlarge NN, Hessian solves dominate