TL;DR
SMaT (Sparse Matrix Matrix Tensor Core-accelerated) is a novel library that finally unlocks the power of GPU Tensor Cores for unstructured sparse matrix multiplication (SpMM). By combining intelligent row reordering with low-level hardware optimizations, SMaT achieves up to a 125x speedup over NVIDIA’s cuSPARSE and consistently outperforms other state-of-the-art sparse libraries.
Introduction: The Challenge of Unstructured Sparsity
In high-performance computing, dense matrix multiplication is highly optimized through specialized hardware like NVIDIA’s Tensor Cores (TCs). However, many real-world applications—including Graph Neural Networks (GNNs) and scientific simulations—rely on sparse matrices, where most elements are zero.
The primary challenge is that Tensor Cores require data to be arranged in strict, dense blocks. Unstructured sparsity, common in many datasets, does not naturally fit this requirement. Standard sparse libraries often bypass Tensor Cores or use them inefficiently by "padding" sparse data with zeros to create dense blocks, which wastes both memory and compute cycles. SMaT bridges this gap, providing a general-purpose library that makes Tensor Cores viable for irregular, highly sparse workloads.
The SMaT Pipeline
The SMaT framework consists of two main phases: a one-time preprocessing step and a highly optimized execution kernel.
1. Preprocessing and Matrix Reordering
To minimize padding overhead, SMaT employs a row permutation scheme based on Jaccard similarity. By reordering rows to cluster non-zero elements, the library reduces the total number of dense blocks required to represent the sparse matrix.
2. Data Structure
Matrices are stored in a Blocked Compressed Sparse Row (BCSR) format. Block sizes (e.g., 16x8 for FP16) are specifically selected to match the native input requirements of Tensor Core MMA (matrix-matrix-accumulate) instructions.
3. Hardware-Aware Kernel
The execution engine uses low-level CUDA MMA APIs and incorporates several sophisticated optimizations:
- 2D "Bottom-Up" Parallelism: Efficiently maps matrix tiles to GPU warps.
- Asynchronous Data Loads: Utilizes
memcpy_asyncto move data from global memory to shared memory while Tensor Cores are active, hiding memory latency. - Double Buffering: Ensures compute units are continuously supplied with data.
Experimental Evaluation
The authors evaluated SMaT on an NVIDIA A100 GPU using two primary sources:
- SuiteSparse Matrix Collection: Nine representative real-world matrices from domains like quantum chemistry and fluid dynamics, ranging from 766K to 10.4M non-zero elements.
- Synthetic Band Matrices: Custom matrices used to stress-test performance across a spectrum of sparsity levels (from 99.7% to 0%).
Key Insights
Hardware Optimization vs. Algorithms
A critical finding is the relative impact of different optimization layers. While row reordering is beneficial, low-level hardware communication is paramount. As shown in the performance breakdown, using the Tensor Core API alone provides a significant boost, but the full suite of optimizations (including asynchronous loads and cooperative shared memory) yields a 22x improvement over a naive implementation.
Challenging "Dense Supremacy"
Conventional wisdom suggests treating matrices with less than ~99% sparsity as dense (using libraries like cuBLAS). SMaT challenges this by outperforming cuBLAS at sparsity levels as low as 78%.
Load Balancing through Permutation
While reordering adds a one-time cost, it significantly improves load balancing. For specific matrices like mip1, reordering reduced the standard deviation of blocks per row by 8.4x, preventing "straggler" warps from bottlenecking the computation.
Results and Conclusion
SMaT was benchmarked against cuSPARSE, DASP, and Magicube.
- Real-World Performance: On SuiteSparse matrices, SMaT was on average 2.6x faster than the second-best library (DASP) and up to 125x faster than cuSPARSE.
- Synthetic Benchmarks: In controlled tests, SMaT reached up to 2,445x the performance of cuSPARSE for specific configurations.
Limitations
The primary limitation is the preprocessing overhead of row reordering. While acceptable for static matrices, it may be a bottleneck for dynamic workloads. Additionally, extreme power-law distributions can still lead to load imbalances that static 2D scheduling may not fully resolve. Future work will explore dynamic scheduling and support for non-NVIDIA architectures.
Summary updated