Skip to content

Stabilize gp.Latent.conditional covariance with jitter (fixes #8108)#8109

Open
mullachv wants to merge 1 commit intopymc-devs:mainfrom
mullachv:gp-latent-cond
Open

Stabilize gp.Latent.conditional covariance with jitter (fixes #8108)#8109
mullachv wants to merge 1 commit intopymc-devs:mainfrom
mullachv:gp-latent-cond

Conversation

@mullachv
Copy link

@mullachv mullachv commented Feb 17, 2026

Stabilize gp.Latent.conditional covariance with jitter (fixes #8108)

Description

With large Xnew arrays, gp.Latent.conditional could raise LinAlgError: Matrix is not positive definite because the conditional covariance matrix was not numerically stabilized. The jitter argument was only applied to the prior covariance K(X,X) before Cholesky, not to the conditional covariance K(Xnew,Xnew) - K(Xnew,X) K(X,X)^{-1} K(X,Xnew).

Changes:

  • Apply stabilize(..., jitter) to the conditional covariance in Latent._build_conditional so jitter is used for conditional covariance passed to MvNormal.
  • Same in TP._build_conditional for consistency.
  • Add a regression test testLatentConditionalLargeXnewJitter that builds the model from issue BUG: gp.Latent.conditional conditional cov needs stabilizing? #8108 (99 training points, 500 prediction points, ExpQuad, jitter=1e-4) and evaluates the compiled logp to ensure no LinAlgError.

Related Issue

Checklist

  • Checked that the pre-commit linting/style checks pass
  • Included tests that prove the fix is effective or that the new feature works
  • Added necessary documentation (docstrings and/or example notebooks)
  • If you are a pro: each commit corresponds to a [relevant logical change]

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.49%. Comparing base (c32715a) to head (6f81f0c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8109   +/-   ##
=======================================
  Coverage   91.49%   91.49%           
=======================================
  Files         123      123           
  Lines       19832    19832           
=======================================
  Hits        18146    18146           
  Misses       1686     1686           
Files with missing lines Coverage Δ
pymc/gp/gp.py 94.71% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: gp.Latent.conditional conditional cov needs stabilizing?

2 participants