-
Notifications
You must be signed in to change notification settings - Fork 130
Add Cholesky dot(L, L.T) rewrite and remove sandbox module #303
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
Conversation
Thanks @dehorsley. Note that PyMC will still have a messed up dlogp, so it may not be enough to fix performance, but it should at least help. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #303 +/- ##
==========================================
- Coverage 80.50% 80.49% -0.01%
==========================================
Files 154 154
Lines 45186 45204 +18
Branches 11046 11056 +10
==========================================
+ Hits 36376 36387 +11
- Misses 6608 6611 +3
- Partials 2202 2206 +4
|
@ricardoV94 one question about this: it's not clear to me that when |
We should move the rewrites (also the old ones unless you see any potential problems with them) to I think we can just delete the whole Do you mind doing that? |
I've hit a circular dependency with this:
from pytensor.tensor.rewriting.elemwise import local_dimshuffle_lift And from pytensor.tensor.blas import Dot22 Maybe the "right" thing to do is to move the rewrites in EDIT: I've gone with the latter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for the rewrite change that's still there.
Thanks, done. By the way, I got a lot of mypy errors in unrelated files as part of the |
Sometimes pre-commit fails locally because it's run only on the changed files but passes here where it is run globally. I'll make the tests run now and we can see |
Is this the failure you saw? https://github.com/pymc-devs/pytensor/actions/runs/5055814502/jobs/9072710031?pr=303#step:4:434 I guess it's just a case of removing it? |
Yup that's what I saw locally too. Any idea what to do? |
I think we can remove those @michaelosthege any guidance here? |
Yeah, I had to disable pre-commit to commit the change. Should otherwise be good to go if the tests run fine. They ran OK locally so 🤞. |
sounds pretty much like they can be removed |
looks like the fixed it locally |
The failing tests seem to be to do with some numba random issues unrelated to this PR. Are you happy otherwise @ricardoV94 ? |
Having Ops and rewrites in the same files was causing circular imports.
Moving caused a circular dependency with tensor.blas. It seems most linalg rewrites are in the stablize set, so should run before the blas specializers anyway, so these checks were removed. This also deleted the unused `spectral_radius_bound` and dummy `Minimal(Op)`.
@dehorsley the numba tests were fixed in another PR. I rebased from main and also rearranged the commits so that the library is "coherent" after each step. If tests pass I think this is good to go. |
Thanks @dehorsley Do you want to investigate how much this helps on the PyMC side? We will have to add the tag to the value variable when it comes out of that transform |
Since pymc-devs/pytensor#303, `cholesky(L.dot(L.T))` will rewritten to L if `L.tag.lower_triangular=True`. This change adds these where appropriate. Fixes pymc-devs#6717.
Since pymc-devs/pytensor#303, `cholesky(L.dot(L.T))` will rewritten to L if `L.tag.lower_triangular=True`. This change adds these where appropriate. Fixes #6717.
Motivation for these changes
As discussed in pymc-devs/pymc#6717, it is useful in PyMC to rewrite
cholesky(dot(L,L.T))
->L
for use in MvNormal logp.The equivalent was included for the upper triangular factor case.
Implementation details
This uses a
lower_triangular
orupper_triangular
tag to ensure the input matrix is the correct form.New features
cholesky(dot(L, L.T))