Standard Graph Neural Networks (GNNs) are built on local message-passing, where nodes only "talk" to their immediate neighbors. While efficient, this local focus leads to "over-smoothing" and "over-squashing," where long-range information is lost in the noise of the graph. Transformers offer a solution through global self-attention, allowing every node to attend to every other node. However, the $O(N^2)$ computational cost of standard attention makes them unusable for graphs beyond a few thousand nodes.
A new generation of Graph Transformers (GTs) overcomes this bottleneck by achieving linear complexity ($O(N)$). By reformulating how nodes interact, these models scale to graphs with millions—and even billions—of nodes while maintaining a global receptive field.
Breaking the Quadratic Barrier with Linear Attention
The core intuition behind linear-complexity GTs is that we can capture global dependencies without ever materializing the massive $N \times N$ pairwise attention matrix. In a standard Transformer, the softmax operation couples the queries ($Q$) and keys ($K$) in a way that forces a quadratic computation. Linear attention mechanisms, such as those used in the GPS (General, Powerful, Scalable) framework by Ladislav Rampásek and Michael Galkin, decouple this operation.
By using the associative property of matrix multiplication—computing $(K^T V)$ first instead of $(QK^T)$—the complexity drops from quadratic to linear relative to the number of nodes. Qitian Wu and colleagues demonstrated in SGFormer that even a single layer of this linear global attention can outperform deep, complex architectures on web-scale graphs, achieving up to a 141x inference speedup.
Structural Anchors and Sparse Expanders
Another way to achieve scalability is to restrict the "view" of each node to a representative subset of the graph. Rather than attending to every node, models can attend to "anchors" or follow specific topological paths that mimic global connectivity.
- Expander Graphs: Hamed Shirzad and Ali Kemal Sinop introduced Exphormer, which uses expander graphs—sparse graphs with high connectivity—to mediate attention. This allows information to flow across the entire network in a few steps while keeping the number of attention edges linear ($O(V+E)$).
- Structural Anchors: Models like AnchorGT, proposed by Wenhao Zhu and Liang Wang, identify a "k-dominating set" of nodes to act as global anchors. Every node attends to these anchors, which then broadcast information back to the rest of the graph, preserving a global receptive field at a fraction of the cost.
From Node-to-Node to Node-to-Token Attention
A third strategy shifts the attention mechanism from interacting between nodes to interacting between nodes and a latent "codebook" or set of polynomial tokens. This creates a bottleneck that forces the model to compress global information into a manageable space.
In GT-SVQ, Huizhe Zhang and Liang Chen use spiking neural networks to tokenize nodes into discrete "spike counts." By computing attention between nodes and these discrete tokens, they eliminate the $O(N^2)$ bottleneck entirely. Similarly, Jiahong Ma and Zhewei Wei developed PolyFormer, which restricts attention to a fixed number of "polynomial tokens" per node. This intra-node focus allows the model to learn unique spectral filters for every node while scaling linearly to datasets with over 100 million nodes.
Global Attention as Primal Optimization
Perhaps the most radical shift is reformulating the attention mechanism itself. Mingzhen He introduced Primphormer, which treats self-attention as an optimization problem in "primal space." By avoiding the construction of the pairwise matrix and solving the attention objective directly, Primphormer achieves $O(N)$ complexity while remaining as mathematically expressive as the 1-WL graph isomorphism test.
Why It Works: The Expressivity of Efficiency
The recurring theme across these papers is that global interaction does not require quadratic density. Whether through kernel approximations (GPS, SGFormer), sparse topologies (Exphormer), or latent bottlenecks (GT-SVQ, PolyFormer), these models prove that the essential "signal" of a graph can be captured through linear operations.
As Isaac Reid suggests in WIRE, the bottleneck for Transformers on graphs is often not the attention mechanism itself, but the lack of expressive structural priors. By combining linear attention with graph-aware encodings (like the Laplacian spectrum), researchers are finally enabling Transformers to handle the scale and complexity of real-world relational data, from drug discovery to billion-node social networks.