GRAPES: Learning to Sample Graphs for Scalable Graph Neural Networks

Taraneh Younesian, Daniel Daza, Emile van Krieken, Thiviyan Thanapalasingam, Peter Bloem

Abstract

Graph neural networks (GNNs) learn to represent nodes by aggregating information from their neighbors. As GNNs increase in depth, their receptive field grows exponentially, leading to high memory costs. Several works in the literature proposed to address this shortcoming by sampling subgraphs, or by using historical embeddings. These methods have mostly focused on benchmarks of single-label node classification on homophilous graphs, where neighboring nodes often share the same label. However, most of these methods rely on static heuristics that may not generalize across different graphs or tasks. We argue that the sampling method should be adaptive, adjusting to the complex structural properties of each graph. To this end, we introduce GRAPES, an adaptive sampling method that learns to identify the set of nodes crucial for training a GNN. GRAPES trains a second GNN to predict node sampling probabilities by optimizing the downstream task objective. We evaluate GRAPES on various node classification benchmarks involving homophilous as well as heterophilous graphs. We demonstrate GRAPES’ effectiveness in accuracy and scalability, particularly in multi-label heterophilous graphs. Additionally, GRAPES uses orders of magnitude less GPU memory than a strong baseline based on historical embeddings. Unlike other sampling methods, GRAPES maintains high accuracy even with smaller sample sizes and, therefore, can scale to massive graphs.

Introduction: The Neighbor Explosion Problem

Graph Neural Networks (GNNs) face a fundamental scalability hurdle known as the "neighbor explosion" problem. To compute a representation for a single node, a GNN aggregates information from its neighbors. As the network depth increases, the number of nodes involved in the computation grows exponentially. While researchers typically address this by sampling a small subset of neighbors, most current methods rely on static heuristics—such as selecting nodes with the highest degrees.

However, these "dumb" heuristics often fail on complex graphs, particularly heterophilous ones (where neighbors often have different labels) or in multi-label tasks. In these scenarios, a high-degree neighbor might simply be "noise" that degrades model performance. The core challenge is building a sampler that adapts its strategy based on the specific graph structure and the task at hand.

Methods: Adaptive Sampling with GRAPES

The authors introduce GRAPES (Graph Adaptive Sampling), a layer-wise adaptive sampling method. The architecture consists of two GNNs working in tandem:

  1. The Classifier ($GCN_C$): The primary model performing the actual task (e.g., node classification).
  2. The Sampler ($GCN_S$): A "scout" model that analyzes a node's neighborhood and predicts the probability that each neighbor is "useful."
The GRAPES framework: A sampler GNN learns to select nodes for a classifier GNN, optimized by task performance.

To optimize this system, GRAPES employs several key techniques:

  • Gumbel-Top-k Trick: This allows the model to sample exactly $k$ nodes while maintaining a (mostly) differentiable process.
  • Training via Feedback: Because sampling is a discrete step, standard backpropagation is insufficient. The authors compare REINFORCE (a standard Reinforcement Learning algorithm) and GFlowNets (Generative Flow Networks). GFlowNets proved particularly effective as they learn to sample diverse sets of high-quality neighbors, aiding exploration.

Key Insights: Why Adaptivity Matters

The primary advantage of GRAPES is its ability to handle "messy" graphs. In simple homophilous graphs where neighbors are similar, random sampling is often sufficient. However, in heterophilous or multi-label environments, GRAPES learns to ignore "distractor" neighbors that do not contribute to the classification task.

Comparison of node neighborhoods in (a) homophilous single-label and (b) heterophilous multi-label graphs.

Beyond accuracy, GRAPES offers significant memory efficiency. While some scaling methods use "historical embeddings" to save time, these methods consume massive amounts of GPU memory. GRAPES achieves comparable or superior accuracy while using up to an order of magnitude less memory by processing only a small, intelligently selected subset of the graph. Furthermore, GRAPES maintains performance even with drastically reduced sample sizes, suggesting that only a small fraction of neighbors are truly critical for correct classification.

Results and Scalability

The study evaluated GRAPES across 12 datasets, including large-scale multi-label heterophilous graphs like Yelp and ogbn-proteins. Key findings include:

  • State-of-the-Art Performance: The GFlowNet-based version of GRAPES achieved the highest F1-scores on most heterophilous and multi-label datasets.
  • Massive Scalability: On the ogbn-products dataset, GRAPES maintained high accuracy with a fraction of the memory footprint required by non-sampling baselines.
  • Efficiency: Compared to GAS (a strong non-sampling baseline), GRAPES used significantly less GPU memory, making it viable for researchers without enterprise-grade hardware.

Conclusion

GRAPES demonstrates that learning which nodes to sample is as important as the classification task itself. By making the sampling process adaptive and task-aware, GRAPES overcomes the neighbor explosion problem while maintaining high accuracy and low memory overhead. Future work may extend this adaptive sampling policy to other tasks like link prediction or unsupervised learning, and explore its application to modern architectures like Graph Transformers.

Summary updated

BibTeX
@article{younesian2025grapes,
  author = {Taraneh Younesian and Daniel Daza and Emile van Krieken and Thiviyan Thanapalasingam and Peter Bloem},
  title = {{GRAPES: Learning to Sample Graphs for Scalable Graph Neural Networks}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=QI0l842vSq},
}
Figure