Source-linked AI summary
SGFormer: Simplifying and Empowering Transformers for Large-Graph Representations
Qitian Wu, Wentao Zhao, Chenxiao Yang, Hengrui Zhang, Fan Nie, Haitian Jiang, Yatao Bian, Junchi Yan
TL;DR
Learning effective representations on large graphs under tight computation budgets remains challenging. SGFormer explores a single-layer global attention model; across node-property benchmarks it achieves highly competitive performance, scales to 0.1B-node ogbn-papers100M, and reports up to 37x/141x training/inference speedups over scalable Transformers on medium-sized graphs.
Problem
Learning effective node representations on large graphs under limited time and memory budgets remains challenging, motivating reassessment of deep attention designs.
Source: §1 · pp. 1–2Method
Results
37x/141x training/inference speedups over scalable Transformers on medium-sized graphs accompany highly competitive node-property benchmark results and scaling to 0.1B-node ogbn-papers100M.
Source: §1 · p. 2Takeaways & Limitations
The findings support reassessing whether deep attention is needed for large-graph representation learning.
Source: §1 · p. 2, §7 · p. 10The work assumes training and testing data come from the same distribution, leaving out-of-distribution generalization as a future direction.
Source: §7 · p. 10
Abstract
from arXiv · showhide
Learning representations on large-sized graphs is a long-standing challenge due to the inter-dependence nature involved in massive data points. Transformers, as an emerging class of foundation encoders for graph-structured data, have shown promising performance on small graphs due to its global attention capable of capturing all-pair influence beyond neighboring nodes. Even so, existing approaches tend to inherit the spirit of Transformers in language and vision tasks, and embrace complicated models by stacking deep multi-head attentions. In this paper, we critically demonstrate that even using a one-layer attention can bring up surprisingly competitive performance across node property prediction benchmarks where node numbers range from thousand-level to billion-level. This encourages us to rethink the design philosophy for Transformers on large graphs, where the global attention is a computation overhead hindering the scalability. We frame the proposed scheme as Simplified Graph Transformers (SGFormer), which is empowered by a simple attention model that can efficiently propagate information among arbitrary nodes in one layer. SGFormer requires none of positional encodings, feature/graph pre-processing or augmented loss. Empirically, SGFormer successfully scales to the web-scale graph ogbn-papers100M and yields up to 141x inference acceleration over SOTA Transformers on medium-sized graphs. Beyond current results, we believe the proposed methodology alone enlightens a new technical path of independent interest for building Transformers on large graphs.
1 Introduction
SGFormer challenges the need for deep attention for large-graph representation learning, proposing a simple one-layer model and reporting competitive performance, faster runtimes, and a theoretical account of its expressive power.
1 Introduction
- Large-graph node representation learning must work under tight time and space budgets, while single-graph node tasks often have few labels, increasing large Transformers’ overfitting risk.The introduction contrasts these tasks with small-graph settings that typically offer abundant labeled graph instances.Source: §1 · pp. 1–2
- Global attention can capture implicit inter-node dependencies absent from graph structure, supporting Transformer expressivity and strong performance on small-graph applications [3] [31].The cited examples include graph-level and node-level tasks.Source: §1 · p. 2
- Vision- and language-inspired designs stack deep multi-head attention [8] [2] [9], while all-pair attention costs quadratic time and space and the computation graph grows exponentially with layers [35] [5].These costs make training deep Transformers on million-node graphs resource-intensive and may require partitioning nodes into mini-batches.Source: §1 · p. 2
- SGFormer uses one single-head attention layer with linear node scaling to learn exact all-pair interactions, requiring no positional encodings, preprocessing, extra losses, or edge embeddings.The model is framed as a simplified Graph Transformer.Source: §1 · p. 2
- 37x/141x training/inference speedups over scalable Transformers on medium graphs accompany SGFormer’s highly competitive performance against powerful GNNs and state-of-the-art graph Transformers.It performs competitively across twelve benchmarks and scales to ogbn-papers100M (0.1B nodes), two orders of magnitude beyond prior graph-Transformer demonstrations.Source: §1 · p. 2
- A one-layer attention model can match multi-layer attention’s denoising effect and contribute to steepest descent, supporting its capacity to learn global information from all-pair interactions.The paper connects the Transformer layer to a signal-denoising problem with a specific optimization objective.Source: §1 · p. 2
2 Preliminary and Related Work
The section frames graph representation learning as producing useful node embeddings from partially labeled graphs that may range from thousands to billions of nodes. It contrasts local GNN aggregation with global graph attention, whose scalability and modeling choices pose challenges on large graphs.
Preliminary
- Graph representation learning seeks useful node embeddings from partially labeled graphs, whose node count can range from thousands to billions.The graph is defined by nodes, features, labels, and a usually sparse symmetric adjacency matrix; only a small subset of nodes is labeled.Source: §2 · p. 2
Graph Neural Networks
- GNNs recursively aggregate neighboring-node embeddings, but computation graphs can grow exponentially with depth, motivating sampling, partitioning, and historical-embedding techniques.Common GCN and GAT models use first-order neighbors; other approaches use distillation or MLPs to accelerate inference or training.Source: §2 · p. 3
Graph Transformers
- Global graph attention captures long-range dependencies through all-pair interactions, but its O(N^2) cost generally limits Transformers to graphs of up to hundreds of nodes.Sampling nodes or using ego-graph features can support larger graphs but sacrifices expressivity for interactions among arbitrary nodes.Source: §2 · p. 3
- Linear-complexity attention approaches include kernelized Gumbel-Softmax with random-feature approximation and a non-local diffusion operator that models all-pair interactions without approximation.Source: §2 · p. 3
- Deep multi-head attention architectures pose scaling challenges on billion-node graphs and may overfit when labeled nodes are scarce relative to the graph [19].The section notes that most Transformer models follow deep-layer designs used in vision and language tasks [8] [2] [9].Source: §2 · p. 3
3 Simplifying and Empowering Transformers on Large Graphs
SGFormer pairs a single linear-complexity global attention layer with a GNN output component to model dependencies among arbitrary nodes efficiently. Its sparse-graph complexity and mini-batch strategy support scaling to large graphs.
Simple Global Attention
- SGFormer’s global attention captures implicit dependencies between arbitrary nodes with linear complexity.The model maps input features to latent node embeddings before attention; one layer can propagate information to arbitrary nodes through its densely connected attention graph.Source: §3 · p. 3
- O(N) attention combines all-pair propagation with a self-loop, versus O(N^2) for original Transformer Softmax attention, while retaining all-pair expressivity.The attention uses shallow query, key, and value layers and a residual-link hyperparameter β.Source: §3 · p. 4
Incorporation of Structural Information
Complexity Analysis
- O(N + E) overall complexity lets SGFormer scale linearly with graph size when graphs are sparse, while its one-layer attention and simple GNN keep the model lightweight.The GNN contributes O(E), and sparse graphs typically have E ≪ N^2.Source: §3 · p. 4
Scaling to Larger Graphs
- Random mini-batch partitioning enables training on graphs too large for full-batch single-GPU processing, and linear attention supports larger batches for global interactions.The method is also compatible with neighbor sampling, graph clustering [7], and historical embeddings [12], which the authors leave for future exploration.Source: §3 · p. 4
4 Comparison with Existing Models
SGFormer simplifies graph Transformers while retaining all-node attention with linear complexity, enabling use on graphs ranging from thousands of nodes to web scale.
Architectures
- Unlike models using positional embeddings, augmented losses, preprocessing, and deep multi-head stacks, SGFormer uses none of these additions and only one single-head global-attention layer.Positional preprocessing can have complexity up to O(N^3), while augmented losses may complicate optimization.Source: §4 · p. 5
Expressivity
Scalability
- 0.1B-node ogbn-papers100M is within SGFormer’s single-GPU training scale, two orders of magnitude beyond the largest demonstrations of NodeFormer and DIFFormer.SGFormer supports full-batch training up to 0.1M nodes and mini-batch training with large batch sizes on larger graphs, with negligible performance impact.Source: §4 · p. 5
- SGFormer’s linear complexity supports full-batch training on large graphs, whereas most existing graph Transformers have O(N^2) complexity and neighbor sampling can reduce performance.Large-batch mini-batch training lets SGFormer capture global information on larger graphs with negligible performance impact.Source: §4 · p. 5
5 Empirical Evaluation
Across medium- and large-sized node-prediction benchmarks, SGFormer’s one-layer global attention performs competitively while scaling to very large graphs. The evaluation also examines its efficiency and the effects of model depth and attention components.
5.1 Results on Medium-sized Graphs
- SGFormer beats standard GNNs by up to 25.9% over GCN on actor and is highly competitive with advanced GNNs and graph Transformers.Its gains over standard GNNs are generally more pronounced on heterophilic graphs; the authors suggest global attention can filter spurious neighbors and accommodate informative disconnected nodes. Graphormer and GraphTrans overfit, while SGFormer’s lighter architecture generalizes better with limited labels.Source: Table 2 · p. 6, §5.1 · pp. 6–7
5.2 Results on Large-sized Graphs
- SGFormer outperforms GNN competitors and NodeFormer across five large-graph datasets, and reaches 66.0 testing accuracy on ogbn-papers100M.On ogbn-papers100M, training takes about 3.5 hours and 23.0 GB of memory on a single GPU.Source: Table 3 · p. 7, §5.2 · pp. 7–8
5.3 Efficiency and Scalability
- SGFormer is 38x/141x faster in training/inference than Graphormer on cora, 20x/30x faster than NodeFormer on pubmed, and 2x/4x faster on Amazon2M.The comparisons report training time per epoch and inference time; SGFormer’s simple global attention also reduces memory costs relative to quadratic-attention models.Source: Table 4 · p. 7, §5.3 · p. 8
- On Amazon2M subsets of 10K–100K nodes, SGFormer’s time and memory scale linearly; at 40K nodes, Softmax attention runs out of memory while SGFormer uses 1.5GB.The scalability test uses a hidden size of 256 for all models.Source: Figure 2 · p. 7, §5.3 · p. 8
5.4 Further Discussions
- Adding SGFormer attention layers brings no considerable performance boost, can hurt actor results, and increases training time; one layer remains highly competitive.One-layer attention also performs decently for NodeFormer and SGFormer variants in quite a few cases, though NodeFormer is unsatisfactory on ogbn-proteins; deeper SGFormer without self-loop propagation degrades, indicating that self-loop propagation helps preserve competitiveness at depth.Source: Figure 3 · p. 8, Figure 4 · p. 8, §5.4 · pp. 8–9
6 Theoretical Justifications
The section interprets one-layer attention as a graph-signal denoising step and argues that it can reproduce the global-information aggregation of any multi-layer attention model. This equivalence suggests that stacking layers may add redundancy rather than a distinct denoising effect.
6 Theoretical Justifications
- The analysis frames one Transformer layer as an optimization step for graph-signal denoising, combining initial node features with information absorbed from other nodes.The objective balances local and global smoothness, with λ as the trading-weight parameter; the update is equivalent to gradient descent with step size τ 2λ.Source: §6 · p. 9
- For any K-layer attention model, a single-layer attention model can produce the same global-information aggregation.The theorem states that one gradient-descent step can match the K-layer model from its initial embeddings.Source: §6 · p. 10
- Because multi-layer attention optimizes layer-dependent objectives while one-layer attention pursues a fixed objective in one steepest-descent step, multiple layers may be redundant.The discussion presents this as a consequence of the equivalence between multi-layer and one-layer attention.Source: §6 · p. 10
7 Conclusions and Outlooks
The conclusion presents one-layer attention with a vanilla GCN as a competitive, scalable approach to large-graph representation learning, and identifies out-of-distribution learning and task-specific graph applications as future directions.
7 Conclusions and Outlooks
- SGFormer combines one-layer attention with a vanilla GCN for highly competitive node-property prediction, scales to 0.1B nodes, and achieves 30x acceleration over state-of-the-art Transformers on medium-sized graphs.The paper also provides theoretical justification for the methodology.Source: §7 · p. 10
- Because the work assumes training and testing data share a distribution, future work could study graph Transformers for out-of-distribution generalization and sample detection.The conclusion notes that testing data may come from previously unseen distributions.Source: §7 · p. 10
- Beyond benchmark representation learning, future work could explore graph Transformers in recommender systems, circuit designs [6], and combinatorial optimization [28], which require task-dependent designs.The paper leaves these application settings for future exploration.Source: §7 · p. 10
A Proof for Technical Results · A.1 Proof for Theorem 1 · A.2 Proof for Theorem 2
The proofs connect Transformer layer updates to gradient descent on smoothness-based objectives, then show that any K-layer attention model can be represented by a single gradient-descent step. The second proof constructs that equivalence by composing layer-wise propagation matrices.
A.1 Proof for Theorem 1
- Theorem 1’s layer update is equivalent to gradient descent on a cost function with step size τ 2λ.The parameter λ trades off local and global smoothness.Source: §A.1 · p. 16
- Normalization of the attention scores makes the gradient-descent update coincide with the Transformer layer update in Eqn. 5.Source: §A.1 · p. 16
A.2 Proof for Theorem 2
- Theorem 2 states that for any positive integer K, a constructed C* makes one gradient-descent step from the initial embeddings reproduce a K-layer model’s output.Source: §A.2 · p. 16
- The proof defines a propagation matrix P(k) for each layer and rewrites Eqn. 5 in propagation form.Source: §A.2 · pp. 16–17
- Stacking the K layer-wise propagations yields Z(K) = P*Z(0), where P* is the product of the layer propagation matrices.Source: §A.2 · p. 17
- The proof constructs C* from P* so that a denoising-problem gradient step with step size τ* induces the K-layer output embeddings.Source: §A.2 · p. 17
B Dataset Information
The experiments use 12 publicly available real-world datasets for node property prediction, with dataset information summarized in Table 5. The datasets span citation, heterophilic, social, biological, and large-scale graphs, with task-specific labels and evaluation splits.
- Experiments cover 12 publicly available real-world datasets for node property prediction, summarized in Table 5.The paper identifies Table 5 as the location of dataset information.Source: B Dataset Information · p. 17, Table 5 · p. 17
- Cora, Citeseer, and Pubmed are citation networks with bag-of-words features, paper-topic labels, and 20-per-class training, 500 validation, and 1,000 test examples [23].Source: B Dataset Information · p. 18
- Actor classifies actors into five categories from Wikipedia keywords and co-occurrence links; it is a low-homophily, heterophilic graph.Source: B Dataset Information · p. 18
- Squirrel and Chameleon classify Wikipedia pages into five traffic-based groups; they are heterophilic, and evaluation uses the split that removes train-test overlap.Source: B Dataset Information · p. 18
- Deezer-Europe predicts user gender from liked-artist features with a 50%/25%/25% split, while Pokec predicts gender from profile features using a 10%/10%/80% split [42] [32].Source: B Dataset Information · p. 18
- Ogbn-proteins uses 8-dimensional edge features to predict 112 protein functions across proteins from eight species, with the public OGB split [19].Source: B Dataset Information · p. 18
- Ogbn-arxiv predicts 40 subject areas from 128-dimensional paper features, using a chronological train/validation/test split by publication year [19].Source: B Dataset Information · p. 18
- Amazon2M predicts product top-level categories from description features using a 50%/25%/25% random split [33].Ogbn-papers100M is a nearly largest-public-benchmark web-scale graph with 111 million paper nodes, about 1.5 million labeled papers, 172 subject areas, and the public OGB split [19].Source: B Dataset Information · pp. 18–19
C Implementation Details … C.3 Hyper-parameters
The implementation uses a one-layer global attention module alongside a graph convolution network, with training procedures matched to graph scale and validation-based grid search for hyper-parameters.
C.1 Model Architectures
- The implementation comprises an input layer, global attention, a GNN, and an output layer.The input is a one-layer MLP with nonlinear activation that maps X ∈RN×D to latent embeddings Z(0) ∈RN×d; the output layer maps ZO ∈RN×d to predicted labels.Source: §C.1 · p. 19
- SGFormer combines one-layer global attention with graph convolution outputs as ZO = (1 −α)Z + αGN(Z(0), A).A one-layer MLP maps input features to latent node embeddings, and a feed-forward output layer predicts labels using cross-entropy or mean-square-error loss.Source: §C.1 · p. 19
C.2 Training Details
- For relatively small graphs (1K to 0.1M nodes), training uses the full graph; larger graphs use mini-batches.Full-graph training computes attention across all nodes, while mini-batch training extracts each batch's induced subgraph and computes loss on its training nodes, following.Source: §C.2 · p. 19
- Mini-batch inference uses whole-graph CPU evaluation for ogbn-proteins, Amazon2M, and pokec, but 0.4M-node batches for ogbn-papers100M.Batch sizes are 10K for ogbn-proteins, 0.1M for Amazon2M, 0.1M for pokec, and 0.4M for ogbn-papers100M; the evaluation pipeline for the first three follows [19].Source: §C.2 · p. 19
- Evaluation uses 300 epochs for medium graphs, 1000 for large graphs, and 50 for ogbn-papers100M, reporting the mean and variance over five trials.The selected model is the one with the highest validation result, whose testing accuracy is used for evaluation.Source: §C.2 · pp. 19–20
C.3 Hyper-parameters
- Hyper-parameters for all models, including competitors, are selected on validation data, generally by grid search over learning rate, weight decay, hidden size, dropout, and layer count.The respective search spaces are {0.001, 0.005, 0.01, 0.05, 0.1}, {1e −5, 1e −4, 5e −4, 1e −3, 1e −2}, {32, 64, 128, 256}, {0, 0.2, 0.3, 0.5}, and {1, 2, 3}.Source: §C.3 · p. 20
- SGFormer fixes global attention at one layer and searches 1–3 GCN layers with α in {0.5, 0.8}.Other model-specific searches include attention heads for GAT, hop counts for SGC and SIGN, embedding dimensions for Graphormer, and model-specific parameters for APPNP, JKNet, CPGNN, GloGNN, GraphTrans, and NodeFormer.Source: §C.3 · p. 20
D More Empirical Results
SGFormer’s visualized global attention differs from input graphs and reveals influential information-source nodes, suggesting learned patterns useful for prediction and interpretation.
D More Empirical Results
- SGFormer’s attention graphs differ from input graphs, and the learned patterns are informative for downstream prediction.The attention matrices are visualized across different datasets in Figure 6.Source: D More Empirical Results · p. 20, Figure 6 · p. 21
- Because SGFormer uses one-layer attention, its attention scores can be used to interpret influence among samples.Source: D More Empirical Results · p. 20
- Sharp lines in the attention heat maps mark nodes assigned large weights as important information sources, akin to influential network hubs.Source: D More Empirical Results · p. 20, Figure 6 · p. 21
Related papers
This paper cites
- Attention Is All You Need2017
- BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding2018
- Language Models are Few-Shot Learners2020
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale2020
- Semi-Supervised Classification with Graph Convolutional Networks2016
- Open Graph Benchmark: Datasets for Machine Learning on Graphs2020