Attending to Graph Transformers

Luis Müller, Mikhail Galkin, Christopher Morris, Ladislav Rampásek

Abstract

Graph Transformers (GTs) have emerged as a powerful alternative to traditional Message-Passing Graph Neural Networks (MPNNs), offering solutions to long-standing issues like over-smoothing and over-squashing. This paper presents a comprehensive taxonomy of the GT landscape and evaluates their performance through a series of "stress tests" targeting structural awareness, heterophily, and long-range dependencies. Our findings highlight that while GTs excel in global information propagation, their success is heavily dependent on the integration of high-quality structural and positional encodings.

Introduction

Message-Passing Graph Neural Networks (MPNNs) have long been the standard for graph-structured data. However, their inherent local bias—updating node states based only on immediate neighbors—introduces significant limitations. Specifically, MPNNs suffer from over-smoothing, where node features become indistinguishable over many layers, and over-squashing, where information from distant nodes is lost as it traverses graph bottlenecks.

Graph Transformers (GTs) address these challenges by employing global attention mechanisms, allowing every node to interact with every other node. Despite their promise, the rapid expansion of the field has left a gap in unified frameworks. This work categorizes the diverse GT architectures and empirically validates their ability to overcome GNN-specific failures.

Taxonomy of Graph Transformers

To navigate the growing field of GTs, we propose a taxonomy categorized into four primary dimensions: Encodings, Input Features, Tokens, and Propagation.

Taxonomy of Graph Transformers across four key dimensions: Encodings, Input Features, Tokens, and Propagation.
  1. Encodings: Methods to inject graph topology into the transformer, such as Laplacian eigenvectors or random walk signatures.
  2. Input Features: Handling of standard node/edge attributes versus 3D geometric coordinates.
  3. Tokens: The fundamental units of the sequence, ranging from nodes and edges to subgraphs.
  4. Propagation: The mechanism of information flow, including standard global attention, sparse attention for scalability, or hybrid GNN-Transformer models.

Theoretically, without structural or positional encodings (PE/SE), a GT functions merely as a "DeepSet," treating the graph as an unordered collection of nodes.

Experimental Evaluation

We benchmarked several GT architectures (e.g., Graphormer, GPS, SAN) against standard GNN baselines (e.g., GIN, GCN) across three critical areas:

  • Structural Awareness: Tasks involving link prediction (Edges), subgraph counting (Triangles), and distinguishing complex topologies (CSL).
  • Heterophily: Datasets where neighboring nodes often possess different labels (e.g., Roman-Empire, Amazon-Ratings).
  • Over-squashing: The NeighborsMatch synthetic dataset, which tests a model's ability to propagate information from leaf nodes to the root in a tree structure.

Key Results and Insights

Our empirical analysis reveals several critical insights into the behavior of Graph Transformers.

The Necessity of Structural Encodings

A primary finding is that PE/SE is non-negotiable for structural tasks. As shown in the benchmarking results, a standard Transformer without specialized encodings fails to outperform simple GNNs on tasks like triangle counting or the CSL dataset. However, when augmented with Random Walk Structural Encodings (RWSE) or Laplacian PE, GTs achieve near-perfect accuracy.

Performance comparison of GNNs and various Graph Transformer configurations on structural awareness tasks.

Overcoming Over-squashing and Heterophily

GTs decisively solve the over-squashing problem. On the NeighborsMatch task, GTs maintained 100% accuracy up to depth 6, whereas GNN performance degraded significantly after depth 4. Furthermore, GTs excel in heterophilic environments. By utilizing global attention, nodes can identify relevant features across the entire graph, bypassing the local homophily assumption inherent in standard GNNs. For instance, on the Roman-Empire dataset, GT variants achieved ~83-87% accuracy, significantly outperforming GCNs (~73%).

Discussion and Future Directions

While GTs offer significant advantages, computational complexity remains a major hurdle. Standard global attention scales quadratically ($O(n^2)$) with the number of nodes, limiting application to massive networks. While sparse and linear attention mechanisms are being explored, integrating edge features into these efficient architectures remains an open challenge.

Future work should focus on:

  • Principled integration of domain-specific knowledge (e.g., molecular physics) into attention matrices.
  • Improving scalability for graphs with millions of nodes.
  • Investigating the "scaling laws" of GTs to determine if they mirror the performance gains seen in Large Language Models.

Summary updated

BibTeX
@article{muller2024attending,
  author = {Luis Müller and Mikhail Galkin and Christopher Morris and Ladislav Rampásek},
  title = {{Attending to Graph Transformers}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2024},
  url = {https://openreview.net/forum?id=NUefNfUtEb},
}
Figure