GE-SpMM: general-purpose sparse matrix-matrix multiplication on GPUs for graph neural networks

Guyue Huang, Guohao Dai, Yu Wang, Huazhong Yang

Overview

Graph Neural Networks (GNNs) have become a cornerstone of modern machine learning, yet their performance is often bottlenecked by the aggregation step. This step typically involves Sparse Matrix-Matrix Multiplication (SpMM), where a sparse adjacency matrix is multiplied by a dense feature matrix. GE-SpMM is a high-performance GPU kernel designed to address the inefficiencies of current SpMM implementations. By employing Coalesced Row Caching (CRC) and Coarse-grained Warp Merging (CWM), GE-SpMM achieves significant speedups—up to 1.41× over Nvidia’s cuSPARSE and 3.67× in end-to-end GNN frameworks like DGL and PyTorch Geometric.

The Challenge of Sparse Operations in GNNs

The primary computational load in GNNs is the aggregation of features from a node's neighbors. Mathematically, this is expressed as $Y = A \times X$, where $A$ is a sparse adjacency matrix and $X$ is a dense feature matrix.

Figure 1: Illustration of SpMM operation in GNNs, showing the multiplication of a sparse in-edge adjacency matrix with an input feature matrix to produce an output feature matrix.

Despite the theoretical suitability of GPUs for parallel processing, sparse operations face three major hurdles:

  1. Rigidity: Existing libraries like cuSPARSE are limited to standard arithmetic, whereas GNNs often require specialized aggregations like max-pooling.
  2. Preprocessing Overhead: High-performance kernels often require custom graph formats, which is impractical for dynamic or sampled graphs common in GNN training.
  3. Hardware Inefficiency: Many kernels treat SpMM as multiple Sparse Matrix-Vector (SpMV) operations. This approach leads to uncoalesced memory access and redundant data loading, failing to saturate the GPU's global memory bandwidth.

GE-SpMM: Optimized Memory Access and Warp Merging

GE-SpMM operates directly on the standard Compressed Sparse Row (CSR) format, eliminating preprocessing overhead. It introduces two core optimizations to maximize hardware utilization:

Coalesced Row Caching (CRC)

To combat uncoalesced memory access, CRC uses a two-phase loading strategy. A warp (32 threads) cooperatively loads a tile of a sparse row into shared memory. This ensures that memory transactions are coalesced, reading contiguous blocks and significantly improving bandwidth efficiency.

Coarse-grained Warp Merging (CWM)

CWM addresses the issue of redundant data loading. In standard SpMV-based approaches, the same sparse data is loaded multiple times to compute different output features. CWM merges these workloads, allowing a single thread to produce multiple output values, thereby improving Instruction-Level Parallelism (ILP) and reducing global memory traffic.

Figure 5: Comparison of standard memory loading versus the redundant and uncoalesced loading patterns that GE-SpMM aims to optimize.

Experimental Evaluation

The authors evaluated GE-SpMM across standard GNN benchmarks (Cora, Citeseer, Pubmed), the SNAP dataset (64 real-world matrices), and synthetic graphs to test varying feature lengths ($N$).

Key Results

  • Kernel Performance: GE-SpMM outperformed Nvidia’s cuSPARSE by up to 1.41× and GraphBLAST by up to 1.81×.
  • Framework Integration: When integrated into DGL and PyTorch Geometric, it provided up to a 3.67× speedup for GCN and GraphSAGE models.
  • Efficiency Gains: CRC improved memory load efficiency from ~69% to over 92% on synthetic tests.
  • Versatility: Specialized "SpMM-like" operations (e.g., max-pooling) saw speedups of up to 6.15× compared to default framework implementations.

Discussion and Future Directions

While GE-SpMM provides substantial gains, its performance is most effective when the feature vector length ($N$) exceeds 32. For smaller $N$, the overhead of these optimizations may reduce their impact. Additionally, while a coarsening factor ($CF$) of 2 is generally optimal, further tuning based on specific matrix sparsity patterns could yield even higher performance. Future work involves extending this general-purpose approach to more complex GNN operators, further optimizing the entire GNN pipeline.

Summary updated

BibTeX
@inproceedings{huang2020ge,
  author = {Guyue Huang and Guohao Dai and Yu Wang and Huazhong Yang},
  title = {{GE-SpMM: general-purpose sparse matrix-matrix multiplication on GPUs for graph neural networks}},
  booktitle = {SC},
  year = {2020},
  url = {https://openreview.net/forum?id=Yywqi0hpgL},
}
Figure