GNNSampler: Bridging the Gap Between Sampling Algorithms of GNN and Hardware

Xin Liu, Mingyu Yan, Shuhan Song, Zhengyang Lv, Wenming Li, Guangyu Sun, Xiaochun Ye, Dongrui Fan

TL;DR

GNNSampler is a unified programming model that bridges the gap between Graph Neural Network (GNN) sampling algorithms and hardware execution. By introducing a "locality-aware" optimization that prioritizes sampling nodes with contiguous memory layouts, the authors achieve up to a 44% reduction in training time with minimal impact on accuracy.

What Problem Does This Paper Address?

Graph Neural Networks (GNNs) are powerful but notoriously difficult to scale because real-world graphs (like social networks or recommendation systems) are massive. To handle this, researchers use sampling—selecting a small subset of a node’s neighbors to update its representation rather than processing the entire graph.

However, the authors identify a significant bottleneck: as datasets grow, sampling can consume over 60% of total training time (see Figure 3). The root cause isn't just mathematical complexity; it's a hardware mismatch. Most sampling algorithms result in irregular memory access patterns, forcing the processor to jump around in memory to find neighbor data. This leads to frequent "cache misses," where the CPU has to wait for data to be fetched from the much slower DRAM. Current algorithms are optimized for statistical accuracy but ignore these hardware-level inefficiencies.

![Fig.

  1. The proportion of the execution time in different parts of training across different models and datasets.](/figures/art_70337f6c2b0548c1bcc24817e23d029a)

Methods

The authors propose two main contributions to solve this:

  1. GNNSampler: A unified programming model that abstracts various sampling strategies (node-wise, layer-wise, and subgraph-based) into two stages: INIT (preprocessing and configuration) and EXECUTE (the actual iterative sampling). This allows developers to apply hardware optimizations across different types of GNNs without rewriting the core logic.
  2. Locality-Aware Optimization: This is a specific hardware-centric optimization embedded within GNNSampler. The system identifies "good nodes"—nodes whose neighbors are stored in contiguous memory locations (spatial locality).
  3. Neighbor Generator: It creates a "virtual" ideal neighbor set for a node that would be perfectly contiguous in memory.
  4. Similarity Calculator: It uses a dot product ratio to compare a node's actual neighbor indices to this ideal set.
  5. Biased Sampling: Nodes with high locality are given a higher probability of being sampled. This ensures that when the hardware fetches neighbor data, it can utilize the cache more effectively, reducing slow DRAM accesses.

![Fig.

  1. (a) Workflow of learning large-scale graphs with GNN embedded with GNNSampler. (b) An exemplar for sampling nodes leveraging hardware feature.](/figures/art_f27253c87f26408fa56db8196e3b3782)

Datasets

The researchers evaluated their approach on five diverse benchmark datasets, varying in size and connection density:

  • Pubmed: A citation network.
  • PPI (Protein-Protein Interaction): A biological network.
  • Flickr: An image-based social network.
  • Reddit: A large-scale social media post-to-post network.
  • Amazon: A massive product-to-product network.

Key Insights and Ideas

  • The Hardware-Algorithm Gap: Algorithm designers often treat hardware as a "black box," while hardware designers treat algorithms as fixed. GNNSampler acts as a translation layer that lets the algorithm "know" about the memory layout.
  • NRR (Neighbor Reusing Rate): The authors found that datasets with a high NRR (like Amazon and Reddit) benefit the most from locality optimizations. In these graphs, nodes share many common neighbors, making it easier to find regions with high spatial locality.
  • Topology as a Proxy for Locality: The paper shows that locality-aware sampling naturally selects subgraphs that are more "cliquish" or tightly clustered. This is reflected in higher Clustering Coefficients (CC) and more Closed Triads compared to vanilla random sampling.
  • Once-for-All Preprocessing: The locality metrics only need to be calculated once per dataset during the INIT stage, making the overhead negligible over thousands of training epochs.

Key Results

  • Speedup: The method achieved an average training time reduction of 13.29% across all models. The most dramatic result was on the Amazon dataset using GraphSAINT, which saw a 44.64% speedup.
  • Accuracy: The speed gains came at a small cost, with an average accuracy loss of only 2.74%. The authors demonstrate that this is a tunable trade-off: by adjusting the similarity threshold ($s$), users can choose between maximum speed or maximum accuracy.
  • Hardware Metrics: Using Intel PCM tools, the authors confirmed that their method significantly reduced data access from L3 cache to DRAM (L3-DRAM), proving that the speedup was indeed due to better memory locality.

Limitations and Future Work

The primary limitation is the accuracy-efficiency trade-off. Because the sampler is biased toward nodes with better memory locality, it may ignore statistically important nodes that happen to have "messy" neighbor layouts in memory.

Future work could involve exploring other hardware features beyond spatial locality, such as optimizing for specific GPU architectures or leveraging hardware prefetchers more aggressively. The authors also suggest that their unified model could be extended to support even more diverse GNN architectures beyond the standard GCN variants tested here.

Summary updated

BibTeX
@inproceedings{liu2022gnnsampler,
  author = {Xin Liu and Mingyu Yan and Shuhan Song and Zhengyang Lv and Wenming Li and Guangyu Sun and Xiaochun Ye and Dongrui Fan},
  title = {{GNNSampler: Bridging the Gap Between Sampling Algorithms of GNN and Hardware}},
  booktitle = {ECML/PKDD},
  year = {2022},
  doi = {10.1007/978-3-031-26419-1\_30},
}
Figure