Proposal: Cholesky-tracing to speed up posterior predictive sampling #5451
michaelosthege
started this conversation in
Ideas
Replies: 1 comment
-
For my specific problem that initiated this line of thought, it turned out that my conda environment is broken. Probably some BLAS/NumPy dependencies broke and I'll have to nuke it. So maybe others can comment if they experienced performance problems? The proposed solution from above is rather simply, but we don't need to fix a problem that doesn't exit. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let 👇 be part a big big model that's really expensive to run MCMC on.
Then a typical workflow would be 👇 first running just the expensive MCMC, for example on a cluster.
And doing the diagnostics & visualizations on another machine later.
The Problem
The most expensive (?) step in the model is the
cholesky(stabilize(cov(X)))
.Which needs to be computed for every posterior draw as soon as the covariance function has priors for
scaling
/lengthscale
.For the
conditional(Xnew)
, thecholesky(stabilize(cov(X)))
is created again.While the
InferenceData
contains draws for thescaling
/lengthscale
, this most expensive step of the model is re-computed.Proposed solution
We could introduce an optional
trace_cholesky: str
kwarg that wraps thecholesky(stabilize(cov(X)))
in_build_prior
in apm.Deterministic(trace_cholesky, ...)
, making it end up inInferenceData.posterior
.Similarly, we could add a
from_cholesky
to thegp.conditional
to automatically replace thecholesky(stabilize(cov(X)))
re-creation in_build_conditional
with amodelcontext(None)[from_cholesky]
link to the correspondingpm.Deterministic
model variable from before.In
pm.sample_posterior_predictive
we'd need to replace not only RVs, but alsoDeterministic
variables by input nodes fed from the posterior samples---if we're not doing that already(?).Note that unless we have some cholesky caching mechanism in Aesara (which I think doesn't exist), this would also speed up
pm.sample_posterior_predictive
running in the same notebook session.@bwengals @fonnesbeck @aseyboldt what do you think?
Beta Was this translation helpful? Give feedback.
All reactions