trnsparse 0.4.2 — block-sparse attention primitive
What's new
examples/block_sparse_attention.py— block-sparse attention reference usingBSRMatrix+bsr_spmm. Three mask patterns (local window, dilated, global tokens); verifies against a dense reference; reports block density and timing for thebsr_spmmstep. Closes #21.docs/sparse_attention.md— writeup: how BSR-128 maps to Longformer/BigBird-style attention masks, block density arithmetic, pattern construction helpers, and the fused-tile follow-up (#25).tests/test_attention.py— 8 CPU tests: mask shape/symmetry checks + parity against dense reference atatol=1e-4for all three patterns and the full-attention edge case.mkdocs.yml: add Iterative Solvers (was missing from nav) and Sparse Attention.
Notes
No API changes, no kernel changes. The claim in #21: bsr_spmm is the block-sparse attention primitive; BSRMatrix captures the mask.
The 128-token granularity at which sparse attention is natural is the Tensor Engine tile — Trainium was built for attention; that design transfers to any block-128-structured sparse workload.
Install
pip install trnsparse==0.4.2Full changelog: CHANGELOG.md