Skip to main content

Sparse matrix operations for AWS Trainium via NKI

Project description

trnsparse

CI codecov Ruff PyPI Python License Docs

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:

(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

Disclaimer

trnsci is an independent open-source project. It is not sponsored by, endorsed by, or affiliated with Amazon.com, Inc., Amazon Web Services, Inc., or Annapurna Labs Ltd.

"AWS", "Amazon", "Trainium", "Inferentia", "NeuronCore", "Neuron SDK", and related identifiers are trademarks of their respective owners and are used here solely for descriptive and interoperability purposes. Use does not imply endorsement, partnership, or any other relationship.

All work, opinions, analyses, benchmark results, architectural commentary, and editorial judgments in this repository and on trnsci.dev are those of the project's contributors. They do not represent the views, positions, or commitments of Amazon, AWS, or Annapurna Labs.

Feedback directed at the Neuron SDK or Trainium hardware is good-faith ecosystem commentary from independent users. It is not privileged information, is not pre-reviewed by AWS, and should not be read as authoritative about product roadmap, behavior, or quality.

For official AWS guidance, see aws-neuron documentation and the AWS Trainium product page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trnsparse-0.4.2.tar.gz (75.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trnsparse-0.4.2-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file trnsparse-0.4.2.tar.gz.

File metadata

  • Download URL: trnsparse-0.4.2.tar.gz
  • Upload date:
  • Size: 75.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trnsparse-0.4.2.tar.gz
Algorithm Hash digest
SHA256 11c8d14b64c6d09d1259731f9123525e5897cd68157594a7d3d9966db2bc50f5
MD5 53bb979d50d7b86e6f819c998ee9e21b
BLAKE2b-256 28c1b2a33da361a99ebc83ca065144b1746c4f213b3632bb7d386fa966d7d2d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for trnsparse-0.4.2.tar.gz:

Publisher: publish.yml on trnsci/trnsparse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trnsparse-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: trnsparse-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trnsparse-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 afb0cb30b562d6f54c938a9d3bdaff2e4b77d05c102510e724673620450f0668
MD5 5cf95596a7b3f570e7988e86b7e3ffa9
BLAKE2b-256 8a9d5ead291d6d0bc336b3fcdbfac072dbe59429a8fd77d7ffa7a16d4632aae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for trnsparse-0.4.2-py3-none-any.whl:

Publisher: publish.yml on trnsci/trnsparse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page