SpanGNN: Towards Memory-Efficient Graph Neural Networks via Spanning Subgraph Training

Xizhi Gu, Hongzheng Li, Shihong Gao, Xinyan Zhang, Lei Chen, Yingxia Shao

Abstract

Graph Neural Networks (GNNs) are the state-of-the-art for learning on graph-structured data, yet they face a significant "memory wall" when scaling to large datasets. Traditional full-graph training often leads to Out-of-Memory (OOM) errors, while existing sampling methods like mini-batching or DropEdge often sacrifice accuracy or ignore graph structure. This paper introduces SpanGNN, a training framework that utilizes a sequence of evolving spanning subgraphs to reduce memory consumption. By employing quality-aware edge selection and curriculum learning principles, SpanGNN reduces GPU memory usage by over 40% while maintaining or exceeding the accuracy of full-graph training.

1. Introduction

The message-passing paradigm is central to Graph Neural Networks (GNNs), where node representations are updated by aggregating information from neighboring nodes. While effective, this process creates a massive computational bottleneck. In full-graph training, storing intermediate edge calculations can require up to 100 times more memory than the raw dataset itself. As graphs grow to millions of nodes and billions of edges, researchers are forced to choose between memory-intensive full-graph methods and variance-prone mini-batching techniques.

SpanGNN addresses this challenge by shifting the focus from the entire graph to a series of "spanning subgraphs"—subgraphs that include all nodes but only a fraction of the edges. This approach allows for significant memory savings without losing the global structural context necessary for high-performance learning.

2. The SpanGNN Framework

2.1 Incremental Spanning Subgraph Training

SpanGNN adopts a "simple-to-complex" strategy inspired by curriculum learning. Training begins on a sparse graph structure and progressively adds edges over time. This allows the model to master basic structural features before attempting to learn from the full complexity of the dense graph. This incremental approach not only saves memory but also acts as a regularizer, often preventing early-stage overfitting.

2.2 Quality-Aware Edge Selection

To ensure that the subgraphs retain the most informative edges, SpanGNN moves beyond random sampling (like DropEdge) and utilizes two sophisticated mathematical strategies:

  1. Variance-Reduced Sampling: This strategy prioritizes edges connecting low-degree nodes. These "lonely" nodes often provide more unique information per edge compared to nodes in dense clusters, effectively reducing the variance in node embeddings.
  2. Gradient-Noise Reduced Sampling: This method selects edges that minimize the discrepancy between the subgraph's gradient and the true full-graph gradient, ensuring stable and reliable convergence during the optimization process.

2.3 Computational Efficiency: Two-Step Sampling

To prevent the edge selection process from becoming a bottleneck itself, the authors implemented a "random-then-weighted" two-step sampling approach. The algorithm first takes a large random sample of edges and then applies the quality-aware selection criteria to this reduced subset. This engineering optimization avoids the high cost of building complex data structures for the entire graph, making the overhead of smart sampling negligible.

3. Experimental Evaluation

The researchers evaluated SpanGNN against several baselines, including full-graph training, DropEdge, and popular mini-batch methods like GraphSAINT and ClusterGCN. Testing was conducted on four large-scale benchmarks:

  • Ogbn-proteins: A biological network for protein function prediction.
  • Reddit: A social network post-to-post link dataset.
  • Amazon: A product co-purchasing network.
  • Ogbn-products: A massive product-link dataset containing ~2.4 million nodes.

4. Key Results

4.1 Memory and Speed

SpanGNN demonstrated substantial efficiency gains across all datasets. By utilizing only 30% of the edges, the framework reduced peak GPU memory usage by 42% on Reddit, 25% on Ogbn-products, and 47% on Ogbn-proteins. Furthermore, the two-step sampling method proved to be 1.95x to 5.65x faster at generating subgraphs compared to standard DropEdge implementations.

4.2 Accuracy and Robustness

Despite the reduced edge count, SpanGNN-F (the variance-reduced variant) achieved accuracy nearly identical to full-graph training. Notably, on the Reddit dataset using the GraphSAGE architecture, SpanGNN actually outperformed full-graph training. It consistently surpassed DropEdge, which typically suffers from significant accuracy degradation as the edge drop rate increases.

5. Discussion and Limitations

One observed limitation occurred with the Amazon dataset, where a highly skewed sampling probability led the model to repeatedly select a small minority of high-quality edges. This prevented the spanning subgraph from reaching the target edge ratio efficiently. Future research may focus on refining sampling strategies for such skewed distributions or extending the spanning subgraph concept to heterogeneous and dynamic graph types.

6. Conclusion

SpanGNN provides a robust solution to the GNN memory wall. By combining the principles of curriculum learning with quality-aware edge sampling, it allows for the training of high-performance models on large-scale graphs with significantly reduced hardware requirements. This framework proves that not all edges are equal, and a well-chosen subset can be just as effective—if not more so—than the whole.

Summary updated

BibTeX
@inproceedings{gu2024spangnn,
  author = {Xizhi Gu and Hongzheng Li and Shihong Gao and Xinyan Zhang and Lei Chen and Yingxia Shao},
  title = {{SpanGNN: Towards Memory-Efficient Graph Neural Networks via Spanning Subgraph Training}},
  booktitle = {ECML/PKDD},
  year = {2024},
  url = {https://openreview.net/forum?id=3D39VD5EZ5},
}
Figure