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 support of scipy.linalg.solve_banded() #607

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

AxelBreuer
Copy link

Until now, autograd only handles scipy.linalg.solve() and scipy.linalg.solve_triangular().

In contrast to scipy.linalg.solve() and scipy.linalg.solve_triangular(); scipy.linalg.solve_banded() can handle VERY large systems of equations.

In fact, I think that solve_banded() could interest a lot of autograd users: banded systems are ubiquitous in ODEs, PDEs and signal processing.

Furthermore, solve_banded() could be of interest to a wider audience, since sparse matrix solvers are not handled yet by torch.autograd (to the best of my knowledge).

In that sense, solve_banded() would be a first step towards handling a specific subset of sparse matrices, namely banded matrices.

Last but not least, I hope that, at a later stage, someone could then adapt, improve and include my code to torch.autograd and/or jax.

@j-towns
Copy link
Collaborator

j-towns commented Sep 26, 2023

Thanks @AxelBreuer! Could you please add a test, the right place to do it is down here:

## Linalg
def test_sqrtm(): combo_check(spla.sqrtm, modes=['fwd'], order=2)([R(3, 3)])
def test_sqrtm(): combo_check(symmetrize_matrix_arg(spla.sqrtm, 0), modes=['fwd', 'rev'], order=2)([R(3, 3)])
def test_solve_sylvester(): combo_check(spla.solve_sylvester, [0, 1, 2], modes=['rev', 'fwd'], order=2)([R(3, 3)], [R(3, 3)], [R(3, 3)])
.

@AxelBreuer
Copy link
Author

AxelBreuer commented Oct 8, 2023

Hi @j-towns I wrote the test you asked for. This exercise actually helped me to find a bug in my original code; which I corrected. Overall my code and test could probably be more elegant, but they do the job.

@j-towns
Copy link
Collaborator

j-towns commented Nov 16, 2023

Hi @AxelBreuer, nice work! I reverted some unnecessary changes to test_scipy.py, but this is now ready to merge. Thanks, and sorry for the long wait.

@j-towns j-towns merged commit 9a90bd6 into HIPS:master Nov 16, 2023
26 of 27 checks passed
@AxelBreuer
Copy link
Author

Thank you so much Jamie !

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.

2 participants