torchsparsegradutils 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. {torchsparsegradutils-0.2.0/torchsparsegradutils.egg-info → torchsparsegradutils-0.2.1}/PKG-INFO +21 -23
  2. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/README.md +4 -4
  3. torchsparsegradutils-0.2.1/docs/source/conf.py +187 -0
  4. torchsparsegradutils-0.2.1/pyproject.toml +110 -0
  5. torchsparsegradutils-0.2.1/setup.py +5 -0
  6. torchsparsegradutils-0.2.1/torchsparsegradutils/encoders/__init__.py +44 -0
  7. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/encoders/pairwise_encoder.py +6 -2
  8. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/encoders/pairwise_voxel_encoder.py +3 -10
  9. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_encoders.py +50 -59
  10. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_integration_pairwise_sparse_mvn.py +2 -2
  11. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1/torchsparsegradutils.egg-info}/PKG-INFO +21 -23
  12. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils.egg-info/SOURCES.txt +1 -0
  13. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils.egg-info/requires.txt +9 -0
  14. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils.egg-info/top_level.txt +3 -0
  15. torchsparsegradutils-0.2.0/pyproject.toml +0 -49
  16. torchsparsegradutils-0.2.0/setup.py +0 -50
  17. torchsparsegradutils-0.2.0/torchsparsegradutils/encoders/__init__.py +0 -14
  18. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/LICENSE +0 -0
  19. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/MANIFEST.in +0 -0
  20. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/setup.cfg +0 -0
  21. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/__init__.py +0 -0
  22. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/__init__.py +0 -0
  23. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/batched_sparse_mm_rand.py +0 -0
  24. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/benchmark_suite.py +0 -0
  25. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/benchmark_utils.py +0 -0
  26. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/sparse_generic_solve_rand.py +0 -0
  27. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/sparse_generic_solve_suite.py +0 -0
  28. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/sparse_mm_rand.py +0 -0
  29. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/sparse_mm_suite.py +0 -0
  30. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/sparse_triangular_solve_rand.py +0 -0
  31. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/sparse_triangular_solve_suitesparse.py +0 -0
  32. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/benchmarks/visualize_benchmark_results.py +0 -0
  33. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/cupy/__init__.py +0 -0
  34. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/cupy/cupy_bindings.py +0 -0
  35. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/cupy/cupy_sparse_solve.py +0 -0
  36. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/distributions/__init__.py +0 -0
  37. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/distributions/constraints.py +0 -0
  38. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/distributions/sparse_multivariate_normal.py +0 -0
  39. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/indexed_matmul.py +0 -0
  40. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/jax/__init__.py +0 -0
  41. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/jax/jax_bindings.py +0 -0
  42. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/jax/jax_sparse_solve.py +0 -0
  43. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/sparse_lstsq.py +0 -0
  44. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/sparse_matmul.py +0 -0
  45. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/sparse_solve.py +0 -0
  46. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/__init__.py +0 -0
  47. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_bicgstab.py +0 -0
  48. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_cupy_bindings.py +0 -0
  49. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_cupy_sparse_solve.py +0 -0
  50. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_dist_stats_helpers.py +0 -0
  51. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_distributions.py +0 -0
  52. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_doctests.py +0 -0
  53. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_indexed_matmul.py +0 -0
  54. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_jax_bindings.py +0 -0
  55. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_jax_sparse_solve.py +0 -0
  56. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_linear_cg.py +0 -0
  57. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_lsmr.py +0 -0
  58. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_minres.py +0 -0
  59. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_params/czyx_shifts.yaml +0 -0
  60. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_params/pairwise_coo_indices.yaml +0 -0
  61. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_params/xyz_coords.yaml +0 -0
  62. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_quickstart_guide.py +0 -0
  63. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_random.py +0 -0
  64. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_sparse_lstsq.py +0 -0
  65. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_sparse_matmul.py +0 -0
  66. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_sparse_solve.py +0 -0
  67. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_sparse_triangular_solve.py +0 -0
  68. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/tests/test_utils.py +0 -0
  69. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/__init__.py +0 -0
  70. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/bicgstab.py +0 -0
  71. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/dist_stats_helpers.py +0 -0
  72. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/linear_cg.py +0 -0
  73. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/lsmr.py +0 -0
  74. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/minres.py +0 -0
  75. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/random_sparse.py +0 -0
  76. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils/utils/utils.py +0 -0
  77. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils.egg-info/dependency_links.txt +0 -0
  78. {torchsparsegradutils-0.2.0 → torchsparsegradutils-0.2.1}/torchsparsegradutils.egg-info/not-zip-safe +0 -0
@@ -1,14 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torchsparsegradutils
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A collection of utility functions to work with PyTorch sparse tensors
5
- Home-page: https://github.com/cai4cai/torchsparsegradutils
6
- Author: CAI4CAI research group
7
- Author-email: contact@cai4cai.uk
8
- License: Apache-2.0
9
- Keywords: sparse torch utility
5
+ Author-email: CAI4CAI research group <contact@cai4cai.uk>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/cai4cai/torchsparsegradutils
8
+ Project-URL: Documentation, https://torchsparsegradutils.readthedocs.io
9
+ Project-URL: Repository, https://github.com/cai4cai/torchsparsegradutils
10
+ Project-URL: Issues, https://github.com/cai4cai/torchsparsegradutils/issues
11
+ Project-URL: Changelog, https://github.com/cai4cai/torchsparsegradutils/releases
12
+ Keywords: sparse,torch,utility
10
13
  Classifier: Operating System :: OS Independent
11
- Classifier: License :: OSI Approved :: Apache Software License
12
14
  Classifier: Programming Language :: Python :: 3.10
13
15
  Classifier: Programming Language :: Python :: 3.11
14
16
  Classifier: Programming Language :: Python :: 3.12
@@ -28,23 +30,19 @@ Requires-Dist: myst-parser>=2.0.0; extra == "docs"
28
30
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "docs"
29
31
  Requires-Dist: matplotlib>=3.5.0; extra == "docs"
30
32
  Requires-Dist: sphinx-autodoc-typehints>=1.24.0; extra == "docs"
31
- Dynamic: author
32
- Dynamic: author-email
33
- Dynamic: classifier
34
- Dynamic: description
35
- Dynamic: description-content-type
36
- Dynamic: home-page
37
- Dynamic: keywords
38
- Dynamic: license
33
+ Requires-Dist: sphinxcontrib-bibtex>=2.5.0; extra == "docs"
34
+ Requires-Dist: sphinx-gallery>=0.13.0; extra == "docs"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest; extra == "dev"
37
+ Requires-Dist: pytest-cov; extra == "dev"
38
+ Requires-Dist: black; extra == "dev"
39
+ Requires-Dist: isort; extra == "dev"
40
+ Requires-Dist: flake8; extra == "dev"
39
41
  Dynamic: license-file
40
- Dynamic: provides-extra
41
- Dynamic: requires-dist
42
- Dynamic: requires-python
43
- Dynamic: summary
44
42
 
45
43
  # torchsparsegradutils: Sparsity-preserving gradient utility tools for PyTorch
46
44
 
47
- [![Python tests](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml/badge.svg)](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml) [![License](https://img.shields.io/github/license/cai4cai/torchsparsegradutils)](https://github.com/cai4cai/torchsparsegradutils?tab=Apache-2.0-1-ov-file#readme) [![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
45
+ [![PyPI](https://img.shields.io/pypi/v/torchsparsegradutils.svg)](https://pypi.org/project/torchsparsegradutils/) [![Python Versions](https://img.shields.io/pypi/pyversions/torchsparsegradutils.svg)](https://pypi.org/project/torchsparsegradutils/) [![Downloads](https://img.shields.io/pypi/dm/torchsparsegradutils.svg)](https://pypi.org/project/torchsparsegradutils/) ![PyTorch 2.5+](https://img.shields.io/badge/PyTorch-2.5%2B-ee4c2c?logo=pytorch) ![Tested 2.5 / 2.9 / nightly](https://img.shields.io/badge/Tested-2.5%20|%202.9%20|%20nightly-ee4c2c?logo=pytorch) [![Build](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml/badge.svg)](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml) [![Docs](https://readthedocs.org/projects/torchsparsegradutils/badge/?version=latest)](https://readthedocs.org/projects/torchsparsegradutils) [![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![License](https://img.shields.io/github/license/cai4cai/torchsparsegradutils)](LICENSE) [![status](https://joss.theoj.org/papers/6da0e92488d06f70c0a03d0a7cbfba7d/status.svg)](https://joss.theoj.org/papers/6da0e92488d06f70c0a03d0a7cbfba7d)
48
46
 
49
47
  A comprehensive collection of utility functions to work with PyTorch sparse tensors, ensuring memory efficiency and supporting various sparsity-preserving tensor operations with automatic differentiation. This package addresses fundamental gaps in PyTorch's sparse tensor ecosystem, providing essential operations that preserve sparsity in gradients during backpropagation.
50
48
 
@@ -156,7 +154,7 @@ pip install scipy matplotlib pandas tqdm pytest
156
154
 
157
155
  ## 📊 Performance Benchmarks
158
156
 
159
- Our comprehensive benchmark suite demonstrates significant performance improvements across various sparse operations. All benchmarks were conducted on an NVIDIA GeForce RTX 4090 with PyTorch 2.8.0+cu128. Benchmarks are performed using [Rothberg/cfd2](https://suitesparse-collection-website.herokuapp.com/Rothberg/cfd2) matrix from [SuiteSparse Matrix Collection](https://suitesparse-collection-website.herokuapp.com/)
157
+ Our comprehensive benchmark suite demonstrates significant performance improvements across various sparse operations. All benchmarks were conducted on an NVIDIA GeForce RTX 4090 with PyTorch 2.9.0+cu130. Benchmarks are performed using [Rothberg/cfd2](https://suitesparse-collection-website.herokuapp.com/Rothberg/cfd2) matrix from [SuiteSparse Matrix Collection](https://suitesparse-collection-website.herokuapp.com/)
160
158
 
161
159
  ![Sparse MM Suite Performance (int32/float32 COO)](torchsparsegradutils/benchmarks/benchmark_visualizations/sparse_mm_suite_performance_int32_float32_coo.png)
162
160
 
@@ -543,7 +541,7 @@ For a consistent development environment with GPU support and all dependencies p
543
541
 
544
542
  **Available Configurations:**
545
543
 
546
- - **`.devcontainer/Dockerfile.stable`** (default): Uses stable PyTorch with CUDA 12.8 support
544
+ - **`.devcontainer/Dockerfile.stable`** (default): Uses stable PyTorch with CUDA 13.0 support
547
545
  - **`.devcontainer/Dockerfile.nightly`**: Uses nightly PyTorch builds for latest features
548
546
 
549
547
  To switch configurations, modify the `dockerfile` field in `.devcontainer/devcontainer.json`:
@@ -555,7 +553,7 @@ To switch configurations, modify the `dockerfile` field in `.devcontainer/devcon
555
553
  ```
556
554
 
557
555
  **What's Included:**
558
- - **CUDA 12.8**: Full GPU development support with NVIDIA drivers
556
+ - **CUDA 13.0**: Full GPU development support with NVIDIA drivers
559
557
  - **Pre-installed Dependencies**: PyTorch, CuPy, JAX, SciPy, and all development tools
560
558
  - **VS Code Extensions**: Python, Pylance, Jupyter, GitHub Copilot, and code formatting tools
561
559
  - **Development Tools**: pytest, black, flake8, pre-commit hooks
@@ -1,6 +1,6 @@
1
1
  # torchsparsegradutils: Sparsity-preserving gradient utility tools for PyTorch
2
2
 
3
- [![Python tests](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml/badge.svg)](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml) [![License](https://img.shields.io/github/license/cai4cai/torchsparsegradutils)](https://github.com/cai4cai/torchsparsegradutils?tab=Apache-2.0-1-ov-file#readme) [![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
3
+ [![PyPI](https://img.shields.io/pypi/v/torchsparsegradutils.svg)](https://pypi.org/project/torchsparsegradutils/) [![Python Versions](https://img.shields.io/pypi/pyversions/torchsparsegradutils.svg)](https://pypi.org/project/torchsparsegradutils/) [![Downloads](https://img.shields.io/pypi/dm/torchsparsegradutils.svg)](https://pypi.org/project/torchsparsegradutils/) ![PyTorch 2.5+](https://img.shields.io/badge/PyTorch-2.5%2B-ee4c2c?logo=pytorch) ![Tested 2.5 / 2.9 / nightly](https://img.shields.io/badge/Tested-2.5%20|%202.9%20|%20nightly-ee4c2c?logo=pytorch) [![Build](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml/badge.svg)](https://github.com/cai4cai/torchsparsegradutils/actions/workflows/python-package.yml) [![Docs](https://readthedocs.org/projects/torchsparsegradutils/badge/?version=latest)](https://readthedocs.org/projects/torchsparsegradutils) [![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![License](https://img.shields.io/github/license/cai4cai/torchsparsegradutils)](LICENSE) [![status](https://joss.theoj.org/papers/6da0e92488d06f70c0a03d0a7cbfba7d/status.svg)](https://joss.theoj.org/papers/6da0e92488d06f70c0a03d0a7cbfba7d)
4
4
 
5
5
  A comprehensive collection of utility functions to work with PyTorch sparse tensors, ensuring memory efficiency and supporting various sparsity-preserving tensor operations with automatic differentiation. This package addresses fundamental gaps in PyTorch's sparse tensor ecosystem, providing essential operations that preserve sparsity in gradients during backpropagation.
6
6
 
@@ -112,7 +112,7 @@ pip install scipy matplotlib pandas tqdm pytest
112
112
 
113
113
  ## 📊 Performance Benchmarks
114
114
 
115
- Our comprehensive benchmark suite demonstrates significant performance improvements across various sparse operations. All benchmarks were conducted on an NVIDIA GeForce RTX 4090 with PyTorch 2.8.0+cu128. Benchmarks are performed using [Rothberg/cfd2](https://suitesparse-collection-website.herokuapp.com/Rothberg/cfd2) matrix from [SuiteSparse Matrix Collection](https://suitesparse-collection-website.herokuapp.com/)
115
+ Our comprehensive benchmark suite demonstrates significant performance improvements across various sparse operations. All benchmarks were conducted on an NVIDIA GeForce RTX 4090 with PyTorch 2.9.0+cu130. Benchmarks are performed using [Rothberg/cfd2](https://suitesparse-collection-website.herokuapp.com/Rothberg/cfd2) matrix from [SuiteSparse Matrix Collection](https://suitesparse-collection-website.herokuapp.com/)
116
116
 
117
117
  ![Sparse MM Suite Performance (int32/float32 COO)](torchsparsegradutils/benchmarks/benchmark_visualizations/sparse_mm_suite_performance_int32_float32_coo.png)
118
118
 
@@ -499,7 +499,7 @@ For a consistent development environment with GPU support and all dependencies p
499
499
 
500
500
  **Available Configurations:**
501
501
 
502
- - **`.devcontainer/Dockerfile.stable`** (default): Uses stable PyTorch with CUDA 12.8 support
502
+ - **`.devcontainer/Dockerfile.stable`** (default): Uses stable PyTorch with CUDA 13.0 support
503
503
  - **`.devcontainer/Dockerfile.nightly`**: Uses nightly PyTorch builds for latest features
504
504
 
505
505
  To switch configurations, modify the `dockerfile` field in `.devcontainer/devcontainer.json`:
@@ -511,7 +511,7 @@ To switch configurations, modify the `dockerfile` field in `.devcontainer/devcon
511
511
  ```
512
512
 
513
513
  **What's Included:**
514
- - **CUDA 12.8**: Full GPU development support with NVIDIA drivers
514
+ - **CUDA 13.0**: Full GPU development support with NVIDIA drivers
515
515
  - **Pre-installed Dependencies**: PyTorch, CuPy, JAX, SciPy, and all development tools
516
516
  - **VS Code Extensions**: Python, Pylance, Jupyter, GitHub Copilot, and code formatting tools
517
517
  - **Development Tools**: pytest, black, flake8, pre-commit hooks
@@ -0,0 +1,187 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ import os
10
+ import sys
11
+
12
+ # Add the package to the Python path
13
+ sys.path.insert(0, os.path.abspath("../../"))
14
+
15
+ project = "torchsparsegradutils"
16
+ copyright = "2025, CAI4CAI research group"
17
+ author = "CAI4CAI research group"
18
+ release = "0.2.1"
19
+ version = "0.2.1"
20
+
21
+ # -- General configuration ---------------------------------------------------
22
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
23
+
24
+ extensions = [
25
+ "sphinx.ext.autodoc", # Automatic documentation from docstrings
26
+ "sphinx.ext.autosummary", # Generate autodoc summaries
27
+ "sphinx.ext.napoleon", # Support for NumPy and Google style docstrings
28
+ "sphinx.ext.viewcode", # Add links to highlighted source code
29
+ "sphinx.ext.mathjax", # Math notation support
30
+ "sphinx.ext.intersphinx", # Link to other project's documentation
31
+ "sphinx.ext.coverage", # Documentation coverage
32
+ "sphinx.ext.githubpages", # GitHub Pages support
33
+ "sphinx_copybutton", # Add copy button to code blocks
34
+ "myst_parser", # Markdown support
35
+ ]
36
+
37
+ # Autosummary settings
38
+ autosummary_generate = True
39
+ autosummary_imported_members = True
40
+
41
+ # Napoleon settings for docstring parsing
42
+ napoleon_google_docstring = True
43
+ napoleon_numpy_docstring = True
44
+ napoleon_include_init_with_doc = False
45
+ napoleon_include_private_with_doc = False
46
+ napoleon_include_special_with_doc = True
47
+ napoleon_use_admonition_for_examples = False
48
+ napoleon_use_admonition_for_notes = False
49
+ napoleon_use_admonition_for_references = False
50
+ napoleon_use_ivar = False
51
+ napoleon_use_param = True
52
+ napoleon_use_rtype = True
53
+ napoleon_preprocess_types = False
54
+ napoleon_type_aliases = None
55
+ napoleon_attr_annotations = True
56
+
57
+ # Autodoc settings
58
+ autodoc_default_options = {
59
+ "members": True,
60
+ "member-order": "bysource",
61
+ "special-members": "__init__",
62
+ "undoc-members": True,
63
+ "exclude-members": "__weakref__",
64
+ }
65
+
66
+ # Intersphinx mapping
67
+ intersphinx_mapping = {
68
+ "python": ("https://docs.python.org/3/", None),
69
+ "torch": ("https://pytorch.org/docs/stable/", None),
70
+ "numpy": ("https://numpy.org/doc/stable/", None),
71
+ "scipy": ("https://docs.scipy.org/doc/scipy/", None),
72
+ "jax": ("https://jax.readthedocs.io/en/latest/", None),
73
+ "cupy": ("https://docs.cupy.dev/en/stable/", None),
74
+ }
75
+
76
+ templates_path = ["_templates"]
77
+ exclude_patterns = []
78
+
79
+ # Source file parsers
80
+ source_suffix = {
81
+ ".rst": None,
82
+ ".md": "myst_parser",
83
+ }
84
+
85
+ # -- Options for HTML output -------------------------------------------------
86
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
87
+
88
+ html_theme = "sphinx_rtd_theme"
89
+ html_static_path = ["_static"]
90
+
91
+ # Theme options
92
+ html_theme_options = {
93
+ "canonical_url": "",
94
+ "analytics_id": "",
95
+ "logo_only": False,
96
+ "prev_next_buttons_location": "bottom",
97
+ "style_external_links": False,
98
+ "vcs_pageview_mode": "",
99
+ "style_nav_header_background": "#2980B9",
100
+ # Toc options
101
+ "collapse_navigation": True,
102
+ "sticky_navigation": True,
103
+ "navigation_depth": 4,
104
+ "includehidden": True,
105
+ "titles_only": False,
106
+ }
107
+
108
+ # Add any paths that contain custom static files (such as style sheets) here,
109
+ # relative to this directory. They are copied after the builtin static files,
110
+ # so a file named "default.css" will overwrite the builtin "default.css".
111
+ html_static_path = ["_static"]
112
+
113
+ # Custom CSS
114
+ html_css_files = [
115
+ "custom.css",
116
+ ]
117
+
118
+ # HTML title
119
+ html_title = f"{project} v{version}"
120
+
121
+ # Favicon
122
+ # html_favicon = '_static/favicon.ico'
123
+
124
+ # Logo
125
+ # html_logo = '_static/logo.png'
126
+
127
+ # -- Options for LaTeX output ------------------------------------------------
128
+ latex_engine = "pdflatex"
129
+ latex_elements = {
130
+ # The paper size ('letterpaper' or 'a4paper').
131
+ "papersize": "letterpaper",
132
+ # The font size ('10pt', '11pt' or '12pt').
133
+ "pointsize": "10pt",
134
+ # Additional stuff for the LaTeX preamble.
135
+ "preamble": r"""
136
+ \usepackage{amsmath}
137
+ \usepackage{amsfonts}
138
+ \usepackage{amssymb}
139
+ \usepackage{mathrsfs}
140
+ """,
141
+ }
142
+
143
+ # Grouping the document tree into LaTeX files. List of tuples
144
+ # (source start file, target name, title, author, documentclass [howto, manual, or own class]).
145
+ latex_documents = [
146
+ ("index", "torchsparsegradutils.tex", "torchsparsegradutils Documentation", "CAI4CAI research group", "manual"),
147
+ ]
148
+
149
+ # -- Options for manual page output ------------------------------------------
150
+ # One entry per manual page. List of tuples
151
+ # (source start file, name, description, authors, manual section).
152
+ man_pages = [("index", "torchsparsegradutils", "torchsparsegradutils Documentation", [author], 1)]
153
+
154
+ # -- Options for Texinfo output ----------------------------------------------
155
+ # Grouping the document tree into Texinfo files. List of tuples
156
+ # (source start file, target name, title, author,
157
+ # dir menu entry, description, category)
158
+ texinfo_documents = [
159
+ (
160
+ "index",
161
+ "torchsparsegradutils",
162
+ "torchsparsegradutils Documentation",
163
+ author,
164
+ "torchsparsegradutils",
165
+ "PyTorch sparse tensor utilities.",
166
+ "Miscellaneous",
167
+ ),
168
+ ]
169
+
170
+ # -- Extension configuration -------------------------------------------------
171
+ # Copy button configuration
172
+ copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
173
+ copybutton_prompt_is_regexp = True
174
+
175
+ # Math notation
176
+ mathjax3_config = {
177
+ "tex": {
178
+ "inlineMath": [["$", "$"], ["\\(", "\\)"]],
179
+ "displayMath": [["$$", "$$"], ["\\[", "\\]"]],
180
+ "processEscapes": True,
181
+ "processEnvironments": True,
182
+ },
183
+ "options": {
184
+ "ignoreHtmlClass": "tex2jax_ignore",
185
+ "processHtmlClass": "tex2jax_process",
186
+ },
187
+ }
@@ -0,0 +1,110 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "torchsparsegradutils"
7
+ version = "0.2.1"
8
+ description = "A collection of utility functions to work with PyTorch sparse tensors"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ authors = [
13
+ {name = "CAI4CAI research group", email = "contact@cai4cai.uk"}
14
+ ]
15
+ keywords = ["sparse", "torch", "utility"]
16
+ classifiers = [
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ ]
22
+ dependencies = [
23
+ "torch>=2.5",
24
+ "scipy",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ extras = ["jax", "cupy"]
29
+ docs = [
30
+ "sphinx>=7.0.0",
31
+ "sphinx-rtd-theme>=1.3.0",
32
+ "sphinx-copybutton>=0.5.0",
33
+ "myst-parser>=2.0.0",
34
+ "sphinx-autobuild>=2021.3.14",
35
+ "matplotlib>=3.5.0",
36
+ "sphinx-autodoc-typehints>=1.24.0",
37
+ "sphinxcontrib-bibtex>=2.5.0",
38
+ "sphinx-gallery>=0.13.0",
39
+ ]
40
+ dev = [
41
+ "pytest",
42
+ "pytest-cov",
43
+ "black",
44
+ "isort",
45
+ "flake8",
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/cai4cai/torchsparsegradutils"
50
+ Documentation = "https://torchsparsegradutils.readthedocs.io"
51
+ Repository = "https://github.com/cai4cai/torchsparsegradutils"
52
+ Issues = "https://github.com/cai4cai/torchsparsegradutils/issues"
53
+ Changelog = "https://github.com/cai4cai/torchsparsegradutils/releases"
54
+
55
+ [tool.setuptools]
56
+ zip-safe = false
57
+ include-package-data = true
58
+
59
+ [tool.setuptools.packages.find]
60
+ exclude = ["tests*"]
61
+
62
+ [tool.black]
63
+ line-length = 120
64
+ target-version = ['py310', 'py311', 'py312']
65
+ include = '\.pyi?$'
66
+ exclude = '''
67
+ (
68
+ /(
69
+ # exclude a few common directories in the root of the project
70
+ \.eggs
71
+ | \.git
72
+ | \.hg
73
+ | \.mypy_cache
74
+ | \.tox
75
+ | \.venv
76
+ | \.pytype
77
+ | _build
78
+ | buck-out
79
+ | build
80
+ | dist
81
+ )/
82
+ # also separately exclude other files if needed
83
+ #| some_file
84
+ )
85
+ '''
86
+
87
+ [tool.isort]
88
+ profile = "black"
89
+ multi_line_output = 3
90
+ line_length = 120
91
+ known_first_party = ["torchsparsegradutils"]
92
+ force_grid_wrap = 0
93
+ combine_as_imports = true
94
+ include_trailing_comma = true
95
+
96
+ [tool.pytest.ini_options]
97
+ minversion = "6.0"
98
+ addopts = ["-v"]
99
+ testpaths = [
100
+ "torchsparsegradutils/tests",
101
+ ]
102
+ doctest_optionflags = [
103
+ "NORMALIZE_WHITESPACE",
104
+ "IGNORE_EXCEPTION_DETAIL",
105
+ "ELLIPSIS"
106
+ ]
107
+ # Separate command for doctests due to potential issues
108
+ markers = [
109
+ "slow: marks tests as slow (deselect with '-m \"not slow\"')",
110
+ ]
@@ -0,0 +1,5 @@
1
+ # Minimal setup.py for backward compatibility
2
+ # All configuration is now in pyproject.toml
3
+ from setuptools import setup
4
+
5
+ setup()
@@ -0,0 +1,44 @@
1
+ # Import from the new pairwise_encoder module (recommended)
2
+ from .pairwise_encoder import PairwiseEncoder, calc_pairwise_coo_indices_nd
3
+
4
+
5
+ def __getattr__(name):
6
+ """Lazy-load deprecated aliases to avoid import-time warnings."""
7
+ if name == "PairwiseVoxelEncoder":
8
+ # Import without warning here - the class itself will warn when instantiated
9
+ from .pairwise_voxel_encoder import PairwiseVoxelEncoder
10
+
11
+ return PairwiseVoxelEncoder
12
+ elif name == "calc_pairwise_coo_indices":
13
+ import warnings
14
+
15
+ warnings.warn(
16
+ "calc_pairwise_coo_indices is deprecated and will be removed in a future version. "
17
+ "Use calc_pairwise_coo_indices_nd instead.",
18
+ DeprecationWarning,
19
+ stacklevel=2,
20
+ )
21
+ from .pairwise_encoder import calc_pairwise_coo_indices
22
+
23
+ return calc_pairwise_coo_indices
24
+ elif name == "calc_pariwise_coo_indices":
25
+ import warnings
26
+
27
+ warnings.warn(
28
+ "calc_pariwise_coo_indices (typo) is deprecated and will be removed in a future version. "
29
+ "Use calc_pairwise_coo_indices_nd instead. "
30
+ "Note: This function name contains a typo; use calc_pairwise_coo_indices for the corrected spelling.",
31
+ DeprecationWarning,
32
+ stacklevel=2,
33
+ )
34
+ from .pairwise_encoder import calc_pariwise_coo_indices
35
+
36
+ return calc_pariwise_coo_indices
37
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
38
+
39
+
40
+ __all__ = [
41
+ # New recommended classes and functions
42
+ "PairwiseEncoder",
43
+ "calc_pairwise_coo_indices_nd",
44
+ ]
@@ -505,7 +505,7 @@ def calc_pairwise_coo_indices_nd(
505
505
  return indices
506
506
 
507
507
 
508
- def calc_pariwise_coo_indices(
508
+ def calc_pairwise_coo_indices(
509
509
  radius: float,
510
510
  volume_shape: Tuple[int, int, int, int],
511
511
  diag: bool = False,
@@ -548,13 +548,17 @@ def calc_pariwise_coo_indices(
548
548
  """
549
549
  # Validate 4D shape for backward compatibility
550
550
  if not (len(volume_shape) == 4 and all(isinstance(dim, int) and dim > 0 for dim in volume_shape)):
551
- raise ValueError("volume_shape must be a 4D tuple of positive integers for backward compatibility")
551
+ raise ValueError("`volume_shape` must be a 4D tuple of positive integers, representing [C, H, D, W]")
552
552
 
553
553
  out = calc_pairwise_coo_indices_nd(radius, volume_shape, diag, upper, channel_voxel_relation, dtype, device)
554
554
  # Narrow key type for static checker (all offsets have length 4 here)
555
555
  return {tuple(k): v for k, v in out.items()} # type: ignore[return-value]
556
556
 
557
557
 
558
+ # Keep the typo version for backward compatibility
559
+ calc_pariwise_coo_indices = calc_pairwise_coo_indices # type: ignore[misc]
560
+
561
+
558
562
  class PairwiseEncoder(torch.nn.Module):
559
563
  r"""Encode pairwise spatial–channel neighborhoods as sparse tensors.
560
564
 
@@ -3,15 +3,8 @@ from typing import Tuple
3
3
 
4
4
  import torch
5
5
 
6
- # Deprecation warning for the entire module
7
- warnings.warn(
8
- "The 'pairwise_voxel_encoder' module is deprecated and will be removed in a future version. "
9
- "Please use 'pairwise_encoder' instead, which provides the same functionality with support for arbitrary N-dimensional spatial relationships.",
10
- DeprecationWarning,
11
- stacklevel=2,
12
- )
13
-
14
6
  # Import everything from the new module for backward compatibility
7
+ from .pairwise_encoder import calc_pariwise_coo_indices # typo version for backward compatibility
15
8
  from .pairwise_encoder import (
16
9
  PairwiseEncoder,
17
10
  _gen_coords,
@@ -19,8 +12,8 @@ from .pairwise_encoder import (
19
12
  _gen_offsets,
20
13
  _gen_offsets_nd,
21
14
  _trim_nd,
15
+ calc_pairwise_coo_indices,
22
16
  calc_pairwise_coo_indices_nd,
23
- calc_pariwise_coo_indices,
24
17
  )
25
18
 
26
19
 
@@ -105,7 +98,7 @@ class PairwiseVoxelEncoder(PairwiseEncoder):
105
98
  "PairwiseVoxelEncoder is deprecated and will be removed in a future version. "
106
99
  "Use PairwiseEncoder instead, which supports arbitrary N-dimensional spatial relationships.",
107
100
  DeprecationWarning,
108
- stacklevel=2,
101
+ stacklevel=3,
109
102
  )
110
103
 
111
104
  # Validate input for backward compatibility