Graph-Mamba: Towards Long-Range Graph Sequence Modeling with Selective State Spaces

Chloe Wang, Oleksii Tsepa, Jun Ma, Bo WangarXiv 2024 · DOI

Introduction

Graph Transformers have emerged as a powerful tool for capturing long-range dependencies in graph-structured data. By utilizing self-attention, these models can relate any two nodes regardless of their distance in the graph. However, this global connectivity comes at a steep price: the quadratic computational complexity ($O(N^2)$) of self-attention makes scaling to large graphs nearly impossible. Graph-Mamba addresses this bottleneck by integrating Selective State Space Models (SSMs), specifically the Mamba architecture, into the Graph Neural Network (GNN) pipeline.

The Scaling Challenge in Graph Transformers

While local Message Passing Neural Networks (MPNNs) excel at capturing neighborhood structures, they struggle with "over-squashing" when information must travel across many hops. Graph Transformers solve this by providing a direct path between all nodes. Yet, for a graph with thousands of nodes, the attention matrix becomes prohibitively large for standard GPU memory. Previous attempts to sparsify attention often rely on heuristics that may overlook critical, distant interactions.

Methodology: The Graph-Mamba Framework

Graph-Mamba is built upon the modular GraphGPS framework, replacing the standard global attention layer with a specialized Graph-Mamba Block (GMB).

Overview of the Graph-Mamba architecture, including the Graph-Mamba Block (GMB) and node prioritization strategy.

The Graph-Mamba Block (GMB)

The GMB leverages Mamba’s selective scan mechanism to propagate information with linear complexity ($O(N)$). Unlike traditional RNNs or Transformers, Mamba uses a data-dependent gating mechanism to decide which information to retain or discard as it processes a sequence. This allows the model to perform "informed sparsification," focusing only on relevant nodes.

Node Prioritization and Serialization

A significant challenge in applying Mamba to graphs is that Mamba is designed for sequences, while graphs are unordered sets. The authors introduce a Node Prioritization strategy based on node degrees to linearize the graph structure.

Detailed view of graph flattening, degree-based node prioritization, and the selective scan mechanism in the Mamba module.

Because Mamba is a recurrent scan, nodes later in the sequence have access to a richer "context" from all previous nodes. By sorting nodes by their degree, high-degree "hub" nodes—which are often structurally central—are placed at the end of the sequence to maximize their contextual awareness. To prevent overfitting to a specific order, the model employs permutation-based training, shuffling nodes with identical degrees and averaging multiple permutations during inference.

Experimental Results

Graph-Mamba was evaluated on the Long-Range Graph Benchmark (LRGB) and several standard GNN benchmarks, demonstrating significant improvements in both performance and efficiency.

  • State-of-the-Art Performance: The model achieved top-tier results on tasks like PascalVOC-SP, where it improved the F1 score to 0.4191 compared to 0.3446 for Exphormer.
  • Efficiency Gains: On the MalNet-Tiny dataset, Graph-Mamba demonstrated linear scaling. Compared to standard Graph Transformers, it achieved a 74% reduction in GPU memory and a 66% reduction in FLOPs.
  • Scalability: While Transformers often encounter Out-of-Memory (OOM) errors on graphs exceeding 700 nodes, Graph-Mamba successfully processed graphs twice that size without significant overhead.

Conclusion

Graph-Mamba represents a significant step forward in efficient graph modeling. By successfully adapting sequence-based Selective State Space Models to graph structures through intelligent node ordering, it provides a scalable alternative to Graph Transformers. This approach maintains the ability to capture long-range dependencies while drastically reducing the computational burden, opening the door for deep learning on massive, complex graph datasets.

Summary updated

BibTeX
@misc{wang2024graph,
  author = {Chloe Wang and Oleksii Tsepa and Jun Ma and Bo Wang},
  title = {{Graph-Mamba: Towards Long-Range Graph Sequence Modeling with Selective State Spaces}},
  year = {2024},
  eprint = {2402.00789},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.00789},
}
Figure