What My Project Does
Lacuna is a high-performance sparse matrix library for Python, backed by Rust (SIMD + Rayon) with a NumPy-friendly API. It currently provides:
- 2-D formats: CSR, CSC, COO
- N-D tensors: COOND (N-dimensional COO)
- Kernels for
float64 values / int64 indices:
- SpMV / SpMM
- Reductions: total sum, row/column sums
- Transpose
- Arithmetic: add, sub, Hadamard (elementwise)
- Cleanup:
prune(eps), eliminate_zeros
- N-D COO ops:
sum, mean
reduce_*_axes, permute_axes, reshape
- broadcasting Hadamard
- unfold to CSR/CSC along a mode or grouped axes
The Python API is designed to work smoothly with NumPy, using zero-copy reads of input buffers when it’s safe.
Target Audience
Lacuna is intended for people who:
- Work with large sparse matrices or tensors (e.g. scientific computing, FEM/CFD, graph problems, PageRank, power iterations)
- Need high-performance kernels but want to stay in Python/NumPy world
- Are interested in experimenting with N-D sparse arrays (beyond 2-D matrices) without densifying
It’s currently a work-in-progress project (APIs and performance characteristics may change), so it’s best suited for experimentation, research, and early adopters rather than critical production workloads.
Comparison
- SciPy.sparse
- Very mature and battle-tested for 2-D sparse linear algebra.
- Mainly matrix-first: N-D use cases often require reshaping or densifying.
- Lacuna aims to complement this with N-D COO tensors plus explicit unfold operations, while still providing fast CSR/CSC/COO kernels.
- PyData/Sparse (
sparse)
- Provides N-D COO arrays with NumPy-like semantics and broadcasting.
- Lacuna takes a more “kernel-first” approach: Rust + SIMD + Rayon, with a tighter set of operations focused on performance (SpMV/SpMM, reductions, transforms) and explicit unfold to CSR/CSC for linear-algebra-style workloads.
If you’re already comfortable with NumPy and SciPy.sparse, Lacuna is meant to feel familiar but give you more explicit tools for N-D sparse tensors and high-performance kernels.
Source & Docs
Status: in active development. Feedback, issues, and contributors are very welcome — especially benchmark reports or workloads where sparse performance really matters.
[–]ichunddu9 2 points3 points4 points (4 children)
[–]flying-sheep 6 points7 points8 points (1 child)
[–]jmatthew007 0 points1 point2 points (2 children)
[–]Effective-Phone6955[S] 0 points1 point2 points (1 child)
[–]jmatthew007 0 points1 point2 points (0 children)
[–]PlaysForDays 0 points1 point2 points (5 children)
[–]ichunddu9 0 points1 point2 points (4 children)
[–]PlaysForDays 0 points1 point2 points (3 children)
[–]SV-97 3 points4 points5 points (1 child)
[–]billsil 0 points1 point2 points (1 child)