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:
- 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.
- 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).
- Hardware Comparison: Tests were run on both CPU-only and hybrid CPU-GPU setups.
- Measurement Tools: They used
pyinstrumentfor fine-grained runtime profiling andCodeCarbonto track energy usage and carbon emissions.
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.
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.
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