TL;DR
The Graph Transformer SParsification (GTSP) framework is the first comprehensive attempt to make Graph Transformers (GTs) efficient by pruning them across four dimensions: input nodes, attention heads, model layers, and weights. Remarkably, GTSP doesn't just save on compute—it can actually improve performance, such as achieving a 1.8% accuracy boost on the OGBG-HIV dataset while slashing FLOPs by 30%.
What Problem Does This Paper Address?
Graph Transformers have emerged as a powerful alternative to standard Graph Neural Networks (GNNs), particularly for graph-level tasks like molecular classification. However, they come with a heavy "tax": the Multi-Head Attention (MHA) mechanism has a quadratic computational complexity relative to the number of nodes.
While pruning techniques exist for standard GNNs, they don't translate well to GTs. GNN pruning usually focuses on node classification and edge removal. In contrast, GTs are often used for graph classification, where the number of input nodes is the primary bottleneck. Furthermore, the architectural differences—like the heavy use of attention heads and deep stacks of layers—require a specialized sparsification strategy. The authors tackle this "resource-intensity" problem to make GTs viable for resource-constrained environments.
Methods
The authors introduce GTSP, a mask-based pruning framework that targets four specific areas of redundancy:
- Pruning Tokens (Nodes): Not all nodes in a graph contribute equally to the final prediction. GTSP uses a learnable "token selector" (powered by a GCN) to assign importance scores to nodes. To keep the process differentiable for end-to-end training, they employ the Gumbel-Softmax trick to decide which nodes to keep or drop.
- Pruning Attention Heads: By analyzing head redundancy using metrics like Jensen-Shannon distance, the authors found many heads do the same thing. They calculate an importance score based on the model's sensitivity to each head and prune the least significant ones. They also include a "regrowth" mechanism to reactivate heads if their gradients become high again.
- Pruning Layers: Deep GTs often suffer from "over-smoothing," where node representations become indistinguishable. GTSP uses a random drop-layer approach (stochastic depth) during training to identify and remove redundant layers, effectively shortening the network without losing expressive power.
- Pruning Weights: Following the "lottery ticket" philosophy, GTSP identifies and removes small-magnitude weights. They use a gradual pruning schedule and a gradient-based regrowth scheme to ensure that important connections aren't lost permanently during early training phases.
Datasets
The framework was evaluated on three prominent graph classification benchmarks:
- NCI1: A small-scale dataset of chemical compounds.
- OGBG-HIV: A large-scale dataset from the Open Graph Benchmark (OGB) focused on predicting HIV virus inhibition.
- OGBG-Molpcba: Another large-scale OGB dataset involving molecular properties.
The authors tested GTSP across three different state-of-the-art GT architectures: GraphTrans, Graphormer, and GraphGPS.
Key Insights and Ideas
- The "Less is More" Paradox: In several cases, pruning actually improved accuracy. For example, weight pruning (GTSP-WP) at 50% sparsity outperformed the baseline. This suggests that sparsification acts as a form of regularization, preventing the model from over-fitting on noisy graph data.
- Specialized Attention Roles: Visualization revealed that different attention heads naturally specialize. Some focus on "long-range" dependencies (distant nodes), while others focus on "neighbors." Pruning allows the model to keep only the most functional "specialists."
- Breaking the Depth Limit: Standard GTs often see performance nose-dive as they get deeper (e.g., 48 layers) due to over-smoothing. GTSP’s layer pruning helps mitigate this, allowing deep models to maintain high accuracy where the baseline fails.
- Prioritizing Motifs: When pruning nodes, the model doesn't just pick at random. It tends to preserve critical chemical motifs (like specific functional groups) while discarding redundant structures like simple benzene rings, enhancing the model's interpretability.
Key Results
- Efficiency vs. Accuracy: On the OGBG-HIV dataset, GTSP achieved a 1.8% increase in ROC-AUC while reducing Floating Point Operations (FLOPs) by 30%.
- Parameter Reduction: For the GraphTrans model, GTSP-WP (Weight Pruning) maintained baseline performance while using only 50% of the parameters and roughly 30% of the FLOPs.
- Head Pruning: The authors successfully reduced the number of attention heads by 50% with a negligible performance hit (and sometimes a 0.5% improvement), proving significant architectural redundancy in current GT designs.
Limitations and Future Work
The primary limitation noted is that the current study prunes each component (nodes, heads, layers, weights) individually to analyze their specific impacts. The authors acknowledge that "joint pruning"—optimizing all four dimensions simultaneously—is a complex challenge due to the intricate interactions between these components.
Future work will likely focus on automated ways to adjust pruning ratios dynamically for different graph structures and exploring the synergy between these different sparsification dimensions.
Summary updated