Accurate and Scalable Graph Neural Networks via Message Invariance

Zhihao Shi, Jie Wang, Zhiwei Zhuang, Xize Liang, Bin Li, Feng Wu

Abstract

Message passing-based graph neural networks (GNNs) have achieved great success in many real-world applications. For a sampled mini-batch of target nodes, the message passing process is divided into two parts: message passing between nodes within the batch (MP-IB) and message passing from nodes outside the batch to those within it (MP-OB). However, MP-OB recursively relies on higher-order out-of-batch neighbors, leading to an exponentially growing computational cost with respect to the number of layers. Due to the neighbor explosion, the whole message passing stores most nodes and edges on the GPU such that many GNNs are infeasible to large-scale graphs. To address this challenge, we propose an accurate and fast mini-batch approach for large graph transductive learning, namely topological compensation (TOP), which obtains the outputs of the whole message passing solely through MP-IB, without the costly MP-OB. The major pillar of TOP is a novel concept of message invariance, which defines message-invariant transformations to convert costly MP-OB into fast MP-IB. This ensures that the modified MP-IB has the same output as the whole message passing. Experiments demonstrate that TOP is significantly faster than existing mini-batch methods by order of magnitude on vast graphs (millions of nodes and billions of edges) with limited accuracy degradation.

Introduction: The Challenge of Neighbor Explosion

Training Graph Neural Networks (GNNs) on massive graphs is a significant computational hurdle. Standard GNNs rely on a recursive message-passing mechanism where a node's representation is updated based on its neighbors. In a mini-batch training setting, computing the embedding for a single target node requires information from its immediate neighbors. These neighbors, in turn, require information from their neighbors in the previous layer.

This leads to the "neighbor explosion" problem: as the number of layers increases, the number of nodes involved in the computation grows exponentially. For deep GNNs on dense graphs, a single mini-batch can eventually require loading almost the entire graph into memory, making training on large-scale datasets like OGBN-Papers100M (with over 100 million nodes and 1.6 billion edges) impossible on standard hardware.

Existing Solutions and Their Trade-offs

Researchers have traditionally addressed this using two main strategies:

  1. Sampling Methods: Techniques like GraphSAGE or neighbor sampling pick a fixed number of neighbors at each layer. While this bounds the computation, the "explosion" still occurs, albeit at a slower rate, and the recursive fetching of out-of-batch (OB) nodes remains a bottleneck.
  2. Subgraph Sampling: Methods like Cluster-GCN or GraphSAINT restrict computation entirely to nodes within the mini-batch (In-Batch or IB nodes). This is extremely fast and memory-efficient because it ignores all out-of-batch messages ($MP_{OB}$). However, this "missing information" leads to significant accuracy drops, as the model loses the global context of the graph.

Topological Compensation (TOP) via Message Invariance

The proposed Topological Compensation (TOP) framework aims to achieve the speed of subgraph sampling without sacrificing the accuracy of full-graph message passing. The core innovation is the concept of Message Invariance. The authors observe that messages from out-of-batch nodes ($MP_{OB}$) are not entirely independent of the messages already present within the batch ($MP_{IB}$). Instead, they hypothesize that $MP_{OB}$ can be represented as a transformation of $MP_{IB}$.

Comparison of GNN training paradigms: (a) Original GNNs with costly out-of-batch message passing, (b) Subgraph sampling which loses information, and (c) TOP which uses topological compensation to recover missing information.

How TOP Works

Instead of fetching data for OB neighbors, TOP calculates a "compensation" term. It treats the out-of-batch messages as a linear combination of in-batch messages.

  • Linear Estimation: The framework solves for a coefficient matrix $R$ such that $H_{OB} \approx R H_{IB}$. This allows the model to approximate the influence of the entire graph using only the nodes in the current mini-batch.
  • The Random Initialization Trick: A key challenge is estimating $R$ without knowing the final node embeddings. The authors discovered that the structural properties of the graph can be captured by passing random noise through the GNN architecture. By using a GNN with randomly initialized weights as a "hash function," they can pre-calculate the compensation matrix $R$ in a single preprocessing step.
  • Modified Adjacency: During training, TOP uses a modified adjacency matrix that incorporates these "virtual" weighted edges. This allows the GNN to run solely on IB nodes while mathematically accounting for the missing OB messages.

Experimental Results

The authors evaluated TOP across a wide range of benchmarks, from medium-sized datasets like Reddit to the massive Ogbn-papers100M.

Speed and Scalability

TOP demonstrates remarkable efficiency. On the Ogbn-products dataset, it achieved an 11x speedup over GAS, a state-of-the-art historical embedding method. Most impressively, TOP enabled the training of deep GNNs on the 1.6 billion edge Ogbn-papers100M dataset using only a single consumer-grade RTX 2080 Ti GPU. Many baseline methods simply ran out of memory (OOM) on this scale.

Accuracy and Stability

Despite being an approximation, TOP maintains high performance. On Ogbn-products, a TOP-enhanced GCNII model reached 81.96% accuracy, significantly outperforming Cluster-GCNII (79.62%). Furthermore, TOP showed much lower variance across training runs compared to other subgraph-based methods, indicating a more stable and reliable learning process.

Conclusion

Topological Compensation (TOP) offers a scalable path forward for GNNs on massive graphs. By leveraging message invariance, it effectively "compresses" the global graph structure into local mini-batch updates. While currently focused on linear approximations in transductive settings, the principles of TOP open new avenues for efficient graph representation learning without the burden of neighbor explosion.

Reference: Shi, Z., Wang, J., et al. (2025). Accurate and Scalable Graph Neural Networks via Message Invariance. ICLR 2025.

Summary updated

Abstract

Message passing-based graph neural networks (GNNs) have achieved great success in many real-world applications. For a sampled mini-batch of target nodes, the message passing process is divided into two parts: message passing between nodes within the batch (MP-IB) and message passing from nodes outside the batch to those within it (MP-OB). However, MP-OB recursively relies on higher-order out-of-batch neighbors, leading to an exponentially growing computational cost with respect to the number of layers. Due to the neighbor explosion, the whole message passing stores most nodes and edges on the GPU such that many GNNs are infeasible to large-scale graphs. To address this challenge, we propose an accurate and fast mini-batch approach for large graph transductive learning, namely topological compensation (TOP), which obtains the outputs of the whole message passing solely through MP-IB, without the costly MP-OB. The major pillar of TOP is a novel concept of message invariance, which defines message-invariant transformations to convert costly MP-OB into fast MP-IB. This ensures that the modified MP-IB has the same output as the whole message passing. Experiments demonstrate that TOP is significantly faster than existing mini-batch methods by order of magnitude on vast graphs (millions of nodes and billions of edges) with limited accuracy degradation.
BibTeX
@inproceedings{shi2025accurate,
  author = {Zhihao Shi and Jie Wang and Zhiwei Zhuang and Xize Liang and Bin Li and Feng Wu},
  title = {{Accurate and Scalable Graph Neural Networks via Message Invariance}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=UqrFPhcmFp},
}
Figure