Abstract
General-purpose Sparse Matrix-Matrix Multiplication (SpMM) is a fundamental kernel in scientific computing and deep learning. The emergence of new matrix computation units such as Tensor Cores (TCs) brings more opportunities for SpMM acceleration. However, in order to fully unleash the power of hardware performance, systematic optimization is required. In this paper, we propose Acc-SpMM, a high-performance SpMM library on TCs, with multiple optimizations, including data-affinity-based reordering, memory efficient compressed format, high-throughput pipeline, and adaptive sparsity-aware load balancing. In contrast to the state-of-the-art SpMM kernels on various NVIDIA GPU architectures with a diverse range of benchmark matrices, Acc-SpMM achieves significant performance improvements, on average 2.52x (up to 5.11x) speedup on RTX 4090, on average 1.91x (up to 4.68x) speedup on A800, and on average 1.58x (up to 3.60x) speedup on H100 over cuSPARSE.
Introduction
Sparse Matrix-Matrix Multiplication (SpMM) is the backbone of modern Graph Neural Networks (GNNs) and large-scale scientific simulations. However, SpMM is notoriously difficult to optimize. Unlike dense math, sparse data is irregular, leading to "memory-bound" performance where the processor spends more time waiting for data than actually calculating.
NVIDIA’s Tensor Cores (TCs) were designed to solve this for dense AI workloads, but they are a poor natural fit for sparse data. TCs expect neat, dense blocks of numbers; sparse matrices are full of "holes" (zeros). Previous attempts to use TCs for SpMM often suffered from low density in blocks, pipeline bubbles due to irregular memory fetches, and load imbalance across GPU cores.
Methodology
Acc-SpMM introduces four systematic optimizations to bridge the gap between sparse data and dense hardware.
1. Data-Affinity-Based Reordering
Instead of processing the matrix as-is, Acc-SpMM treats the sparse matrix as a graph. It employs a modularity-based algorithm to identify "communities" of data—rows and columns that frequently interact. By reordering the matrix based on these communities, non-zero elements are "clumped" together, creating denser blocks that Tensor Cores can process more efficiently. This strategy has been shown to increase L1 cache hit rates by up to 17.56%.
2. BitTCF Compressed Format
Standard sparse formats like CSR have high metadata overhead. Acc-SpMM introduces BitTCF, which uses a uint64 bitmask to represent 8x8 tiles. Each bit indicates whether a value is zero or non-zero. This format is extremely memory-efficient and allows for fast decompression using hardware-accelerated bitwise operations.
3. High-Throughput Pipeline
To eliminate idle time ("bubbles"), the library uses a double-buffering strategy. While Tensor Cores calculate one tile, the system prefetches the next tile of the dense matrix into registers and shared memory using asynchronous copy instructions (cp.async), overlapping computation and memory access.
4. Adaptive Sparsity-Aware Load Balancing
Acc-SpMM utilizes a performance model that predicts task duration based on sparsity. It then dynamically redistributes work across GPU Thread Blocks to ensure no single core becomes a bottleneck, addressing the inherent load imbalance in sparse workloads.
Experimental Evaluation
The researchers evaluated Acc-SpMM using 10 representative real-world matrices (e.g., Yeast, Reddit, Amazon) and 414 diverse matrices from the SuiteSparse collection. Testing spanned three generations of NVIDIA GPUs: RTX 4090 (Ada Lovelace), A800 (Ampere), and H100 (Hopper).
Performance Results
Acc-SpMM consistently outperformed the industry-standard cuSPARSE and other state-of-the-art research kernels:
- RTX 4090: Average 2.52x speedup (up to 5.11x).
- A800: Average 1.91x speedup (up to 4.68x).
- H100: Average 1.58x speedup (up to 3.60x).
Discussion and Future Work
A key insight of this work is the application of graph theory (community detection) to hardware optimization, naturally increasing the density of blocks sent to Tensor Cores. Furthermore, the move from pointer-heavy formats to bitmasks significantly reduces the "metadata tax."
Current limitations include the use of one-sided reordering (only matrix A). Future work aims to implement two-sided reordering and integrate Acc-SpMM into the Deep Graph Library (DGL) to support the broader AI research community. While preprocessing overhead for reordering exists, it is typically amortized over many training epochs in deep learning contexts.
Summary updated