-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ENH: JAX OP MatrixIsPositiveDefinite
#6849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That seems to be an Op implemented in PyMC, not in PyTensor, so any dispatch should be implemented there. pymc/pymc/distributions/multivariate.py Lines 849 to 895 in ccad4c8
That code relies on scipy to raise a LinalgError when calling cholesky with a non-semiposdef matrix. A jitted cholesky in JAX doesn't raise but returns Otherwise ignoring like we do for |
ok! so if I understand correctly we could either use import jax.numpy as jnp
jnp.any(jnp.isnan(jnp.linalg.cholesky(x))) or
Can you clarify the second option (Otherwise ignoring like we do for Assert)? I do not get it 🙈 |
Some Ops like Assert ere not really supported by JAX so our dispatch is basically a pass through I would try option #1 first |
I want to try this one out! Just to get started... where should I add the JAX code import jax.numpy as jnp
jnp.any(jnp.isnan(jnp.linalg.cholesky(x))) ? |
Check this guide (for pytensor): https://pytensor.readthedocs.io/en/latest/extending/creating_a_numba_jax_op.html Then the code would probably go here: https://github.com/pymc-devs/pymc/blob/main/pymc/sampling/jax.py And the tests in the analogous test file. |
While we are at it we can remove the SpecifyShape from here: Lines 63 to 74 in a2695a7
Because that's actually supported and well implemented in PyTensor |
Hi! I tried to replicate the Correlated priors with
LKJCorr
from https://tomicapretto.github.io/posts/2022-06-12_lkj-prior/#model-4-correlated-priors-with-lkjcorr.-replicate-rstanarm-prior using thenumpyro
sampler and got the error:Before
So it would be great to add this operator.
Is this something a newbie like me could try?
After
The text was updated successfully, but these errors were encountered: