Generalizable Insights for Graph Transformers in Theory and Practice
Timo Stoll, Luis Müller, Christopher Morris
TL;DR
This work addresses the lack of generalizable insights for graph transformers by introducing the Generalized-Distance Transformer (GDT), a standard-attention GT whose expressivity is tied to the Generalized-Distance Weisfeiler--Leman (GD-WL) framework. The GDT unifies node- and edge-level tokenization, explicit edge embeddings, and both absolute and relative positional embeddings to encode graph structure, proving that it can simulate GD-WL and thus achieve powerful graph discrimination when equipped with appropriate PEs. Through large-scale experiments across real-world domains (molecular property prediction, image-based object detection, code summarization) and synthetic algorithmic tasks, the authors identify a practical hierarchy of positional embeddings (RWSE, RRWP, LPE, SPE) and show strong few-shot transfer and size extrapolation capabilities, highlighting design choices that generalize across tasks and scales. The results offer generalizable insights for GT design, training, and inference, and demonstrate that scaling and thoughtful PE selection yield robust, transferable representations across diverse graph domains. The work provides theoretical and empirical guidance for building general-purpose, scalable graph transformers with broad applicability.
Abstract
Graph Transformers (GTs) have shown strong empirical performance, yet current architectures vary widely in their use of attention mechanisms, positional embeddings (PEs), and expressivity. Existing expressivity results are often tied to specific design choices and lack comprehensive empirical validation on large-scale data. This leaves a gap between theory and practice, preventing generalizable insights that exceed particular application domains. Here, we propose the Generalized-Distance Transformer (GDT), a GT architecture using standard attention that incorporates many advancements for GTs from recent years, and develop a fine-grained understanding of the GDT's representation power in terms of attention and PEs. Through extensive experiments, we identify design choices that consistently perform well across various applications, tasks, and model scales, demonstrating strong performance in a few-shot transfer setting without fine-tuning. Our evaluation covers over eight million graphs with roughly 270M tokens across diverse domains, including image-based object detection, molecular property prediction, code summarization, and out-of-distribution algorithmic reasoning. We distill our theoretical and practical findings into several generalizable insights about effective GT design, training, and inference.
