arXiv:2409.05477cs.LG2024-09被引 7

用Transformer重构时序图神经网络,训练速度提升2.2倍以上

Retrofitting Temporal Graph Neural Networks with Transformer

  • 以Transformer解码器为骨干,将时序图建模转为序列建模
  • 在9个数据集上训练速度提升超2.2倍,精度相当或更优
  • 适配高效训练框架,适合追求训练效率的时序图研究者

时序图神经网络(TGNN)通过引入时间信息,在图操作中表现优于普通GNN。然而,现有TGNN依赖专用模型(如TGN、TGAT、APAN)和定制训练框架(如TGL、ETC)。本文提出TF-TGN,采用Transformer解码器作为骨干模型,利用Transformer成熟的高效计算库(如flash-attention、memory-efficient attention)和分布式训练方案(如PyTorch FSDP、DeepSpeed、Megatron-LM)。我们发现TGNN中的消息聚合可类比语言建模,即按时间顺序处理节点及其邻居。基于此,设计了后缀填充、带自环的时序图注意力与因果掩码自注意力等机制。针对现有系统在拓扑转换与采样上的瓶颈,提出并行化CSR格式转换与图采样方法,并适配Transformer代码库实现多卡高效训练。在9个图数据集上对比2个前沿TGNN训练框架,结果表明TF-TGN训练加速超过2.20倍,精度相当或更优。代码已开源:https://github.com/qianghuangwhu/TF-TGN。

原文摘要 · Abstract (English)

Temporal graph neural networks (TGNNs) outperform regular GNNs by incorporating time information into graph-based operations. However, TGNNs adopt specialized models (e.g., TGN, TGAT, and APAN ) and require tailored training frameworks (e.g., TGL and ETC). In this paper, we propose TF-TGN, which uses Transformer decoder as the backbone model for TGNN to enjoy Transformer's codebase for efficient training. In particular, Transformer achieves tremendous success for language modeling, and thus the community developed high-performance kernels (e.g., flash-attention and memory-efficient attention) and efficient distributed training schemes (e.g., PyTorch FSDP, DeepSpeed, and Megatron-LM). We observe that TGNN resembles language modeling, i.e., the message aggregation operation between chronologically occurring nodes and their temporal neighbors in TGNNs can be structured as sequence modeling. Beside this similarity, we also incorporate a series of algorithm designs including suffix infilling, temporal graph attention with self-loop, and causal masking self-attention to make TF-TGN work. During training, existing systems are slow in transforming the graph topology and conducting graph sampling. As such, we propose methods to parallelize the CSR format conversion and graph sampling. We also adapt Transformer codebase to train TF-TGN efficiently with multiple GPUs. We experiment with 9 graphs and compare with 2 state-of-the-art TGNN training frameworks. The results show that TF-TGN can accelerate training by over 2.20 while providing comparable or even superior accuracy to existing SOTA TGNNs. TF-TGN is available at https://github.com/qianghuangwhu/TF-TGN.

时序图神经网络Transformer高效训练图学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。