finds.dev

rusty1s/pytorch_sparse

PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations

View on GitHub

★ 1,106PythonMITupdated Jun 2026

// the take

A small PyTorch C++/CUDA extension providing optimized sparse matrix primitives (coalesce, transpose, sparse-dense and sparse-sparse matmul) with autograd support on values. It's the sparse-algebra backbone of the PyTorch Geometric ecosystem, aimed at people building GNNs or anything else that needs fast sparse ops PyTorch's own sparse tensor API doesn't cover well.

Real CPU and CUDA kernels rather than Python fallbacks, so spmm/spspmm are meaningfully faster than naive torch.sparse_coo_tensor ops. It's a load-bearing dependency of PyG with years of production use, decent test/lint CI, and even exposes a C++ API for people embedding it outside Python. The index/value calling convention sidesteps a lot of torch.sparse_coo_tensor's historical awkwardness.

Installation is the real cost: there's no clean 'pip install' story, you're matching a precise PyTorch+CUDA version to a wheel from a lookup table, and building from source means wrangling CUDA toolchains plus an optional METIS dependency with manual header edits. GPU wheels only exist for Linux/Windows; macOS is CPU-only, so no Apple Silicon GPU support. Indices are non-differentiable by design, meaning sparsity patterns are fixed during training — fine for static graphs, limiting for anything with learned or dynamic sparsity. It's tightly coupled to PyTorch Geometric's release cadence rather than evolving independently, and as PyTorch's native sparse tensor support keeps improving, this package is increasingly a compatibility/performance patch rather than a unique capability.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
1,106
Forks
162
Language
Python
License
MIT
Last commit
3 Jun 2026

// nearby

If pytorch_sparse isn't quite it.

All repos →