STGformer: Efficient Spatiotemporal Graph Transformer for Traffic Forecasting

Hongjun Wang, Jiyuan Chen, Tong Pan, Zheng Dong, Lingyu Zhang, Renhe Jiang, Xuan SongarXiv 2024 · DOI

Abstract

Traffic forecasting is a cornerstone of smart city infrastructure, yet existing models struggle to scale to real-world urban networks containing thousands of sensors. Traditional Graph Convolutional Networks (GCNs) often miss long-range dependencies, while Transformers suffer from quadratic complexity. We introduce STGformer, a streamlined architecture that captures complex spatiotemporal patterns in a single, highly efficient layer. By integrating linearized attention with graph propagation, STGformer achieves state-of-the-art accuracy while delivering a 100x speedup and using 99.8% less GPU memory than previous leading models like STAEformer.

The Scalability Wall in Traffic Forecasting

Real-world road networks, such as the Caltrans system in California, involve tens of thousands of sensors. Most current research, however, focuses on small datasets with only a few hundred nodes. This discrepancy exists because existing solutions face a fundamental trade-off:

  1. GCNs are efficient at local neighborhood interactions but fail to capture global context.
  2. Transformers excel at global modeling but their memory and computational requirements explode ($O(N^2)$) as the number of sensors ($N$) grows.

STGformer bridges this gap, providing the global "vision" of a Transformer with the efficiency required for massive, real-world graphs.

Methodology: The STG-Attention Block

The core innovation of STGformer is the STG-attention block, which replaces the traditional deep stack of multiple attention layers with a single, recursive interaction module.

Comparison of STAEformer and STGformer architectures. STGformer simplifies the pipeline by unifying temporal and spatial processing into a single block.

Key Architectural Innovations

  • Unified Spatiotemporal Attention: Rather than processing space and time sequentially, STGformer treats them as a unified entity, allowing for joint modeling in a single pass.
  • Linearized Attention: To overcome the quadratic bottleneck, the authors utilize a linear attention mechanism. By replacing standard softmax with decomposed inner products, computational complexity is reduced from $O(N^2)$ to $O(N)$.
  • Graph Propagation Integration: The model incorporates simplified graph propagation (based on Chebyshev polynomials) to extract local structural information, which is then integrated into the global attention module.
  • Recursive Interaction: Instead of stacking deep layers—which can lead to over-smoothing—STGformer uses a recursive approach to refine features, maintaining a minimal parameter footprint.

Experimental Results

STGformer was evaluated on the LargeST benchmark, which includes sub-datasets from San Diego (716 sensors), the Bay Area (2,352 sensors), and Los Angeles (3,834 sensors).

Efficiency and Accuracy

STGformer consistently outperformed state-of-the-art models like PDFormer and STAEformer across all metrics (MAE, RMSE, MAPE). Notably, during batch inference on a California road graph with 8,600 sensors, STGformer achieved a 100x speedup compared to STAEformer.

MAE vs. FLOPs for various ST-Models. STGformer (red line) sits on the Pareto frontier, achieving lower error with significantly fewer computations than heavy models like STAEformer and DSTAGNN.

Robustness and Generalization

The model demonstrated remarkable robustness in "cross-year" scenarios (training on 2019 data and testing on 2020 data). It achieved a 14.14% reduction in RMSE for 3-hour predictions compared to other models, proving its ability to handle shifting traffic patterns over time.

Conclusion and Future Work

STGformer represents a significant leap toward practical, large-scale traffic forecasting. By proving that a single, well-integrated layer can outperform deep architectures, it sets a new standard for efficiency. Future work will explore dynamic graph learning to account for real-time road changes (e.g., accidents) and push the model toward extreme scaling for networks exceeding 20,000 sensors.

Summary updated

BibTeX
@misc{wang2024stgformer,
  author = {Hongjun Wang and Jiyuan Chen and Tong Pan and Zheng Dong and Lingyu Zhang and Renhe Jiang and Xuan Song},
  title = {{STGformer: Efficient Spatiotemporal Graph Transformer for Traffic Forecasting}},
  year = {2024},
  eprint = {2410.00385},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.00385},
}
Figure