Sparse matrix operations for AWS Trainium via NKI
Project description
trnsparse
Sparse matrix operations for AWS Trainium via NKI.
CSR/COO formats, SpMV, SpMM, and integral screening for sparse scientific computing on Trainium. Part of the trnsci scientific computing suite (github.com/trnsci).
Current phase
trnsparse follows the trnsci 5-phase roadmap. Active work is tracked in phase-labeled GitHub issues:
- Phase 1 — correctness ✅ v0.2.0: NKI SpMM validated on trn1 via densify-then-GEMM; first
torch.autograd.Function-wrapped NKI kernel in the suite (seetrnsci/trnsci#3). Benchmarks indocs/benchmarks.md. - Phase 3 — perf: nnz-bucketing SpMM, streaming large-sparse, NEFF cache reuse.
- Phase 4 — multi-chip: sharded sparse matrices across chips.
- Phase 5 — generation: trn2 DMA bandwidth exploitation.
(No Phase 2 for trnsparse — the precision story is inherited from trnblas.)
Suite-wide tracker: trnsci/trnsci#1.
Install
pip install trnsparse
Usage
import torch
import trnsparse
# Dense → sparse
A = torch.randn(100, 100)
A[torch.abs(A) < 1.0] = 0.0
csr = trnsparse.from_dense(A)
# SpMV: y = A @ x
y = trnsparse.spmv(csr, x, alpha=2.0)
# SpMM: C = A @ B
C = trnsparse.spmm(csr, B)
# Integral screening
Q = trnsparse.schwarz_bounds(diagonal_integrals)
mask = trnsparse.screen_quartets(Q, threshold=1e-10)
stats = trnsparse.sparsity_stats(Q)
Operations
| Operation | Description |
|---|---|
spmv |
Sparse × dense vector |
spmm |
Sparse × dense matrix |
spmv_symmetric |
Symmetric SpMV (half storage) |
sparse_add |
C = αA + βB |
sparse_scale |
B = αA |
sparse_transpose |
A^T |
schwarz_bounds |
Schwarz screening bounds |
screen_quartets |
Shell quartet significance mask |
density_screen |
Density-weighted screening |
License
Apache 2.0 — Copyright 2026 Scott Friedman
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trnsparse-0.4.1.tar.gz.
File metadata
- Download URL: trnsparse-0.4.1.tar.gz
- Upload date:
- Size: 68.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef195029661b7b445e21f03ffcd2c4c6646324821ad3b3df310825b2ecadf05d
|
|
| MD5 |
ceb537041a9a465470b04d1a46cd293d
|
|
| BLAKE2b-256 |
34fe646d57b88b8edee582ec21a63e859e6a51b221e750178b147dabf62e1f22
|
Provenance
The following attestation bundles were made for trnsparse-0.4.1.tar.gz:
Publisher:
publish.yml on trnsci/trnsparse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trnsparse-0.4.1.tar.gz -
Subject digest:
ef195029661b7b445e21f03ffcd2c4c6646324821ad3b3df310825b2ecadf05d - Sigstore transparency entry: 1301697064
- Sigstore integration time:
-
Permalink:
trnsci/trnsparse@3693747995202f90c2ef21b66828c4d85fbf0218 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/trnsci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3693747995202f90c2ef21b66828c4d85fbf0218 -
Trigger Event:
release
-
Statement type:
File details
Details for the file trnsparse-0.4.1-py3-none-any.whl.
File metadata
- Download URL: trnsparse-0.4.1-py3-none-any.whl
- Upload date:
- Size: 26.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c22ccd1a9cb2297c91db6619399ba2186ffbc734f822ab10306d8823f453716d
|
|
| MD5 |
4f13788bf0bdf06d326a8fa151816d24
|
|
| BLAKE2b-256 |
5def80663020ae5b701b912964b77e1c37710801c4c399e5b8fbe8f8ad8d01a3
|
Provenance
The following attestation bundles were made for trnsparse-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on trnsci/trnsparse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trnsparse-0.4.1-py3-none-any.whl -
Subject digest:
c22ccd1a9cb2297c91db6619399ba2186ffbc734f822ab10306d8823f453716d - Sigstore transparency entry: 1301697174
- Sigstore integration time:
-
Permalink:
trnsci/trnsparse@3693747995202f90c2ef21b66828c4d85fbf0218 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/trnsci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3693747995202f90c2ef21b66828c4d85fbf0218 -
Trigger Event:
release
-
Statement type: