Abstract
Graph neural networks (GNNs) can extract meaningful representations from highly expressive graph-structured data. However, current GNNs suffer from poor performance of their sparse-dense matrix multiplication (SpMM) operator. Analysis shows that up to 95% of inference time can be spent on SpMM. To address this, we introduce ES-SpMM, a cache-first edge sampling mechanism and codesigned SpMM kernel. ES-SpMM uses edge sampling to downsize the graph to fit into GPU shared memory, improving cache locality and reducing computation. Integrated with DGL, ES-SpMM outperforms cuSPARSE by up to 4.35x with no accuracy loss and 45.3x with <1% loss.
Introduction: The SpMM Bottleneck
Graph Neural Networks (GNNs) have become essential for processing complex relational data. Despite their success, their execution on modern hardware like GPUs is often inefficient. The primary performance bottleneck is the Sparse-Dense Matrix Multiplication (SpMM) operation, which is used for feature aggregation.
As shown in Figure 5, SpMM can account for the vast majority of inference time—up to 95% in some cases. This inefficiency stems from the irregular memory access patterns inherent in sparse graphs, which conflict with the dense, regular data processing for which GPUs are optimized. While edge sampling (removing edges) can reduce the workload, traditional CPU-based sampling introduces overhead that often exceeds the computational savings.
Methodology: ES-SpMM
The proposed solution, ES-SpMM, integrates edge sampling directly into the GPU SpMM kernel. This "cache-first" design eliminates CPU-to-GPU transfer overhead and leverages GPU parallelism.
In-Kernel Sampling and Cache Optimization
Instead of preprocessing, GPU threads sample edges as they load data. The algorithm targets a specific width ($S$) based on the GPU's shared memory (L1 cache) capacity. By ensuring the sampled neighborhood of a node fits entirely within this high-speed memory, ES-SpMM drastically reduces expensive global memory fetches.
Two sampling strategies are employed:
- Bucket Sampling: A fast method that takes the first $S$ edges.
- FastRand Sampling: Uses a lightweight hash function for pseudo-random sampling, better preserving graph structure for minimal cost.
Results and Robustness
A key insight of this work is that pre-trained GNNs are remarkably resilient to missing edges during inference. This robustness allows for aggressive sampling to optimize hardware utilization.
As illustrated in Figure 6, datasets like Proteins and Reddit maintain near-baseline accuracy even when 80% of edges are dropped. This allows ES-SpMM to transform a memory-bound problem into a compute-bound one by forcing data into the cache.
Performance Comparison
Evaluated on an NVIDIA V100 GPU against industry standards like cuSPARSE:
- Reddit: Achieved a 45.3x speedup with less than 1% accuracy loss.
- Pubmed: Outperformed cuSPARSE by 4.35x with zero accuracy loss.
- Efficiency: On large graphs, ES-SpMM reduced SpMM time to just 5-20% of the original, effectively resolving the primary GNN bottleneck.
Conclusion
ES-SpMM demonstrates that hardware-aware edge sampling can significantly accelerate GNN inference. By treating sampling as a memory management strategy rather than just a statistical tool, the kernel achieves massive speedups with minimal impact on model performance. Future work includes integrating dynamic normalization into the kernel and exploring applications in GNN training.
Summary updated