You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if apart from the modifiers (#659) we should consider saving original object class as an attribute.
Would one expect to restore the same object class that was saved? If yes, that should make sense.
I don't think IO operations should return different types depending on the environment. I think that's too surprising of behavior, and will definitely lead to bugs in user code.
Plus very little space for interlanguage interoperability.
The tricky thing here is that if a GPU is available Jax will try to put all the data on device which can easily become problematic. While I really do think Jax is promising, a Torch backend is probably way more practical as a result (combined with the fact that most sc ML applications use pytorch). PyTorch also has sparse CSR support.
I am not sure how much of a problem this is in practice though.
Of course we'll have to test it on different setups but I expect it to work smoothly on most of them. Especially considering GPU by default can be turned off.
Also, implementing one alternative backend should make adding more backends easier.
Also there is already a loader with built-in converter to pytorch tensors
This would be different than a complete backend right? We have our own PyTorch dataloader as well in scvi-tools. Backends could support things like PyTorch PCA in Scanpy etc
I agree, a different thing if you have this in mind. But then it gets unclear if things like pytorch (or jax) tensors should be treated in loaders or directly in AnnData objects.
But then it gets unclear if things like pytorch (or jax) tensors should be treated in loaders or directly in AnnData objects.
At least on our side, in the torch case, we would only need to add one line of code to not convert the format in our dataloader. In the Jax case, same thing, but it would be bad for a dataloader if you had jax arrays on GPU and then had to convert to torch gpu I think
JAX is our groups primary mode of development, and it would be fantastic if anndata also supported this! JAX now has experimental support for sparse matrices via BCOO and BCSR as well.
This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!
Activity
gtca commentedon Jan 31, 2022
I wonder if apart from the modifiers (#659) we should consider saving original object class as an attribute.
Would one expect to restore the same object class that was saved? If yes, that should make sense.
If the respective library is not available, we use the default backend (NumPy in this case).
ivirshup commentedon Feb 1, 2022
I don't think IO operations should return different types depending on the environment. I think that's too surprising of behavior, and will definitely lead to bugs in user code.
Plus very little space for interlanguage interoperability.
gtca commentedon Feb 1, 2022
I guess it would be nice to include a «global switch» for the backend when reading files then, i.e.
That would include sparse matrices.
adamgayoso commentedon Mar 7, 2022
The tricky thing here is that if a GPU is available Jax will try to put all the data on device which can easily become problematic. While I really do think Jax is promising, a Torch backend is probably way more practical as a result (combined with the fact that most sc ML applications use pytorch). PyTorch also has sparse CSR support.
gtca commentedon Mar 7, 2022
I am not sure how much of a problem this is in practice though.
Of course we'll have to test it on different setups but I expect it to work smoothly on most of them. Especially considering GPU by default can be turned off.
Also, implementing one alternative backend should make adding more backends easier.
adamgayoso commentedon Mar 7, 2022
Yes but can you then easily turn it back on for only some tensors? Agree that it's not mutually exclusive, jax and torch would be great.
Koncopd commentedon Mar 7, 2022
Also there is already a loader with built-in converter to pytorch tensors
https://github.com/theislab/anndata/tree/master/anndata/experimental/pytorch
https://anndata.readthedocs.io/en/latest/api.html#experimental-api
adamgayoso commentedon Mar 7, 2022
This would be different than a complete backend right? We have our own PyTorch dataloader as well in scvi-tools. Backends could support things like PyTorch PCA in Scanpy etc
Koncopd commentedon Mar 7, 2022
I agree, a different thing if you have this in mind. But then it gets unclear if things like pytorch (or jax) tensors should be treated in loaders or directly in AnnData objects.
adamgayoso commentedon Mar 7, 2022
At least on our side, in the torch case, we would only need to add one line of code to not convert the format in our dataloader. In the Jax case, same thing, but it would be bad for a dataloader if you had jax arrays on GPU and then had to convert to torch gpu I think
Koncopd commentedon Mar 7, 2022
Hm, i think the zero copy conversion can be done via
dlpack:https://jax.readthedocs.io/en/latest/jax.dlpack.html
https://pytorch.org/docs/stable/dlpack.html
quattro commentedon Apr 18, 2023
JAX is our groups primary mode of development, and it would be fantastic if
anndataalso supported this! JAX now has experimental support for sparse matrices via BCOO and BCSR as well.github-actions commentedon Jun 21, 2023
This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!
ivirshup commentedon Jun 21, 2023
Not marking as stale, but also not sure where this sits on a roadmap until there is an implementation plan.
At the moment, I would suggest we can split this into:
read_dispatched