Abstract
Graph Transformers (GTs) have emerged as a powerful tool for capturing long-range dependencies in graph data. However, their application to large-scale node classification is limited by the $O(n^2)$ computational complexity of self-attention and the performance degradation caused by aggregating noise from irrelevant distant nodes. We introduce Gapformer, a novel architecture that incorporates graph pooling into the Transformer framework. By compressing the graph into a compact set of "pooling nodes" that serve as attention targets, Gapformer reduces complexity to $O(n)$ while effectively filtering noise and preserving global context. Our extensive evaluation on 13 real-world datasets shows that Gapformer achieves state-of-the-art results, particularly on heterophilic graphs, while maintaining linear scalability.
Introduction: The Scalability and Noise Bottleneck
Graph Neural Networks (GNNs) typically rely on local message-passing, which can lead to issues like over-smoothing and an inability to capture long-range dependencies. Graph Transformers (GTs) address this by allowing every node to attend to every other node, providing a global receptive field.
Despite their theoretical advantages, GTs struggle with node-level tasks on large graphs for two primary reasons:
- Quadratic Complexity: Standard self-attention scales at $O(n^2)$ with respect to the number of nodes $n$. On large graphs, this leads to prohibitive memory requirements and Out-Of-Memory (OOM) errors.
- Noisy Aggregation: In massive graphs, most distant nodes are irrelevant to a specific target node. Dense attention forces the model to aggregate information from these noisy sources, which can degrade classification accuracy.
Methodology: Attention Enhanced with Graph Pooling (AGP)
Gapformer addresses these challenges by replacing standard dense self-attention with the Attention Enhanced with Graph Pooling (AGP) mechanism. The core idea is to use graph pooling as an information bottleneck, summarizing the graph before performing attention.
The AGP Mechanism
In a standard Transformer, attention is computed between all queries ($Q$) and all keys/values ($K, V$). In Gapformer, the keys and values are first passed through a graph pooling operation, compressing $n$ nodes into a fixed, much smaller number of $n'$ "pooling nodes." The original nodes then only attend to these pooled summaries. This reduces the attention complexity to $O(n'n)$, which is linear in $n$.
Global vs. Local Pooling
Gapformer supports two main variants of pooling:
- AGP-G (Global Graph Pooling): The entire graph is compressed into a few global pooling nodes. Every node in the graph queries these summaries to gain global context.
- AGP-L (Local Graph Pooling): A $k$-hop subgraph is extracted around each node and pooled into local summaries.
To ensure that local topological features are preserved, Gapformer combines this pooled attention with standard local message-passing. The balance between global and local information is controlled by a tunable parameter.
Experimental Results
The authors evaluated Gapformer on 13 real-world datasets, including 9 homophilic graphs (e.g., Cora, Pubmed, ogbn-arxiv) and 4 heterophilic graphs (e.g., Cornell, Actor).
Accuracy and Robustness
Gapformer outperformed or matched 20 state-of-the-art baselines. A significant finding was its superior performance on heterophilic graphs. Standard GTs often perform poorly in these settings; Gapformer’s ability to summarize global structure helps it avoid being misled by direct, dissimilar neighbors.
Linear Scalability
Synthetic benchmarks confirmed that Gapformer’s time and memory usage scale linearly ($O(n)$). While vanilla GTs failed on graphs with more than a few thousand nodes, Gapformer easily handled the 169,000-node ogbn-arxiv dataset, demonstrating its readiness for large-scale applications.
The Role of Pooling and FFNs
Ablation studies revealed that trainable pooling methods (like SAGPool) are more effective than simple Mean or Max pooling. Interestingly, the authors found that removing the Feed-Forward Network (FFN) module improved performance on some datasets, suggesting that standard Transformer blocks may be over-parameterized for certain graph tasks.
Conclusion and Future Directions
Gapformer provides a scalable and noise-robust alternative to standard Graph Transformers for node classification. By utilizing graph pooling to create a structural summary of the graph, it achieves a global receptive field with linear complexity. Future research will explore more efficient implementations of local pooling and the potential for combining global and local pooling strategies to further enhance performance on massive-scale graphs.
Summary updated