Skip to content
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

Adds functions to rewrite cholesky decomposition of identity and diagonal matrices #925

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

tanish1729
Copy link
Contributor

Description

Add a function to rewrite cholesky(eye) -> eye and cholesky(diag) -> sqrt(diag)

Related Issue

Checklist

Type of change

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

Copy link

codecov bot commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.76%. Comparing base (3e98b9f) to head (cf87362).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/tensor/rewriting/linalg.py 93.93% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #925   +/-   ##
=======================================
  Coverage   81.75%   81.76%           
=======================================
  Files         183      183           
  Lines       47763    47796   +33     
  Branches    11619    11635   +16     
=======================================
+ Hits        39050    39081   +31     
+ Misses       6523     6522    -1     
- Partials     2190     2193    +3     
Files with missing lines Coverage Δ
pytensor/tensor/rewriting/linalg.py 90.93% <93.93%> (+0.29%) ⬆️

... and 2 files with indirect coverage changes

@tanish1729
Copy link
Contributor Author

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and suggestions. I'd also ask that you add a test to make sure the cases that should not be rewritten are, in fact, not rewritten. For example, pt.linalg.cholesky(pt.eye(7, k=-1) * x)

pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
tests/tensor/rewriting/test_linalg.py Outdated Show resolved Hide resolved
Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, just a couple nitpicks. Could you also add a batch case to each of test_cholesky_diag_from_diag and test_cholesky_diag_from_eye_mul, then I think we'll be there.

tests/tensor/rewriting/test_linalg.py Show resolved Hide resolved
tests/tensor/rewriting/test_linalg.py Outdated Show resolved Hide resolved
@tanish1729 tanish1729 force-pushed the cholesky_eye_diag branch 2 times, most recently from 0b69d85 to 365b6df Compare August 5, 2024 12:18
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
pytensor/tensor/rewriting/linalg.py Outdated Show resolved Hide resolved
Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jessegrabowski jessegrabowski merged commit be6a032 into pymc-devs:main Oct 8, 2024
60 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants