TL;DR
Temporal Graph Learning (TGL) has historically suffered from fragmented, inefficient software infrastructure that strictly separates continuous and discrete-time methods. The Temporal Graph Modelling (TGM) library bridges this gap using modular "hooks" and native time-granularity conversions. TGM achieves massive speedups over existing tools—averaging a 7.8× training speedup and a 175× discretization speedup—while unlocking new research paradigms like dynamic graph property prediction.
The Infrastructure Gap in Temporal Graphs
If you work in standard graph machine learning, you likely rely on mature, highly optimized libraries like PyTorch Geometric (PyG) or Deep Graph Library (DGL). However, real-world networks—such as financial transactions, social media interactions, and traffic mobility—are rarely static; they evolve over time.
Machine learning for these Temporal Graphs (TGs) lacks comparable infrastructure. Existing TGL libraries are often narrow in scope, supporting only a single family of architectures. Worse, the field is conceptually split into two isolated camps:
- Continuous-Time Dynamic Graphs (CTDG): Treats the graph as a continuous stream of timestamped events.
- Discrete-Time Dynamic Graphs (DTDG): Treats the graph as a sequence of static snapshots (e.g., one graph per day).
Because these two paradigms traditionally require entirely different data pipelines, researchers struggle to compare models fairly, combine ideas, or rapidly prototype. TGM was built to fix this fragmented ecosystem.
The TGM Architecture: Unifying CTDG and DTDG
TGM introduces a framework that unifies CTDG and DTDG approaches by treating them not as different data types, but as different ways to iterate over the same underlying event stream.
Key technical innovations include:
- Unified Iteration: TGM allows users to iterate over a graph by events (CTDG style, e.g., 200 interactions per batch) or by time (DTDG style, e.g., 1 day of interactions per batch) using the exact same underlying data structure.
- Hooks and Recipes: Instead of hardcoding data transformations into the models, TGM uses a modular "hook" system. Operations like temporal neighbor sampling, negative edge generation, and GPU transfer are defined as independent hooks. TGM's HookManager automatically resolves dependencies and executes them efficiently during data loading.
Vectorized Discretization
To run snapshot-based models on continuous data, TGM provides a fully vectorized, PyTorch-native discretization engine. It groups fine-grained events into coarser time buckets (e.g., seconds to hours) without the massive overhead of Python dictionaries.
This allows researchers to seamlessly test a discrete GCN against a continuous Transformer-based model on the exact same task, effectively removing the artificial data barrier between the two methodologies.
Key Insights and Performance Results
The library was evaluated primarily using the standardized Temporal Graph Benchmark (TGB) and the MiNT benchmark, covering link prediction, node property prediction, and graph property prediction.
TGM's flexible architecture revealed several critical insights:
- Time Granularity is a Crucial Hyperparameter: TGM makes it trivial to change the snapshot resolution for DTDG models. The authors found this drastically impacts performance; for instance, a GCN's accuracy (MRR) on the Wikipedia dataset jumped by 30% simply by switching from weekly to daily snapshots.
- Batching Strategies Alter Model Accuracy: In continuous-time models, processing larger batches is faster but delays how often the model updates its internal memory. TGM revealed that larger batch sizes or coarser temporal units actually degrade predictive performance, highlighting a hidden trade-off between computational efficiency and model "staleness."
Speed and Efficiency
- Training Speed: TGM achieved an average 7.8× speedup in end-to-end training across multiple models and datasets compared to DyGLib, a widely used existing library. For specific models like the transformer-based DyGFormer, it was 4.4× faster.
- Discretization Speed: TGM's vectorized approach to converting continuous graphs into snapshots is blisteringly fast, achieving an average 175× speedup (and up to 433× on the LastFM dataset) compared to previous implementations.
- Broad Support: TGM successfully implements 8 diverse baseline and state-of-the-art models (including TGAT, TGN, GCLSTM, and TPNet) under one roof.
Future Directions
The interplay between batch size, model update frequency, and predictive performance remains a complex area requiring further theoretical exploration. Moving forward, the TGM team is actively expanding the library to include cutting-edge architectures, such as state-space models for graphs (e.g., DyGMamba). They also plan to build out alternative, highly optimized storage backends to support massive-scale graphs and diverse hardware workloads.
Summary updated