Abstract
As Graph Neural Networks (GNNs) transition from academic research to large-scale industrial applications, the efficiency of the underlying software frameworks becomes as critical as model accuracy. This paper presents a comprehensive comparative analysis of the two dominant GNN frameworks: Deep Graph Library (DGL) and PyTorch Geometric (PyG). By decomposing the GNN pipeline into its constituent parts—data loading, sampling, and convolutional operations—we identify critical bottlenecks and evaluate the energy consumption of each framework. Our findings reveal that while PyG offers superior user-friendliness and data loading speeds, DGL’s C++ backend provides significant advantages in sampling efficiency and scalability, making it the more energy-efficient choice for massive datasets.
Introduction
Graph Neural Networks have become the standard for processing irregular, sparse data in domains ranging from social network analysis to bioinformatics. To support these models, specialized frameworks like DGL and PyG have emerged, abstracting the complexities of sparse matrix operations and graph traversals. However, these frameworks are often treated as "black boxes" by researchers who focus primarily on predictive performance.
As datasets scale to millions of nodes and billions of edges, system efficiency (runtime) and environmental sustainability (energy consumption) have become paramount. This study aims to provide a granular understanding of the GNN pipeline, identifying where time and energy are spent and how framework-specific architectural choices impact overall performance.
Methodology
The study employs a multi-level "functional testing" approach to isolate performance variables:
- Component-Level Benchmarking: The authors isolated individual stages of the GNN workflow, including data loaders, three distinct graph samplers (Neighborhood, ClusterGCN, and GraphSAINT), and eight standard convolutional (Conv) layers.
- Model-Level Evaluation: End-to-end training scenarios were tested using state-of-the-art sampling-based models, specifically GraphSAGE, ClusterGCN, and GraphSAINT.
- Hardware and Metrics: Experiments were conducted on an NVIDIA Quadro RTX 8000 GPU and Intel Xeon CPUs. Runtime profiling was performed using
pyinstrument, while energy consumption and carbon footprint were quantified usingCodeCarbon. - Optimization Case Studies: The research explored advanced strategies, such as pre-loading graphs into GPU memory and utilizing DGL’s Unified Virtual Addressing (UVA) and specialized GPU-based samplers.
Datasets
The evaluation utilized six real-world datasets of varying scales to observe performance trends as data exceeds cache limits:
- Small/Medium: PPI, Flickr, and ogbn-Arxiv.
- Large-Scale: Reddit (114M edges), Yelp, and ogbn-Products (2.4M nodes, 61M edges).
Key Insights and Framework Architectures
The Sampling Bottleneck
A primary finding of this study is that graph sampling—the process of selecting subgraphs for mini-batch training—is the dominant overhead in GNN pipelines. In many configurations, sampling accounts for up to 90% of the total runtime. This suggests that GNN efficiency is fundamentally a data-handling problem rather than a neural computation problem.
C++ vs. Python Implementations
The performance disparity between the frameworks is largely rooted in their architectural choices. DGL implements its samplers in C++ using OpenMP for parallelization. In contrast, PyG’s samplers are primarily Python-based. This allows DGL to scale significantly better on massive graphs where the overhead of Python's Global Interpreter Lock (GIL) and object management becomes a hindrance.
Energy Efficiency and "Green AI"
The study found a direct correlation between runtime and energy consumption. There is no "magic" framework that consumes less power per unit of time; rather, the framework that completes the task fastest is inherently the most energy-efficient. Consequently, reducing runtime through optimized sampling and data movement is the most effective lever for achieving "Green AI" in the GNN domain.
Data Movement Constraints
The repeated transfer of sampled subgraphs from CPU to GPU memory creates a significant bottleneck. The authors found that pre-loading the entire graph into GPU memory (when hardware constraints allow) can reduce data movement time by up to 20x, highlighting the importance of memory management in GNN system design.
Experimental Results
- Convolutional Acceleration: Executing Conv layers on the GPU yielded up to a 70x speedup over CPU execution. On the CPU specifically, DGL’s Conv layers consistently outperformed PyG due to more optimized message-passing kernels.
- Sampling Performance: DGL’s neighborhood sampler demonstrated superior efficiency, particularly as graph size increased. Furthermore, utilizing DGL’s GPU-based sampling achieved a 5.5x speedup compared to the traditional CPU-sampling/GPU-training (CPUGPU) workflow.
- Full-Batch Training: For scenarios where the entire graph is trained at once (full-batch), DGL-CPU significantly outperformed PyG-CPU across nearly all tested datasets.
- Usability: PyG was found to be more user-friendly, with a faster data loader and better out-of-the-box support for diverse datasets, making it an attractive choice for rapid prototyping on smaller scales.
Conclusion and Future Work
While PyG excels in ease of use and initial data loading, DGL’s graph-centric abstraction and C++ backend provide the necessary performance for large-scale, production-grade GNN workloads. The study underscores that the path to efficient GNNs lies in optimizing data movement and sampling rather than just the neural architecture.
Future research should expand this benchmarking to distributed GNN training across multi-node clusters and investigate the trade-offs between sampling aggressiveness and model accuracy. Additionally, evaluating specialized hardware accelerators beyond standard GPUs could provide further insights into the next generation of GNN efficiency.
Summary updated