Abstract
Recently, transformers have shown promising performance in learning graph representations. However, there are still some challenges when applying transformers to real-world scenarios due to the fact that deep transformers are hard to train from scratch and the quadratic memory consumption w.r.t. the number of nodes. In this paper, we propose Graph Masked Autoencoders (GMAEs), a self-supervised transformer-based model for learning graph representations. To address the above two challenges, we adopt the masking mechanism and the asymmetric encoder-decoder design. Specifically, GMAE takes partially masked graphs as input, and reconstructs the features of the masked nodes. The encoder and decoder are asymmetric, where the encoder is a deep transformer and the decoder is a shallow transformer. The masking mechanism and the asymmetric design make GMAE a memory-efficient model compared with conventional transformers. We show that, when serving as a conventional self-supervised graph representation model, GMAE achieves state-of-the-art performance on both the graph classification task and the node classification task under common downstream evaluation protocols. We also show that, compared with training in an end-to-end manner from scratch, we can achieve comparable performance after pre-training and fine-tuning using GMAE while simplifying the training process.
Introduction
Graph Convolutional Networks (GCNs) have long been the standard for graph data. However, they face significant limitations, primarily the "over-smoothing" problem. As more layers are added, node representations tend to become indistinguishable, restricting GCNs to capturing only local neighborhood information.
Transformers offer a compelling alternative by using self-attention to capture global dependencies. Yet, their application to graphs is hindered by two main issues: quadratic memory consumption ($O(n^2)$) relative to the number of nodes and the difficulty of training deep architectures from scratch. The Graph Masked Autoencoder (GMAE) is proposed to overcome these hurdles by leveraging a "mask-and-reconstruct" paradigm inspired by successes in NLP and Computer Vision.
Methods
GMAE utilizes a self-supervised approach to learn robust graph representations. The architecture is built on three main components:
- Random Masking: A significant portion (typically 50% to 70%) of node features is randomly hidden. This forces the model to learn from the remaining context and the underlying graph structure.
- Asymmetric Encoder-Decoder: This is the pivotal innovation for efficiency. The Encoder is a deep Transformer that processes only the unmasked nodes. Since it operates on a fraction of the data, the $O(n^2)$ memory cost is drastically reduced. The Decoder is a shallow Transformer that receives the encoder's output, inserts "mask tokens" for the missing nodes, and reconstructs the original features.
- Graphormer Backbone: To incorporate structural information, GMAE adopts positional embeddings (centrality, spatial, and edge encoding) from the Graphormer architecture.
By masking 70% of nodes, the encoder only handles 30% of the data. Since memory usage scales quadratically, processing 30% of nodes utilizes approximately 9% of the memory required by a full-graph Transformer. This "efficiency loophole" enables the training of much deeper models on larger graphs.
Key Results
The authors evaluated GMAE across graph classification (7 benchmarks), node classification (6 benchmarks), and molecular property prediction (ZINC dataset).
- Performance: GMAE achieved state-of-the-art results, outperforming baselines like GraphCL and InfoGraph on the majority of classification tasks. On the ZINC dataset, GMAE reached a Mean Absolute Error (MAE) of 0.120, surpassing the standard Graphormer (0.122) and significantly outperforming GCNs and GATs.
- Memory Efficiency: Empirical results confirm that GMAE significantly reduces memory usage compared to conventional Graph Transformers. As shown in the figure below, the memory savings become more pronounced as the number of nodes increases.
Conclusion
GMAE demonstrates that masking and asymmetry are powerful tools for scaling Graph Transformers. By focusing the heavy computation on a subset of nodes and using a shallow reconstruction head, GMAE achieves high performance with reduced resource requirements. Future work may explore structural masking (e.g., masking edges) and techniques to further mitigate the $O(n^2)$ bottleneck for web-scale graphs.
Summary updated