Table of Contents
Fetching ...

TGM: a Modular and Efficient Library for Machine Learning on Temporal Graphs

Jacob Chmura, Shenyang Huang, Tran Gia Bao Ngo, Ali Parviz, Farimah Poursafaei, Jure Leskovec, Michael Bronstein, Guillaume Rabusseau, Matthias Fey, Reihaneh Rabbany

TL;DR

Temporal graphs require specialized tooling to handle evolving structures and to bridge continuous-time and discrete-time paradigms. TGM introduces a modular framework with node events, a hook-based pipeline, and a unified CTDG/DTDG representation via a common time granularity $\tau$ and a discretization operator $\mathcal{\psi}_{r}$, enabling time-driven workflows and reusable transformations. The library delivers substantial empirical gains (average training speedups of $7.8\times$ over DyGLib and up to $175\times$ for discretization), supports a broad set of models, and aligns with the Temporal Graph Benchmark, providing a robust research-oriented platform. By enabling dynamic graph property prediction and time-driven training paradigms, TGM lowers barriers to experimentation and paves the way for a shared ecosystem of models, hooks, and analytics for temporal graph learning.

Abstract

Well-designed open-source software drives progress in Machine Learning (ML) research. While static graph ML enjoys mature frameworks like PyTorch Geometric and DGL, ML for temporal graphs (TG), networks that evolve over time, lacks comparable infrastructure. Existing TG libraries are often tailored to specific architectures, hindering support for diverse models in this rapidly evolving field. Additionally, the divide between continuous- and discrete-time dynamic graph methods (CTDG and DTDG) limits direct comparisons and idea transfer. To address these gaps, we introduce Temporal Graph Modelling (TGM), a research-oriented library for ML on temporal graphs, the first to unify CTDG and DTDG approaches. TGM offers first-class support for dynamic node features, time-granularity conversions, and native handling of link-, node-, and graph-level tasks. Empirically, TGM achieves an average 7.8x speedup across multiple models, datasets, and tasks compared to the widely used DyGLib, and an average 175x speedup on graph discretization relative to available implementations. Beyond efficiency, we show in our experiments how TGM unlocks entirely new research possibilities by enabling dynamic graph property prediction and time-driven training paradigms, opening the door to questions previously impractical to study. TGM is available at https://github.com/tgm-team/tgm

TGM: a Modular and Efficient Library for Machine Learning on Temporal Graphs

TL;DR

Temporal graphs require specialized tooling to handle evolving structures and to bridge continuous-time and discrete-time paradigms. TGM introduces a modular framework with node events, a hook-based pipeline, and a unified CTDG/DTDG representation via a common time granularity and a discretization operator , enabling time-driven workflows and reusable transformations. The library delivers substantial empirical gains (average training speedups of over DyGLib and up to for discretization), supports a broad set of models, and aligns with the Temporal Graph Benchmark, providing a robust research-oriented platform. By enabling dynamic graph property prediction and time-driven training paradigms, TGM lowers barriers to experimentation and paves the way for a shared ecosystem of models, hooks, and analytics for temporal graph learning.

Abstract

Well-designed open-source software drives progress in Machine Learning (ML) research. While static graph ML enjoys mature frameworks like PyTorch Geometric and DGL, ML for temporal graphs (TG), networks that evolve over time, lacks comparable infrastructure. Existing TG libraries are often tailored to specific architectures, hindering support for diverse models in this rapidly evolving field. Additionally, the divide between continuous- and discrete-time dynamic graph methods (CTDG and DTDG) limits direct comparisons and idea transfer. To address these gaps, we introduce Temporal Graph Modelling (TGM), a research-oriented library for ML on temporal graphs, the first to unify CTDG and DTDG approaches. TGM offers first-class support for dynamic node features, time-granularity conversions, and native handling of link-, node-, and graph-level tasks. Empirically, TGM achieves an average 7.8x speedup across multiple models, datasets, and tasks compared to the widely used DyGLib, and an average 175x speedup on graph discretization relative to available implementations. Beyond efficiency, we show in our experiments how TGM unlocks entirely new research possibilities by enabling dynamic graph property prediction and time-driven training paradigms, opening the door to questions previously impractical to study. TGM is available at https://github.com/tgm-team/tgm

Paper Structure

This paper contains 19 sections, 4 equations, 6 figures, 14 tables.

Figures (6)

  • Figure 1: Overview of TGM features. TGM has native support for node events and unified continuous- and discrete-time graph iteration (left). Generic hooks formalize common TG transformations (top-right). TGM supports a broad range of temporal graph learning methods (bottom-right).
  • Figure 2: TGM supports iteration by events and time. Discretization maps fine-grained timestamps (e.g., hourly) to coarser timestamps (e.g., daily), aggregating duplicated edges in the process.
  • Figure 3: Example recipes in TGM: TGAT link prediction and Density of States Analysis. TGM provides a unified ecosystem supporting both representation learning and temporal graph analytics. The constituent hooks are modular, enabling reuse across different workflows within the community.
  • Figure 4: Three Layer Architecture of TGM: data layer (left), with IO adaptors and preprocessing, immutable COO graph storage, and lightweight sub-graph views; execution layer (middle), where users register custom hooks or apply pre-built recipes through the hook manager and dataloader to inject execution logic; and ML layer (right), where batches are materialized on device and used for node-, link-, or graph-level prediction. Light blue elements denote user-facing APIs.
  • Figure 5: Example workflow in TGM. Left: dataset loading, graph creation, and hook registration; Right: manager injection, model setup, and training loop with automatic hook activation. Highlighted code maps to system components from Figure \ref{['fig:arch']}.
  • ...and 1 more figures

Theorems & Definitions (4)

  • Definition 3.1: Node and Edge Events
  • Definition 3.2: Materialized Batch
  • Definition 3.3: Hook
  • Definition 3.4: Hook Recipe