Characterizing the Efficiency of Graph Neural Network Frameworks with a Magnifying Glass

Xin Huang, Jongryool Kim, Bradley Rees, Chul-Ho Lee

TL;DR

This paper provides a comprehensive "under the hood" comparison of the two most popular Graph Neural Network (GNN) frameworks: Deep Graph Library (DGL) and PyTorch Geometric (PyG). The authors reveal that while PyG offers superior usability and performance for small graphs, DGL’s C++ backend and optimized kernels make it significantly more efficient and "greener" for large-scale, sampling-based training.

What Problem Does This Paper Address?

Graph Neural Networks have revolutionized learning on non-Euclidean data, but their implementation is tricky. Unlike standard deep learning, graphs are sparse and irregular, making them inefficient on traditional hardware. While frameworks like DGL and PyG were built to solve this, their internal system performance—especially regarding mini-batch sampling for massive graphs—remains poorly understood.

Furthermore, as "Green AI" becomes a priority, the community lacks data on the energy and carbon footprint of these frameworks. This paper fills that gap by benchmarking runtime and power consumption across different graph scales and hardware configurations.

Methods

The authors conducted a multi-level evaluation:

  1. Functional Testing: They isolated key components—data loaders, graph samplers (Neighborhood, ClusterGCN, GraphSAINT), and eight different convolutional layers (e.g., GCN, GAT, SAGE)—to measure their individual overhead.
  2. End-to-End Evaluation: They measured the total runtime and energy consumption of three state-of-the-art sampling-based GNNs (GraphSAGE, ClusterGCN, and GraphSAINT).
  3. Hardware Comparison: Tests were run on both CPU-only and hybrid CPU-GPU setups.
  4. Measurement Tools: They used pyinstrument for fine-grained runtime profiling and CodeCarbon to track energy usage and carbon emissions.
Figure 1: Two training methods for GNNs.

Datasets

The study used six real-world datasets representing a wide range of scales:

  • Small/Medium: PPI (Protein-Protein Interactions), Flickr, and ogbn-Arxiv.
  • Large: Reddit (114M edges), Yelp, and ogbn-Products (2.4M nodes, 61M edges).

These datasets allow the authors to observe how framework efficiency changes as the graph grows from thousands to millions of nodes.

Key Insights and Ideas

  • The Sampling Bottleneck: In mini-batch training, sampling can consume up to 90% of the total runtime. This highlights a massive opportunity for optimization beyond just faster matrix multiplications.
  • C++ vs. Python: DGL implements its samplers in C++ with OpenMP, whereas PyG relies more on Python. This architectural choice makes DGL significantly faster for sampling on large graphs.
  • Usability vs. Performance: PyG is noted for being more user-friendly, with a data loader that integrates more datasets out-of-the-box and handles small graphs more efficiently.
  • Energy follows Time: The authors found no "magic" energy efficiency; energy consumption is almost entirely dictated by runtime. Therefore, the fastest framework is effectively the "greenest" one.
  • GPU Sampling is a Game Changer: DGL’s support for GPU-based sampling and Unified Virtual Addressing (UVA) provides a massive speedup (up to 5.5x) over CPU-based sampling, though it is currently limited to specific models like GraphSAGE.
Figure 2: Workflow of sampling-based GNN training.

Key Results

  • Convolutional Layers: DGL’s optimized kernels outperformed PyG’s in almost all CPU tests. On GPUs, GNN operations showed up to a 70x speedup compared to CPU execution.
  • Sampler Efficiency: As shown in the benchmarking of samplers, DGL consistently outperformed PyG on larger datasets like Reddit and Products. For example, in the ClusterGCN METIS partitioning, DGL was significantly faster.
  • Data Movement: Moving data between CPU and GPU is a major hidden cost. Pre-loading the entire graph into GPU memory (when possible) can lead to a 2x overall speedup.
  • Memory Issues: PyG suffered from Out-of-Memory (OOM) errors on large graphs for certain layers (like GAT and ChebConv) because it lacks the fused kernels that DGL uses to optimize memory usage.
Runtime comparison of graph samplers.

Limitations and Future Work

  • Framework Scope: The study focused exclusively on DGL and PyG, leaving out other emerging frameworks like Spektral or DeepGraph.
  • GPU Sampling Support: At the time of the study, GPU-based sampling was largely a DGL-only feature for specific models. The authors suggest that PyG needs to catch up in this area to remain competitive for large-scale tasks.
  • Hyperparameter Impact: The study kept hyperparameters constant for fair framework comparison, but the authors acknowledge that tuning for accuracy might shift the efficiency balance.
  • Future Direction: The authors urge the development of more asynchronous data movement (like DGL's "pre-fetching") and better caching strategies to mitigate the sampling and data movement bottlenecks.

Summary updated

Abstract

Graph neural networks (GNNs) have received great attention due to their success in various graph-related learning tasks. Several GNN frameworks have then been developed for fast and easy implementation of GNN models. Despite their popularity, they are not well documented, and their implementations and system performance have not been well understood. In particular, unlike the traditional GNNs that are trained based on the entire graph in a full-batch manner, recent GNNs have been developed with different graph sampling techniques for mini-batch training of GNNs on large graphs. While they improve the scalability, their training times still depend on the implementations in the frameworks as sampling and its associated operations can introduce non-negligible overhead and computational cost. In addition, it is unknown how much the frameworks are 'eco-friendly' from a green computing perspective. In this paper, we provide an in-depth study of two mainstream GNN frameworks along with three state-of-the-art GNNs to analyze their performance in terms of runtime and power/energy consumption. We conduct extensive benchmark experiments at several different levels and present detailed analysis results and observations, which could be helpful for further improvement and optimization.
BibTeX
@inproceedings{huang2022characterizing,
  author = {Xin Huang and Jongryool Kim and Bradley Rees and Chul-Ho Lee},
  title = {{Characterizing the Efficiency of Graph Neural Network Frameworks with a Magnifying Glass}},
  booktitle = {IISWC},
  year = {2022},
  url = {https://openreview.net/forum?id=Q5smIJC7bU},
}
Figure