Let's Group: A Plug-and-Play SubGraph Learning Method for Memory-Efficient Spatio-Temporal Graph Modeling

Wenchao Weng, Hanyu Jiang, Mei Wu, Xiao Han, Haidong Gao, Guojiang Shen, Xiangjie Kong

Abstract

Spatio-Temporal Graph Neural Networks (STGNNs) are the state-of-the-art for modeling complex dependencies in sensor networks, such as traffic and weather systems. However, their $O(N^2)$ memory complexity—driven by the calculation of full-graph correlation matrices—creates a "memory wall" that hinders scalability to large-scale datasets. We introduce SubGraph Learning (SGL), a plug-and-play framework that dynamically partitions graphs into smaller, learnable subgraphs. By replacing global operations with localized subgraph processing, SGL reduces GPU memory overhead by up to 56.4% without compromising predictive performance. Our method utilizes learnable memory vectors to capture dynamic node relationships, offering a scalable solution for modern spatio-temporal modeling.

Introduction

In fields like traffic forecasting, sensors are modeled as nodes in a spatio-temporal graph. Modern STGNNs typically compute a correlation matrix to capture dependencies between all pairs of nodes. While effective, this approach scales quadratically ($O(N^2)$) with the number of nodes $N$. As urban sensor networks grow, the memory required to store these matrices often exceeds the capacity of high-end GPUs.

Existing solutions often rely on static partitioning (e.g., geographic clustering), which fails to account for the dynamic, feature-based relationships between nodes. To address this, we propose SubGraph Learning (SGL), which enables dynamic, learnable partitioning and efficient feature aggregation.

Methodology

The SGL framework consists of two primary modules that can be integrated into existing STGNN architectures as a plug-and-play enhancement.

Comparison between standard Spatio-temporal Graph Feature Extraction (top) and the proposed Subgraph Feature Extraction (bottom) using SGL.

SubGraph Partition Module (SGPM)

The SGPM avoids fixed geographic boundaries by using learnable "memory vectors" as anchors. For each anchor, the module calculates similarity scores against current node features and selects the top-$K$ most similar nodes to form a subgraph. This allows the model to group nodes based on behavioral patterns rather than physical proximity.

The SubGraph Partition Module (SGPM) uses learnable memory vectors to dynamically group nodes into subgraphs based on feature similarity.

SubGraph Feature Aggregation Module (SGFAM)

Since nodes are grouped dynamically, a single node may belong to multiple subgraphs, leading to redundant representations. The SGFAM reconciles these by collecting a node's features from all its assigned subgraphs and performing an aggregation (e.g., averaging). This ensures a comprehensive representation while maintaining computational efficiency. By processing subgraphs of size $K$ instead of the full graph $N$, the computational complexity is reduced from $O(N^2)$ to approximately $O(N + K^2)$, where $K \ll N$.

Experimental Evaluation

We evaluated SGL using four real-world traffic flow datasets from the Caltrans Performance Measurement System (PeMS): PEMS03 (358 nodes), PEMS04 (307 nodes), PEMS07 (883 nodes), and PEMS08 (170 nodes). SGL was integrated as a plug-and-play component into several backbone models, including GMAN, STWave, and DGCRN.

Key Results

  • Memory Efficiency: SGL achieved a maximum average GPU memory reduction of 56.4%. Notably, for the DDGCRN model on the large-scale PEMS07 dataset, memory usage was slashed from 12.59 GB to 4.97 GB.
  • Predictive Performance: Despite the reduced memory footprint, SGL variants maintained or even improved accuracy. For instance, the GMAN-SGL variant achieved lower Mean Absolute Error (MAE) than the original full-graph model.
  • Scalability: The benefits of SGL scale with data size. On larger datasets like PEMS07, the memory savings exceeded 60% for specific backbones, demonstrating its viability for massive sensor networks.

Conclusion and Future Work

SGL provides a robust, memory-efficient strategy for scaling STGNNs. By shifting from static, geographic partitioning to dynamic, learnable subgraph grouping, it captures complex dependencies while breaking the $O(N^2)$ memory barrier. Future research will focus on optimizing hyperparameter selection for $M$ (number of subgraphs) and $K$ (subgraph size), as well as exploring more sophisticated attention-based aggregation methods in the SGFAM to better handle overlapping node information.

Summary updated

BibTeX
@inproceedings{weng2025let,
  author = {Wenchao Weng and Hanyu Jiang and Mei Wu and Xiao Han and Haidong Gao and Guojiang Shen and Xiangjie Kong},
  title = {{Let's Group: A Plug-and-Play SubGraph Learning Method for Memory-Efficient Spatio-Temporal Graph Modeling}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/386},
}
Figure