# Sparsity-preserving gradient utility tools for PyTorch
A collection of utility functions to work with PyTorch sparse tensors. This is work-in-progress, here be dragons.
Currenly available features with backprop include:
- Memory efficient sparse mm with batch support (workaround for https://github.com/pytorch/pytorch/issues/41128)
- Sparse triangular solver with batch support (see discussion in https://github.com/pytorch/pytorch/issues/87358)
- Generic sparse linear solver (requires a non-differentiable backbone sparse solver)
- Generic sparse linear least-squares solver (requires a non-differentiable backbone sparse linear least-squares solver)
- Wrappers around [cupy sparse solvers](https://docs.cupy.dev/en/stable/reference/scipy_sparse_linalg.html#solving-linear-problems) (see discussion in https://github.com/pytorch/pytorch/issues/69538)
- Wrappers around [jax sparse solvers](https://jax.readthedocs.io/en/latest/jax.scipy.html#module-jax.scipy.sparse.linalg)
- Sparse multivariate normal distribution with sparse covariance and precision parameterisation, with reparameterised sampling (rsample)
Additional backbone solvers implemented in pytorch with no additional dependencies include:
- BICGSTAB (ported from [pykrylov](https://github.com/PythonOptimizers/pykrylov))
- CG (ported from [cornellius-gp/linear_operator](https://github.com/cornellius-gp/linear_operator))
- LSMR (ported from [pytorch-minimize](https://github.com/rfeinman/pytorch-minimize))
- MINRES (ported from [cornellius-gp/linear_operator](https://github.com/cornellius-gp/linear_operator))
Additional features:
- Pairwise voxel encoder for encoding local neighbourhood relationships in a 3D spatial volume with multiple channels, into a sparse COO or CSR matrix.
Things that are missing may be listed as [issues](https://github.com/cai4cai/torchsparsegradutils/issues).
## Installation
The provided package can be installed using:
`pip install torchsparsegradutils`
or
`pip install git+https://github.com/cai4cai/torchsparsegradutils`
## Unit Tests
A number of unittests are provided, which can be run as:
```
python -m pytest
```
(Note that this also runs the tests from `unittest`)
Raw data
{
"_id": null,
"home_page": "https://github.com/cai4cai/torchsparsegradutils",
"name": "torchsparsegradutils",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8, <3.11",
"maintainer_email": "",
"keywords": "sparse torch utility",
"author": "CAI4CAI research group",
"author_email": "contact@cai4cai.uk",
"download_url": "https://files.pythonhosted.org/packages/c6/9c/cc1719a1ac675c59ca08a3361b86585f517a8d9a344ffc3eaaa829210bd5/torchsparsegradutils-0.1.2.tar.gz",
"platform": null,
"description": "# Sparsity-preserving gradient utility tools for PyTorch\nA collection of utility functions to work with PyTorch sparse tensors. This is work-in-progress, here be dragons.\n\nCurrenly available features with backprop include:\n- Memory efficient sparse mm with batch support (workaround for https://github.com/pytorch/pytorch/issues/41128)\n- Sparse triangular solver with batch support (see discussion in https://github.com/pytorch/pytorch/issues/87358)\n- Generic sparse linear solver (requires a non-differentiable backbone sparse solver)\n- Generic sparse linear least-squares solver (requires a non-differentiable backbone sparse linear least-squares solver)\n- Wrappers around [cupy sparse solvers](https://docs.cupy.dev/en/stable/reference/scipy_sparse_linalg.html#solving-linear-problems) (see discussion in https://github.com/pytorch/pytorch/issues/69538)\n- Wrappers around [jax sparse solvers](https://jax.readthedocs.io/en/latest/jax.scipy.html#module-jax.scipy.sparse.linalg)\n- Sparse multivariate normal distribution with sparse covariance and precision parameterisation, with reparameterised sampling (rsample)\n\nAdditional backbone solvers implemented in pytorch with no additional dependencies include:\n- BICGSTAB (ported from [pykrylov](https://github.com/PythonOptimizers/pykrylov))\n- CG (ported from [cornellius-gp/linear_operator](https://github.com/cornellius-gp/linear_operator))\n- LSMR (ported from [pytorch-minimize](https://github.com/rfeinman/pytorch-minimize))\n- MINRES (ported from [cornellius-gp/linear_operator](https://github.com/cornellius-gp/linear_operator))\n\nAdditional features:\n- Pairwise voxel encoder for encoding local neighbourhood relationships in a 3D spatial volume with multiple channels, into a sparse COO or CSR matrix.\n\nThings that are missing may be listed as [issues](https://github.com/cai4cai/torchsparsegradutils/issues).\n\n## Installation\nThe provided package can be installed using:\n\n`pip install torchsparsegradutils`\n\nor\n\n`pip install git+https://github.com/cai4cai/torchsparsegradutils`\n\n## Unit Tests\nA number of unittests are provided, which can be run as:\n\n```\npython -m pytest\n```\n (Note that this also runs the tests from `unittest`)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A collection of utility functions to work with PyTorch sparse tensors",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/cai4cai/torchsparsegradutils"
},
"split_keywords": [
"sparse",
"torch",
"utility"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "87ee753527362adfef288b0ef2273f95ead81e6deb4f505d1c9dae0cddcf3318",
"md5": "5d6b3cdbcc82c3048611685edd0868c3",
"sha256": "3611408bf1f2ff13eceec01c68820d141dd3be42083f2bb84721cb5c771aba6a"
},
"downloads": -1,
"filename": "torchsparsegradutils-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5d6b3cdbcc82c3048611685edd0868c3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8, <3.11",
"size": 84479,
"upload_time": "2023-08-15T15:09:11",
"upload_time_iso_8601": "2023-08-15T15:09:11.356051Z",
"url": "https://files.pythonhosted.org/packages/87/ee/753527362adfef288b0ef2273f95ead81e6deb4f505d1c9dae0cddcf3318/torchsparsegradutils-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c69ccc1719a1ac675c59ca08a3361b86585f517a8d9a344ffc3eaaa829210bd5",
"md5": "0aa16c29c0cfd3a9d5441c87eac351b8",
"sha256": "bcffddee7a2dd4db0552992b612618694f8d76a02dad2671db4cb0ccea7fbafd"
},
"downloads": -1,
"filename": "torchsparsegradutils-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "0aa16c29c0cfd3a9d5441c87eac351b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8, <3.11",
"size": 67366,
"upload_time": "2023-08-15T15:09:13",
"upload_time_iso_8601": "2023-08-15T15:09:13.898282Z",
"url": "https://files.pythonhosted.org/packages/c6/9c/cc1719a1ac675c59ca08a3361b86585f517a8d9a344ffc3eaaa829210bd5/torchsparsegradutils-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-15 15:09:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cai4cai",
"github_project": "torchsparsegradutils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "torchsparsegradutils"
}