Matcha: Mitigating Graph Structure Shifts with Test-Time Adaptation

Wenxuan Bao, Zhichen Zeng, Zhining Liu, Hanghang Tong, Jingrui He

TL;DR

Matcha is a novel test-time adaptation (TTA) framework designed to rescue Graph Neural Networks (GNNs) from "structure shifts"—changes in how nodes connect (e.g., degree or homophily) between training and deployment. By dynamically tuning how a model aggregates neighbor information using a new "Prediction-Informed Clustering" loss, Matcha restores the separability of node representations without needing any labels or access to the original training data.

The Challenge of Structure Shifts in Graphs

Graph Neural Networks are notoriously sensitive to distribution shifts. While researchers have developed Test-Time Adaptation (TTA) to help models adjust to new data on the fly, most existing methods were designed for computer vision, where samples are independent. In graphs, nodes are interconnected, introducing unique vulnerabilities.

The authors identify two distinct types of shifts in graphs:

  1. Attribute Shifts: Changes in node features (e.g., user profiles changing over time). This usually just shifts the decision boundary, which standard TTA can handle.
  2. Structure Shifts: Changes in connectivity patterns (e.g., moving from a professional network like LinkedIn to a casual one like Instagram).
Effect of distribution shifts on node representations

The critical discovery here is that structure shifts are significantly more damaging. As shown above, they don't just move the decision boundary; they actually "blur" the node representations, causing different classes to mix together in the embedding space. Standard TTA methods fail here because they assume the underlying representations remain high-quality.

The Matcha Framework

To fix these blurred representations, Matcha introduces two key innovations:

Matcha framework architecture
  • Adaptive Hop-Aggregation: Instead of retraining the entire GNN, Matcha focuses exclusively on the parameters ($\gamma$) that control how much information is pulled from different "hops" (immediate neighbors, neighbors-of-neighbors, etc.). By adjusting these, the model can dynamically decide to trust neighbors more in highly homophilic graphs, or trust them less if the structure has become noisy or heterophilic.
  • Prediction-Informed Clustering (PIC) Loss: Standard TTA often uses "entropy minimization," which can lead to trivial solutions where the model just becomes more confident in its wrong answers. Matcha’s PIC loss treats the model's soft predictions as "pseudo-classes." It minimizes the variance within those classes while maximizing the distance between them. This forces the model to "un-blur" the representations and push different categories apart in the embedding space.

Matcha is designed as a plug-and-play module. It seamlessly integrates with existing TTA methods (like Tent or T3A) to handle attribute and structure shifts simultaneously.

Experimental Setup and Key Insights

The authors evaluated Matcha on a mix of synthetic and real-world benchmarks, including the Contextual Stochastic Block Model (CSBM) for controlled testing, as well as modified real-world graphs like Syn-Cora, Syn-Products, Twitch-E, and OGB-Arxiv. They specifically tested "homo $\rightarrow$ hetero" shifts and "high $\rightarrow$ low" degree shifts.

Key Findings

  • The Representation Gap: The paper proves theoretically that structure shifts degrade the upstream featurizer. If features are already mixed together, classifier tuning alone cannot save the model; the aggregation process itself must be fixed.
  • Stability through Sparsity: By only updating the hop-aggregation parameters rather than the entire neural network backbone, Matcha avoids "model forgetting" and remains stable even with very few adaptation steps.
  • Efficiency: Because it only tunes a handful of parameters, Matcha is incredibly fast. It adds only about 11.9% overhead to standard inference time, whereas other graph-specific adaptation methods can slow down the process by 200% to 400%.
  • Accuracy Boost: When applied alone, Matcha improved source model performance by up to 31.95%. When integrated with existing TTA methods, the total boost reached 40.61%. It consistently outperformed specialized graph TTA baselines across almost all structure shift scenarios.
  • Scalability: Matcha scales linearly with the number of nodes, successfully running on graphs with up to 10 million nodes.

Limitations and Future Work

  • Initial Signal Requirement: Matcha assumes the pre-trained source model can produce some level of class-clustered representations. If the initial model is completely random or the signal-to-noise ratio is extremely low, the PIC loss might lack a good starting point to refine.
  • Task Scope: The current work focuses primarily on node classification. Future research could explore how these structural adaptation techniques apply to link prediction or graph-level classification.
  • Black-box Models: While Matcha works with many GNN architectures (e.g., GPRGNN, APPNP, JKNet), it requires access to the hop-aggregation parameters. It may not be directly applicable to strictly "black-box" proprietary models where only the final output is visible.

Summary updated

BibTeX
@inproceedings{bao2025matcha,
  author = {Wenxuan Bao and Zhichen Zeng and Zhining Liu and Hanghang Tong and Jingrui He},
  title = {{Matcha: Mitigating Graph Structure Shifts with Test-Time Adaptation}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=EpgoFFUM2q},
}
Figure