Back to paper library
Paper notesarXiv 2022NeurIPS 2022

GraphGPS

GPS for Graphs

Original paper

Recipe for a General, Powerful, Scalable Graph Transformer

Paper authors

Ladislav Rampášek · Mikhail Galkin · Vijay Prakash Dwivedi · Anh Tuan Luu · Guy Wolf · Dominique Beaini

Publication
NeurIPS 2022Conference
First submitted to arXiv
arXiv:2205.12454
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{graphlearninggraphgps2022,
  title = {{Recipe for a General, Powerful, Scalable Graph Transformer}},
  author = {Ladislav Rampášek and Mikhail Galkin and Vijay Prakash Dwivedi and Anh Tuan Luu and Guy Wolf and Dominique Beaini},
  year = {2022},
  eprint = {2205.12454},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.12454}
}
On this page

In 2021, Graphormer wins the OGB-LSC quantum-chemistry challenge with a Transformer, bringing sudden attention to Graph Transformers.

The appeal is clear. Letting every node see every other seems to bypass message passing's old problems at once: over-smoothing with depth, over-squashing over distance and the WL ceiling on discrimination.

But Graph Transformers then each follow their own recipe. Some use Laplacian eigenvectors for positions, others shortest-path distances as attention biases, others message passing layers at the front. There is no common account of which choices help or why. Global attention's O(N2)O(N^2) cost also confines most models to graphs with a few hundred nodes.

Ladislav Rampášek and Mikhail Galkin at Mila, Vijay Prakash Dwivedi at Nanyang Technological University and colleagues organize these choices into a recipe. GPS stands for General, Powerful, Scalable.

Defining the Problem

Position and Structure

A Transformer cannot see the graph itself. Once all nodes are connected, it has no idea which were originally adjacent, so Graph Transformers must supply graph information separately.

The authors distinguish two kinds:

  • Positional encoding (PE) gives a node's position in the graph. Nearby nodes should have nearby encodings. Laplacian eigenvectors (LapPE) are common.
  • Structural encoding (SE) describes node or graph structure. Nodes with similar surrounding subgraphs should have similar encodings. A common choice is the diagonal of the random-walk matrix's mmth power (RWSE): the probability of returning to self after mm steps.

Each splits further into local, global and relative forms. Global SE could be Laplacian eigenvalues; relative SE could indicate whether two nodes share a substructure. The authors tabulate existing approaches and argue that PE and SE should preferably be node features or real edges, allowing linear-complexity attention.

Why Message Passing Needs Them

Standard message passing is as discriminative as the 1-WL test. The authors illustrate with Circular Skip Link graphs: two non-isomorphic graphs get identical WL colors at every node, so no message passing network distinguishes them. Global PE gives unique starting colors and separates them; local RWSE can also detect their different skip connections.

These signals cannot be learned from structure through message passing alone; they must be provided separately.

Take an even smaller example: a six-node hexagon and two separate triangles. Every node in both graphs has two neighbors, so WL cannot tell them apart. RWSE differs in the probability of returning to the starting node in 3 steps: 0.25 on a triangle and 0 on the hexagon, which has no cycle of length 3. The authors also note that for odd mm, RWSE can tell whether a node lies on a cycle of length mm.

Message Passing before Attention Can Lose Information First

A common architecture, such as GraphTrans, stacks message passing before a Transformer. The authors see a risk: the initial layers' over-smoothing, over-squashing and expressiveness limits may discard information that no later Transformer can recover.

Convolution before a Transformer works in vision because grid convolutions are highly expressive; the authors question whether the same reasoning holds on graphs.

Solving the Problem

Three Ingredients

GPS has three parts:

  1. Positional/structural encodings, added to node or edge features at input.
  2. Local message passing, following real edges and handling edge features.
  3. Global attention, letting every node see all nodes.

Each is replaceable. Message passing can use GINE, GatedGCN or PNA; global attention can use standard Transformer, Performer or BigBird.

Figure 1 of the paper: the modular GPS architecture. Three columns on the left process positional encoding, structural encoding and graph features through MLP, DeepSet, SignNet or other components and add them to node and edge features. On the right, each of L GPS layers runs any message passing layer (GINE, GatedGCN, PNA) and any global attention (Transformer, Performer, BigBird) in parallel, sums them and applies a two-layer MLP.
Figure 1 from Rampášek et al., taken from PDF page 3. The original caption is omitted.

One GPS Layer

Each layer runs two parallel paths, sums their outputs, then applies an MLP:

XMℓ+1, Eℓ+1=MPNNeℓ(Xℓ,Eℓ,A)X_M^{\ell+1},\,E^{\ell+1}=\mathrm{MPNN}_e^{\ell}\left(X^\ell,E^\ell,A\right) XTℓ+1=GlobalAttnℓ(Xℓ)X_T^{\ell+1}=\mathrm{GlobalAttn}^{\ell}\left(X^\ell\right) Xℓ+1=MLPℓ(XMℓ+1+XTℓ+1)X^{\ell+1}=\mathrm{MLP}^{\ell}\left(X_M^{\ell+1}+X_T^{\ell+1}\right)

Edge features enter only the message passing path. Residuals and BatchNorm are omitted from the formulas but appear on both paths in the implementation.

Go back to those two graphs. Without positional or structural encodings, adding global attention still cannot separate them: every node has the same input, so attention can only be spread evenly, and looking at all nodes is no different from looking at the neighbors. Add RWSE, and each node starts out knowing whether it sits on a triangle; the same GPS layer can then tell the graphs apart.

Linear Complexity

Message passing costs O(E)O(E). Standard global attention costs O(N2)O(N^2); replacing it with linear attention such as Performer gives O(N)O(N). Because PE and SE reside on nodes and real edges, and edge features never enter global attention, no full attention matrix is required. On sparse molecular or knowledge graphs, edges grow proportionally with nodes, making the model O(N)O(N) overall. Laplacian eigendecomposition preprocessing is excluded.

In practice, a roughly 6-million-parameter model takes 196 seconds per epoch on ogbg-molpcba, versus SAN's 883 seconds on the same GPU type.

The authors also prove that, with suitable components, the architecture preserves edge information and is a universal function approximator on graphs.

Discussion

Ablation: Each Path's Contribution

The authors dissect components on four datasets:

SettingZINC MAE ↓PCQM4Mv2 subset MAE ↓CIFAR10 accuracy ↑MalNet-Tiny accuracy ↑
Full GPS (Transformer)0.0700.115972.31%93.50%
Performer global attention0.0710.114270.67%92.64%
BigBird global attention0.0710.123770.48%92.34%
Remove global attention0.0700.121369.95%92.23%
Remove message passing0.2170.329468.86%73.90%

Removing message passing badly hurts all four, dropping MalNet-Tiny from 93.50% to 73.90%. The authors regard it as indispensable because without it edge features have no entry point.

Global attention's contribution depends on the dataset. ZINC stays at 0.070 with or without it: the target molecular property depends only on counts of local substructures, so global links are unnecessary, but structural encoding matters greatly. Transformer attention helps the other three. Performer trails the standard Transformer but scales to large graphs; BigBird brings no significant gain here and is slower than Performer.

For encodings, ZINC MAE is 0.113 without any, 0.070 with RWSE, and 0.116 with LapPE. RWSE gives consistent gains at relatively low cost; SignNet is the best single encoding but costs more.

Comparison with Other Models

On Benchmarking GNNs' five datasets, GPS reaches ZINC MAE 0.070, below GCN's 0.367, GIN's 0.526 and Graphormer's 0.122; CIFAR10 accuracy is 72.30%. It places second on MNIST and CLUSTER, fourth on PATTERN, only a few tenths of a percentage point behind the leaders.

On OGB graph-level tasks, GPS is top three on ogbg-molpcba, ogbg-ppa and ogbg-code2, beating all other Graph Transformers according to the authors. On PCQM4Mv2, GPS-medium with 19.4 million parameters has validation MAE 0.0858, slightly better than Graphormer's 0.0864 with 48.3 million.

On the Long Range Graph Benchmark (LRGB), GPS combines GatedGCN, Transformer and LapPE and beats every baseline on four of five datasets. Peptides-func average precision is 0.6535 versus GCN's 0.5930; PascalVOC-SP F1 is 0.3748 versus 0.1268.

Reassessment a Year Later

The LRGB gap is later reexamined. In September 2023, Tönshoff et al. at RWTH Aachen perform basic hyperparameter searches for baselines including GCN. Peptides-func GCN rises to 0.6860, above the GPS rerun's 0.6534. The most important hyperparameter is the prediction head: replacing LRGB's single linear layer with a two-layer MLP closes most of the gap, while GPS barely changes. Tönshoff et al.

In 2025, Luo et al. add six techniques, including residuals, normalization, FFNs and positional encoding, to GCN, GIN and GatedGCN. Across 14 graph-level datasets, they match or beat Graph Transformers such as GPS.

Looking back, several GPS ingredients—positional and structural encoding, residuals, feedforward layers—later also appear among the techniques that let classic GNNs catch up.

Conclusion

GraphGPS separates Graph Transformers into three replaceable ingredients: positional/structural encoding, local message passing and global attention. Removing message passing hurts across the board; removing global attention hurts according to the task's need for distant information. Without encodings, attention still cannot see structures invisible to message passing.

For RWSE, a few sparse matrix multiplications produce an inexpensive addition to any GNN's input.

At least on ZINC, removing global attention leaves MAE unchanged; removing RWSE worsens it from 0.070 to 0.113. A few random-walk return probabilities do more than a whole global-attention layer.