How wanifarooq/glnbench works
Purpose and entry points
This is a Python benchmark framework for comparing 13 GNN label-noise robustness methods across graph datasets, noise models, backbones, and repeated runs. The production entry point is main.py, which expands YAML sweeps and incrementally executes missing runs. main_multithreading.py runs a fixed-seed, multi-method comparison in parallel. Programmatic execution centers on util/experiment.py.
Paths: main.py, main_multithreading.py, util/experiment.py
Experiment orchestration and reproducibility
An experiment initializes deterministic run-specific seeds, selects CPU/CUDA, derives output/checkpoint locations, and coordinates the full lifecycle. Sweep expansion, configuration hashing, completion detection, and aggregation support resumable multi-run benchmarks. Each run emits per-epoch logs and optionally checkpoints; aggregate results are persisted by the top-level runner.
Paths: main.py, sweep_utils.py, util/experiment.py
Data ingestion, split boundaries, and label corruption
Dataset loading/preprocessing creates PyTorch Geometric graph data, uses supplied splits or deterministic generated masks, and downloads supported sources as needed. Noise injection modifies only train and validation labels while retaining clean labels and corruption masks for factual-versus-corrected analysis; test labels remain ground truth. Inductive mode partitions the graph into disconnected train/validation/test subgraphs, while default transductive mode exposes the full graph for message passing.
Paths: util/data.py, util/noise.py, util/inductive.py
Backbone and algorithm extension layers
model/gnns.py provides shared GCN, GIN, GAT, GATv2, GPS, and tuned modified-GCN backbones. Robustness algorithms are split into thin registered trainer wrappers and registered helper implementations: wrappers may host algorithm-specific model/loss components, while helpers own setup, optimization, train/validation/prediction, and embedding extraction. This two-registry design makes method selection configuration-driven.
Paths: model/gnns.py, model/registry.py, methods/registry.py
Unified training control plane
TrainingLoop invokes the selected helper over epochs, handling full-graph or compatible mini-batch training, early stopping, best-state restoration, periodic oversmoothing measurement, and final inference. The helper interface is the key boundary between common lifecycle behavior and method-specific learning logic. Unsupported methods remain full-batch for training but can use batched evaluation/inference.
Paths: training/training_loop.py, training/early_stopping.py, methods/base_helper.py
Sampling and runtime execution modes
When batching is configured, the sampler factory supplies PyG NeighborLoader, ClusterLoader, GraphSAINT, or RandomNode loaders. Batched inference scatters predictions/embeddings back to global node IDs; inductive execution instead evaluates within each partition and reconstructs global outputs. Material runtime dependencies are Python 3.10/3.11, PyTorch 2.2.1, PyTorch Geometric, and optional CUDA 11.8.
Paths: util/graph_sampling.py, util/inductive.py, setup.sh
Evaluation, profiling, and artifacts
Evaluation produces macro classification metrics for splits and clean/corrupted subsets, plus embedding-based oversmoothing metrics. Profiling captures inference/training FLOPs and timing; CodeCarbon can record emissions. Training logs, plots, best/per-epoch checkpoints, and aggregate experiment JSON are the durable interface to downstream analysis scripts.
Paths: model/evaluation.py, util/profiling.py, util/plot.py
Main entry points: training_loop.py Training loop · experiment.py Experiment lifecycle · data.py Dataset ingestion · base_helper.py Method helper interface
Components 19
Benchmark orchestration
- Sweep runner · Expands YAML sweeps and resumes missing runs.
main.py - Parallel comparison runner · Runs fixed-seed multi-method comparisons in parallel.
main_multithreading.py - Sweep management · Hashes configurations, detects completion, and aggregates runs.
sweep_utils.py - Experiment lifecycle · Sets seeds, device, locations, and coordinates each run.
util/experiment.py
Data and corruption
- Dataset ingestion · Loads, preprocesses, and creates deterministic graph splits.
util/data.py - Label corruption · Corrupts train and validation labels while preserving clean labels and masks.
util/noise.py - Inductive partitioning · Creates disconnected split subgraphs and reconstructs global outputs.
util/inductive.py
Learning runtime
- Sampler factory · Builds neighbor, cluster, GraphSAINT, or random-node loaders.
util/graph_sampling.py - GNN backbones · Provides shared GCN, GIN, GAT, GPS, and modified-GCN models.
model/gnns.py - Trainer registry · Selects registered algorithm trainer wrappers.
model/registry.py - Helper registry · Selects registered method learning implementations.
methods/registry.py - Method helper interface · Owns setup, optimization, validation, prediction, and embeddings.
methods/base_helper.py - Training loop · Runs epochs, early stopping, restoration, oversmoothing checks, and inference.
training/training_loop.py - Early stopping
training/early_stopping.py - Python / PyTorch runtime · Uses Python, PyTorch, PyG, and optional CUDA.
setup.sh
Evaluation and artifacts
- Metrics evaluation · Calculates split and clean/corrupted macro metrics plus oversmoothing measures.
model/evaluation.py - Runtime profiling · Captures FLOPs, timing, and optional emissions.
util/profiling.py - Plots and logs · Produces training logs and plots.
util/plot.py - Experiment artifacts · Stores checkpoints and aggregate experiment JSON for downstream analysis.
Connections 26
- Sweep runner → Sweep management: expands and resumes
- Sweep runner → Experiment lifecycle: executes runs
- Parallel comparison runner → Experiment lifecycle: parallel runs
- Sweep management → Experiment artifacts: aggregates results
- Experiment lifecycle → Dataset ingestion: loads graph data
- Dataset ingestion → Label corruption: clean split labels
- Dataset ingestion → Inductive partitioning: optional inductive mode
- Experiment lifecycle → Trainer registry: selects method wrapper
- Trainer registry → Helper registry: resolves helper
- Helper registry → Method helper interface: implements contract
- Experiment lifecycle → GNN backbones: configures backbone
- Experiment lifecycle → Sampler factory: configures batching
- Label corruption → Training loop: corrupted training data
- Inductive partitioning → Training loop: partitioned data
- Sampler factory → Training loop: mini-batches
- Training loop → Method helper interface: invokes learning steps
- Method helper interface → GNN backbones: trains and predicts with
- Training loop → Early stopping: applies policy
- Training loop → Metrics evaluation: final predictions and embeddings
- Training loop → Runtime profiling: measures execution
- Training loop → Plots and logs: per-epoch logs
- Metrics evaluation → Experiment artifacts: metrics
- Runtime profiling → Experiment artifacts: performance records
- Plots and logs → Experiment artifacts: logs and plots
- Training loop → Experiment artifacts: checkpoints
- Python / PyTorch runtime → Experiment lifecycle: executes on