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

Add Cholesky and SolveTriangular for torch #1035

Closed
wants to merge 1 commit into from

Conversation

Ch0ronomato
Copy link
Contributor

@Ch0ronomato Ch0ronomato commented Oct 15, 2024

Description

Add torch cholesky operator

Related Issue

Checklist

Type of change

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

📚 Documentation preview 📚: https://pytensor--1035.org.readthedocs.build/en/1035/

@ricardoV94 ricardoV94 added enhancement New feature or request torch PyTorch backend labels Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 61.11111% with 7 lines in your changes missing coverage. Please review.

Project coverage is 81.89%. Comparing base (b66d859) to head (59eb6b6).
Report is 52 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/link/pytorch/dispatch/slinalg.py 58.82% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1035      +/-   ##
==========================================
+ Coverage   81.74%   81.89%   +0.15%     
==========================================
  Files         183      183              
  Lines       47724    47897     +173     
  Branches    11616     8617    -2999     
==========================================
+ Hits        39011    39225     +214     
+ Misses       6520     6499      -21     
+ Partials     2193     2173      -20     
Files with missing lines Coverage Δ
pytensor/link/pytorch/dispatch/__init__.py 100.00% <100.00%> (ø)
pytensor/link/pytorch/dispatch/slinalg.py 58.82% <58.82%> (ø)

... and 65 files with indirect coverage changes

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

Title should mention SolveTriangular as well

torch = pytest.importorskip("torch")


# @todo: We don't have blockwise yet for torch
Copy link
Member

Choose a reason for hiding this comment

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

This is a specific test, just test cholesky and solve directly with the compare_py_and_torch as usual


def solve_triangular(A, b):
return torch.linalg.solve_triangular(
A, b, upper=not lower, unit_triangle=unit_diagonal, left=trans == "T"
Copy link
Member

Choose a reason for hiding this comment

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

trans may also be 1 apparently. We should canonicalize the integers to strings so the Op only has to handle one of the encodings: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solve_triangular.html

@ricardoV94
Copy link
Member

Actually these Ops were already being tackled in #922

@Ch0ronomato Ch0ronomato changed the title Add Cholesky for torch Add Cholesky and SolveTriangular for torch Oct 15, 2024
@Ch0ronomato
Copy link
Contributor Author

Ah yup - want me to close this then?

@Ch0ronomato
Copy link
Contributor Author

Gonna close this while #922 is open - can always reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request torch PyTorch backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants