Sparse operators in Lineax: CSR/CSC and COO format#178
Sparse operators in Lineax: CSR/CSC and COO format#178johannahaffner wants to merge 2 commits intopatrick-kidger:mainfrom
Conversation
|
I've updated the documentation. I think some sparsity-specific tests would be good, I'm not yet convinced that we're catching everything that we should be catching. |
|
Cross-reference: discussion about sparse data types in jax-ml/jax#33514 |
|
Whilst I love the idea of sparse operators in JAX, I'm a bit antsy about depending on the unmaintained At least for the representation of the operator I'm guessing that we could just store coordinates/etc as JAX arrays ourselves, without using e.g. |
|
Yes, that is pretty much where I land on this as well. I don't think this should be part of the next release, at the very least a lot of sparsity-specific testing needs to be done first - it could be that we circumvent a lot of edge cases by virtue of testing these with solvers that never actually need to interact with the sparse structures themselves, and either work with the densely materialised matrix or matrix-vector products. Not relying on FWIW I would not call TLDR - let's not merge this now, leave it here and / or revisit it for BCSR later. Right now the only use case is CuDSS anyway, and the operator is basically a vessel to communicate to CuDSS what the values, offsets and columns are. We can do all of this in Spineax. |
|
Closing this for now. |
These operators wrap the respective JAX operators. They are currently limited to 2D matrices, which is what JAX supports as well. As discussed in #24 (comment), this introduces a dependency on
jax.experimental.sparse, which while part of the experimental module does seem to be actively maintained. This is mostly necessary so that we can use their implementation of__matmul__.It turns out I had the COO version already, I had forgotten about that 😃
As a drive-by change, this adds extra fixtures for cache clearing, which were necessary to get tests to pass on the Linux machine I was using while coding this up.
Some loose strings to tie up:
BCOO,BCSR) may be substituted for their bare-bones, non-batched counterparts. I have not checked whether these pass all the tests, and whether their special batching rules would interfere with what we're already doing. Vmapping works without using these formats.