Comparing Graph Transformers via Positional Encodings

Mitchell Black, Zhengchao Wan, Gal Mishne, Amir Nayyeri, Yusu Wang

Graph Transformers (GTs) have emerged as a powerful alternative to traditional message-passing Graph Neural Networks (GNNs) by leveraging global attention mechanisms. However, because the standard Transformer architecture is permutation-equivariant and treats nodes as an unordered set, it is inherently "blind" to graph topology. To overcome this, researchers employ Positional Encodings (PEs) to inject structural information. These generally fall into two categories: Absolute Positional Encodings (APEs), which assign features to individual nodes, and Relative Positional Encodings (RPEs), which capture relationships between pairs of nodes.

In this work, Mitchell Black and colleagues establish a rigorous theoretical framework to compare these two paradigms, answering whether one is fundamentally more expressive than the other.

Theoretical Framework: The Equivalence of APE and RPE

The authors connect the expressive power of Graph Transformers to the Weisfeiler-Lehman (WL) test hierarchy. They introduce RPE-augWL, a variant of the WL test tailored for RPE-augmented models, to serve as a benchmark for expressivity.

A central contribution of the paper is the proof that APE-GTs and RPE-GTs are theoretically equivalent in their ability to distinguish non-isomorphic graphs when no initial node features are present. The researchers demonstrate that any APE can be transformed into an equivalent RPE via a DeepSet network, while any RPE can be mapped back to an APE using a 2-Equivariant Graph Network (2-EGN).

Theoretical landscape connecting APE-GTs, RPE-GTs, and the RPE-augWL test.

A Hierarchy of Positional Encodings

Beyond the general equivalence of architectures, the paper maps the relative "strength" of specific, popular positional encodings. This hierarchy includes combinatorial measures like Shortest Path Distance (SPD) and Resistance Distance (RD), as well as spectral measures like the Stable and Expressive Positional Encoding (SPE).

Hierarchy of positional encodings and their relationships to spectral and combinatorial properties.

The analysis reveals that while APEs and RPEs are equivalent for unfeatured graphs, RPEs possess a distinct advantage when graphs include initial node features (e.g., atom types in a molecule). In such cases, converting an RPE into an APE can lead to a loss of information, making RPEs a more robust choice for practical, feature-rich applications.

Empirical Validation

The theoretical findings were validated across three distinct benchmarks:

  1. CSL (Circular Skip Links): Both APE-GTs and RPE-GTs achieved 100% accuracy, confirming their theoretical equivalence for structural isomorphism tasks.
  2. BREC: This comprehensive benchmark for pair-distinguishing accuracy suggested that Resistance Distance (RD) and SPE are generally more powerful than the classic Shortest-Path Distance (SPD).
  3. ZINC: On this real-world molecular dataset, RPE-GTs consistently outperformed APE-GTs derived from the same information. For example, using Resistance Distance (RD) directly as an RPE yielded a Mean Absolute Error (MAE) of 0.096, while the APE version (EGN APE-GT) lagged behind at 0.196.

Conclusion and Practical Implications

While APEs and RPEs share theoretical foundations, the practical implementation of the mappings between them—specifically the 2-EGN required to turn RPEs into APEs—is computationally expensive ($\Theta(n^2)$) and difficult to learn. This suggests that RPEs are often the more efficient and effective choice for real-world graph representation learning.

Future research directions include extending the framework to include edge features, moving beyond distinguishing power to function approximation capabilities, and investigating the lower bounds for the hidden dimensions required to learn these complex structural mappings.

Summary updated

BibTeX
@inproceedings{black2024comparing,
  author = {Mitchell Black and Zhengchao Wan and Gal Mishne and Amir Nayyeri and Yusu Wang},
  title = {{Comparing Graph Transformers via Positional Encodings}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=va3r3hSA6n},
}
Figure