Matcha: Mitigating Graph Structure Shifts with Test-Time Adaptation

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

TL;DR

Graph Neural Networks (GNNs) frequently fail when deployed on new graphs with different connectivity patterns, a problem known as graph structure shift. To solve this without needing access to original training data or target labels, Matcha introduces a test-time adaptation framework that dynamically tunes GNN hop-aggregation parameters. By minimizing a novel prediction-informed clustering loss, Matcha restores the distinct boundaries between node categories, significantly boosting accuracy under severe distribution shifts.

What Problem Does This Paper Address?

Test-Time Adaptation (TTA) has become a popular paradigm for adapting pre-trained models to unlabeled target domains on the fly. However, existing TTA methods were primarily built for computer vision, where data points are independent and shifts usually happen in the attributes (e.g., a change in lighting or style).

Graphs are a different beast. Nodes are interconnected, meaning distribution shifts can happen both in node attributes and in the graph's structure—such as changes in average node degree or homophily (the tendency of similar nodes to connect).

The authors reveal that attribute shifts and structure shifts affect GNNs in fundamentally different ways. While attribute shifts merely bias the downstream classifier's decision boundary, structure shifts degrade the upstream featurizer itself. This causes node representations from different classes to completely blend together in the latent space, rendering standard vision-based TTA methods ineffective.

Generic TTA algorithms struggle under structure shifts (homophily and degree) compared to attribute shifts, but Matcha significantly recovers performance.

Methods

To combat structure shifts, the authors propose Matcha (Mitigate grAph sTruCture sHifts with test-time Adaptation). Instead of updating all model weights—which can lead to catastrophic forgetting—Matcha selectively tunes the hop-aggregation parameters ($\gamma$). These parameters dictate how much a GNN weighs a node's own features versus information propagated from 1-hop, 2-hop, or $K$-hop neighbors.

Figure 3: Our proposed framework of Matcha (when combined with GPRGNN)

To guide this adaptation without ground-truth labels, Matcha introduces a Prediction-Informed Clustering (PIC) loss. Standard TTA methods typically minimize entropy, but the authors show that entropy minimization fails on graphs because it simply scales up logit magnitudes without actually separating overlapping clusters. The PIC loss directly optimizes the latent space by minimizing intra-class variance and maximizing inter-class variance using soft pseudo-labels provided by a base TTA method.

Datasets

The framework was evaluated using both synthetic and real-world benchmarks:

  • CSBM (Contextual Stochastic Block Model): Synthetic graphs used to precisely control and isolate homophily, degree, and attribute shifts.
  • Syn-Cora & Syn-Products: Graph benchmarks modified to exhibit severe homophily shifts (moving from a source homophily of 0.8 to a target homophily of 0.2).
  • Twitch-E & OGB-Arxiv: Real-world social and citation networks where subsets of homophilic edges were deleted to inject realistic structural shifts.

Key Insights and Ideas

  • The "Why" Behind GNN TTA Failure: As visualized below, attribute shifts shift the data but keep classes separable. Structure shifts destroy the featurizer, smashing the two class distributions together. Histograms showing how structure shifts mix class distributions together, unlike attribute shifts.

  • Why Entropy Fails: For a linear classifier, simply multiplying the weights by a large constant drives entropy to zero without changing the decision boundary or fixing overlapping representations. This is why a ratio-based clustering loss (like PIC) is required.

  • Synergy with Existing TTA: Matcha is plug-and-play. It can be wrapped around existing TTA algorithms (like Tent or T3A). While the base TTA handles the attribute shifts, Matcha fixes the structural shifts.
Histograms showing how structure shifts mix class distributions together, unlike attribute shifts.

Key Results

  • Substantial Accuracy Gains: When applied alone, Matcha enhances the baseline source model performance by up to 31.95%. When integrated with existing TTA methods, it boosts their performance by up to 40.61%.
  • High Efficiency: Unlike other graph TTA methods (like GTrans or SOGA) that introduce massive computational overhead (247% to 486% extra time), Matcha only adds an extra 11.9% computation time per epoch relative to standard inference. This efficiency stems from only calculating gradients for the tiny vector of hop-aggregation parameters ($\gamma$).
  • Robustness to Noise: Matcha successfully converges and improves accuracy even when the initial pseudo-labels from the unadapted model are highly noisy.

Limitations and Future Work

The authors note that Matcha relies on a key assumption: the source model must be capable of learning class-clustered representations on the source graph in the first place. If a graph dataset has an extremely low signal-to-noise ratio, Matcha's accuracy improvements cannot be guaranteed. Additionally, the current work focuses primarily on node classification; extending this framework to link prediction or graph-level classification remains an open avenue for future research.

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