HopFormer: Sparse Graph Transformers with Explicit Receptive Field Control

Sanggeon Yun, Raheeb Hassan, Ryozo Masukawa, Sungheon Jeong, Mohsen ImaniarXiv 2026

TL;DR

HopFormer simplifies graph Transformers by completely eliminating complex positional encodings and dense global attention. By injecting structural bias exclusively through head-specific, $n$-hop sparse attention masks, it achieves state-of-the-art performance while ensuring computational costs scale linearly with mask sparsity.

What Problem Does This Paper Address?

Transformers have revolutionized sequence modeling, but adapting them to graphs is notoriously tricky. Because graphs are non-sequential and permutation-invariant, standard Transformers cannot inherently perceive graph topology.

To force-feed structural information into these models, current state-of-the-art Graph Transformers rely on two heavy-handed design choices:

  1. Explicit Positional/Structural Encodings (PE/SE): Handcrafted features like Laplacian eigenvectors, random-walk statistics, or shortest-path distances are injected into node embeddings or attention logits. These encodings are highly sensitive to tuning and often fail to generalize when test graphs differ in size or structure from training graphs.
  2. Dense Global Attention: Most models allow every node to attend to every other node. This incurs a prohibitive quadratic computational cost ($O(|V|^2)$), which becomes even worse ($O((|V|+|E|)^2)$) when edges are also treated as tokens. Furthermore, because real-world graphs often exhibit "small-world" properties (where local neighborhoods contain the most relevant information), dense global attention is frequently redundant.

The authors of HopFormer ask a fundamental question: Can we build an effective, efficient graph Transformer using only the simplest design principles of the vanilla Transformer?

Methods

HopFormer answers "yes" by introducing structural bias purely through attention masking, leaving the standard vanilla Transformer architecture completely untouched.

Figure 1: An illustration of the proposed edge-to-node augmentation, node–edge tokenization, and head-specific n-hop sparse attention mechanism.

The method relies on three elegant components:

  1. Edge-to-Node Augmentation: To seamlessly handle both node and edge features without complex architectural modifications (like cross-attention blocks), the input graph is converted into an augmented incidence graph. Every edge becomes an auxiliary "edge node" connected to its original endpoints. Node and edge attributes are then projected into a shared latent space using lightweight, modality-specific linear layers.
  2. Head-Specific $n$-Hop Sparse Attention: Instead of allowing global connectivity, each attention head $h$ is assigned a specific "hop budget" ($n_h$), which defines its maximum receptive field. The attention mask is computed as an $n_h$-hop reachability matrix derived directly from the graph topology.
  3. True Sparse Computation: Crucially, these masks are applied before attention score computation. This means the model only computes attention scores for valid pairs within the hop budget, achieving genuine sparse matrix operations where the computational cost scales as $O(\text{nnz}(M))$ rather than quadratically.

Datasets

The authors evaluated HopFormer across a comprehensive suite of standard benchmarks:

  • Node-level datasets: Citation networks (Cora, Citeseer, Pubmed), web graphs (Chameleon, Squirrel), co-occurrence graphs (Actor), and heterophilous university networks (Texas, Cornell, Wisconsin).
  • Graph-level datasets: Molecular property prediction (ZINC, OGBG-MolHIV, OGBG-MolPCBA) and long-range peptide benchmarks (Peptides-Func, Peptides-Struct).

Key Insights and Ideas

  • Encodings are Optional: Just as causal masking implicitly forces a sequential text Transformer to understand word order without explicit position embeddings, topology-aligned masking is sufficient to inject graph structure into a Transformer.
  • Multi-Scale Representation in a Single Layer: By assigning different hop budgets to different heads within the same layer (e.g., Head 1 looks 1 hop away, Head 2 looks 6 hops away), HopFormer can simultaneously capture local details and broader contextual features without increasing model depth.
  • The Illusion of Global Attention: The paper reveals that for graphs with strong small-world properties, localized, sparsity-controlled attention actually yields more stable and consistently high performance. On graphs with weaker small-world effects, global attention provides diminishing returns, making the quadratic cost rarely worth it.

Key Results

  • Competitive and Superior Accuracy: Despite its structural simplicity, HopFormer matches or outperforms state-of-the-art graph Transformers that use complex encodings. It achieved the top overall performance on OGBG-MolHIV (0.7997 AUC) and Peptides-Struct (0.2503 MAE).
  • True Linear Scalability: The authors empirically validated that HopFormer's forward-pass FLOPs scale linearly with the number of non-zero entries ($\text{nnz}$) in the attention masks. This allows researchers to explicitly trade receptive field size for computational efficiency.
  • Robustness Across Structural Regimes: Unlike competing models whose performance rankings fluctuate wildly depending on the dataset's clustering coefficient or average path length, HopFormer maintains a consistently high rank across all structural variations.

Limitations and Future Work

While HopFormer demonstrates excellent empirical results, the authors note a couple of limitations:

  • Empirical Hop Budgets: The relationship between a graph's inherent small-world properties and its optimal head-specific hop budgets remains primarily empirical. A deeper theoretical characterization is needed.
  • Manual Hyperparameter Tuning: Currently, the hop budgets ($n_h$) for each head are fixed hyperparameters that must be searched manually. The authors point to automatic selection or dynamic learning of these $n$-hop configurations as a promising direction for future work.

Summary updated

BibTeX
@misc{yun2026hopformer,
  author = {Sanggeon Yun and Raheeb Hassan and Ryozo Masukawa and Sungheon Jeong and Mohsen Imani},
  title = {{HopFormer: Sparse Graph Transformers with Explicit Receptive Field Control}},
  year = {2026},
  eprint = {2602.02268},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.02268},
}
Figure