Recognize affine functions of independent Gaussians as MvNormal logp#8342
Draft
ricardoV94 wants to merge 1 commit into
Draft
Recognize affine functions of independent Gaussians as MvNormal logp#8342ricardoV94 wants to merge 1 commit into
ricardoV94 wants to merge 1 commit into
Conversation
Teach pymc.logprob to derive the logp of a value variable that is an affine function of one or more independent Gaussian leaves (e.g. the low-rank guide loc + W @ ek + d * ed) by propagating moments and substituting a dense MvNormal, instead of inverting the transform. This unlocks fundamentally non-invertible cases the existing machinery declines: wide/low-rank matvecs (find_measurable_matmul bails on non-square matrices) and sums of >=2 independent Gaussians (the elemwise transforms require <=1 measurable operand). Covers low-rank ADVI guides, sums of independent normals, and linear-Gaussian marginalization (regression coefficients, etc.). The accumulated covariance is kept dense; exploiting low-rank structure for an O(D K^2) logp would need a Woodbury rewrite in PyTensor, which does not exist yet, so the emitted MvNormal does a dense O(D^3) cholesky. Claude-Session: https://claude.ai/code/session_0183HnSTpYk7UrvAJ7D3kBtj
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8342 +/- ##
==========================================
- Coverage 86.73% 86.71% -0.03%
==========================================
Files 126 127 +1
Lines 20595 20781 +186
==========================================
+ Hits 17863 18020 +157
- Misses 2732 2761 +29
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Teach pymc.logprob to derive the logp of a value variable that is an
affine function of one or more independent Gaussian leaves (e.g. the
low-rank guide loc + W @ ek + d * ed) by propagating moments and
substituting a dense MvNormal, instead of inverting the transform.
This unlocks fundamentally non-invertible cases the existing machinery
declines: wide/low-rank matvecs (find_measurable_matmul bails on
non-square matrices) and sums of >=2 independent Gaussians (the elemwise
transforms require <=1 measurable operand). Covers low-rank ADVI guides,
sums of independent normals, and linear-Gaussian marginalization
(regression coefficients, etc.).
The accumulated covariance is kept dense; exploiting low-rank structure
for an O(D K^2) logp would need a Woodbury rewrite in PyTensor, which
does not exist yet, so the emitted MvNormal does a dense O(D^3) cholesky.
Claude-Session: https://claude.ai/code/session_0183HnSTpYk7UrvAJ7D3kBtj