The Problem
Building, scaling, and benchmarking graph neural networks (GNNs) requires a library that hides low‑level CUDA/CPU handling while staying framework‑agnostic. Teams that switch between PyTorch, TensorFlow or MXNet often rewrite data loaders, message‑passing kernels, and distributed‑training glue code.
What This Does
The repository is a portfolio of related projects that together deliver a full‑stack GNN toolkit:
- Core library –
python/dgl/provides thedglpackage (e.g.,python/dgl/__init__.py,python/dgl/nn/pytorch/conv/). It defines graph objects, message‑passing APIs and a large catalog of layers. - CLI helper –
dglgo/dglgo/cli/cli.pyimplements a command‑line interface (dglgo) for quick training, hyper‑parameter sweeps and model inspection. - Examples & benchmarks –
examples/(742 files) andbenchmarks/contain end‑to‑end scripts for popular models (GAT, GraphSAGE, Graphormer) and performance suites that exercise multi‑GPU and multi‑node scaling. - Distributed runtime –
graphbolt/andsrc/hold the C/C++ back‑ends compiled via the top‑levelCMakeLists.txt. - Packaging –
pyproject.tomlanddglgo/setup.pydescribe the pip‑installable artifacts.
How It Is Wired
Execution starts at the real entry point dglgo/dglgo/cli/cli.py (main at line 25). The flow is:
mainparses CLI arguments and dispatches to sub‑commands such astrain.train(indglgo/dglgo/cli/train_cli.py) creates a model class (e.g.,examples/pytorch/arma/model.py) and calls itsforwardmethod.- The model’s
forwardtypically invokes a DGL convolution layer (SAGEConv,GATConv) – these constructors are instantiated inpython/dgl/nn/pytorch/conv/__init__.py(111 calls toSAGEConv). - Convolution kernels call low‑level ops like
apply_edges,sample_neighbors, and frequently usezeros(called from 101 distinct places) andsize(46 places). - Training loops (
train→step→backward→optimizer.step) are wired through the internal call graph; the most reused functions arezeros,size,eval,train,cuda,cross_entropy. - External effects are short: the model training path reaches the filesystem (e.g., loading datasets in
python/dgl/data/utils.py), writes checkpoints, and occasionally makes a network request (e.g.,_downloadinbenchmarks/benchmarks/utils.py). No database or long‑running service is started.
The hub module python/dgl/__init__.py is imported by 133 other modules, making any change there high‑blast‑radius. It participates in a circular import with python/dgl/base.py and python/dgl/utils/__init__.py, which inflates instability (0.13) and complicates refactoring.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/dgl
cd dgl
# Install Python dependencies (no lockfile – see health section)
pip install -e . # installs the dgl package and builds C/C++ extensions
# Optional: build with CMake for custom CUDA configuration
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
# Run the CLI starter (example: training a GAT on OGB)
python -m dglgo.cli train --config examples/pytorch/ogb/cluster-gat/config.yaml
Configuration files live alongside each example (e.g., examples/pytorch/ogb/cluster-gat/config.yaml). No environment‑variable secrets are required; the only external requirement is a CUDA‑capable GPU if you invoke GPU‑specific examples.
Real‑World Use
A data‑science team can replace a custom PyTorch graph pipeline with:
import dgl
from dglgo.dglgo.cli import train
# Load OGB dataset
graph, labels = dgl.data.OgbnProducts()(raw=False)
# Train using the built‑in GAT model
train(
graph=graph,
labels=labels,
model='GAT',
epochs=50,
lr=0.01,
)
The code reuses the same train entry point used by the repository’s benchmark scripts, guaranteeing identical data handling and optimizer schedules.
Code Health & Issues
- High – Lockfile missing –
pyproject.tomlhas no accompanying lockfile. - High – CI never runs tests – Jenkinsfile exists but no test step in any GitHub workflow.
- Medium – GitHub token permissions –
.github/workflows/lint.ymldeclares no permissions. - Medium – Dependabot not configured – no automatic version‑update bot.
- Medium – Docker base image mutable –
docker/Dockerfile.awscliusesubuntu:latest. - Medium – No dependency‑vulnerability scan – CI lacks a review step.
- Medium – Oversized notebook cells – e.g.,
notebooks/stochastic_training/ondisk_dataset_heterograph.ipynb. - Medium – Missing random seeds in notebooks – stochastic notebooks are nondeterministic.
- Medium – Generated build artifacts under version control – some test directories contain compiled files.
- Medium – Checkout persists credentials –
persist-credentials: falsemissing in CI.
Additional observations: a full test suite (219 files) is present, CI is driven by Jenkins, Dockerfiles exist but are not referenced by any CI job, and the repository carries an Apache‑2.0 license.
The Bottom Line
The repo delivers a mature, framework‑agnostic GNN library with extensive examples and benchmarks, but the codebase suffers from architectural cycles, a volatile core module, and gaps in reproducible builds and CI enforcement. It is suitable for teams that need a research‑grade graph toolkit and are prepared to address the lock‑file and CI shortcomings before production deployment.