CogDL: A Comprehensive Library for Graph Deep Learning

Yukuo Cen, Zhenyu Hou, Yan Wang, Qibin Chen, Yizhen Luo, Zhongming Yu, Hengrui Zhang, Xingcheng Yao, Aohan Zeng, Shiguang Guo, Yuxiao Dong, Yang Yang 0009, Peng Zhang, Guohao Dai, Yu Wang, Chang Zhou, Hongxia Yang, Jie Tang

TL;DR

CogDL is a comprehensive, high-performance library designed to unify the messy landscape of Graph Deep Learning (GDL). By providing a modular "Unified Trainer" and highly optimized sparse GPU kernels, it enables researchers to run standardized experiments across 70+ models and 10 different graph tasks with up to 2x the efficiency of existing frameworks like PyG and DGL.

What Problem Does This Paper Address?

Despite the explosion of interest in Graph Neural Networks (GNNs), the field faces three major hurdles:

  1. Inconsistent Evaluation: Researchers often use different data splits or evaluation metrics for the same dataset (e.g., the famous Cora dataset), making fair comparisons nearly impossible.
  2. Efficiency Gaps: Graph data is inherently sparse and non-Euclidean, which standard deep learning frameworks (built for dense tensors like images) struggle to process efficiently on GPUs.
  3. High Engineering Overhead: Building a robust GNN training pipeline—handling everything from neighbor sampling to hyperparameter optimization—is repetitive and error-prone.

CogDL addresses these by providing a standardized, "one-line" experiment API and a backend tailored specifically for the unique computational demands of graphs.

Methods

The authors introduce two primary innovations:

1. The Unified Trainer

CogDL moves away from monolithic scripts toward a decoupled architecture consisting of four modules:

  • Model: The GNN architecture itself.
  • Dataset: Data loading and preprocessing.
  • ModelWrapper: Defines the training/testing logic (e.g., supervised vs. self-supervised).
  • DataWrapper: Handles how data is fed to the model (e.g., full-graph vs. neighbor sampling).

This design allows users to mix and match components—for instance, applying a self-supervised training objective to a new GNN architecture on a massive dataset—without rewriting the core training loop.

2. Optimized Sparse Operators

Standard libraries often rely on generic sparse matrix multiplication (SpMM). CogDL introduces a data-aware balancer for its custom GSpMM (General SpMM) kernels. It automatically detects the graph's degree distribution:

  • For balanced graphs, it uses a row-split algorithm.
  • For power-law graphs (where a few nodes have many edges), it uses a neighbor-group algorithm to prevent workload imbalance.

Additionally, they implemented a GPU-based fused Edge-wise Softmax kernel, which is a critical bottleneck in models like Graph Attention Networks (GAT).

Datasets

CogDL integrates over 70 datasets across 10 tasks, including:

  • Node Classification: Cora, Citeseer, Pubmed, Reddit, Yelp, Flickr, and OGB benchmarks (ogbn-arxiv, ogbn-products).
  • Graph Classification: MUTAG, PROTEINS, IMDB-B, COLLAB.
  • Knowledge Graph Completion: FB15k, WN18.
  • Network Embedding: Wikipedia, Blogcatalog, DBLP.

The library serves as a living leaderboard, maintaining reproducible results for these datasets using standardized settings.

Table 1: All supported tasks, datasets, and models in CogDL.

Key Insights and Ideas

  • Efficiency through Specialization: By writing custom CUDA kernels for multi-head SpMM and Edge-wise Softmax, CogDL avoids the memory overhead of "broadcasting" operations used by other libraries.
  • Memory-Saving Techniques: The library natively supports Activation Compression Training (ACT), which compresses intermediate layer outputs to 2-4 bits. This allows training much deeper or wider GNNs on consumer-grade hardware.
  • Reproducibility as a Feature: The "one-line" experiment API (experiment(dataset="cora", model="gcn")) isn't just for convenience; it ensures that the exact same preprocessing and evaluation logic is applied every time, eliminating "hidden" performance gains from custom data splits.

Key Results

  • End-to-End Speedups: CogDL achieves up to 2x speedup in inference time for standard GCN models compared to PyG and DGL. For GAT models, it achieves between 1.32x and 2.36x speedup.
  • Kernel Performance: The custom GSpMM kernels show dramatic improvements, particularly on large datasets like Yelp, where they achieve up to 5.24x speedup over DGL's implementation.
Figure 1: Speedup of GSpMM and multi-head SpMM compared with DGL.
  • Memory Efficiency: Mixed-precision training (fp16) provides ~27% memory savings, while ACT provides a staggering 6.4x to 16x memory saving with almost no loss in accuracy.
  • Real-World Impact: The library was deployed in the AMiner academic search system, improving the recall of their paper tagging system by 12.8%.

Limitations and Future Work

While CogDL is comprehensive, the authors note a few areas for growth:

  • Dynamic Graphs: The current version focuses primarily on static graphs. Handling graphs where nodes and edges are added or removed in real-time is a planned future direction.
  • Pre-training: As GNNs move toward large-scale pre-training (similar to BERT in NLP), the authors aim to expand CogDL’s support for these massive, self-supervised workflows.

Summary updated

BibTeX
@inproceedings{cen2023cogdl,
  author = {Yukuo Cen and Zhenyu Hou and Yan Wang and Qibin Chen and Yizhen Luo and Zhongming Yu and Hengrui Zhang and Xingcheng Yao and Aohan Zeng and Shiguang Guo and Yuxiao Dong and Yang Yang and Peng Zhang and Guohao Dai and Yu Wang and Chang Zhou and Hongxia Yang and Jie Tang},
  title = {{CogDL: A Comprehensive Library for Graph Deep Learning}},
  booktitle = {The Web Conference},
  year = {2023},
  doi = {10.1145/3543507.3583472},
}
Figure