Test-Time Graph Recalibration: Enhancing Robust Zero-Shot Inference for Graph Foundation Models

Chunchun Chen, Zhen Luo, Xing Wei, Yuxing Zhang, Xiaofeng Cao, Rui Fan, Ambuj Singh, Wei YeNeurIPS 2026

TL;DR

Graph foundation models are surprisingly fragile: a few strategically placed bogus connections can completely derail their zero-shot predictions, and retraining them to defend against new attacks is prohibitively expensive. This paper introduces TRACE, a training-free "immune system" that diagnoses tampered subgraphs on the fly and surgically rewires them back to sanity right at test time. By pairing spectral signal processing with text-guided semantic anchors, it restores accuracy on poisoned graphs without touching the underlying model weights—or hurting performance on clean data.

What Problem Does This Paper Address?

Just as vision-language models like CLIP revolutionized image understanding, Graph Foundation Models (GFMs) are bringing zero-shot generalization to Text-Attributed Graphs (TAGs)—networks where nodes carry rich text, like academic papers in a citation network or products in an e-commerce web.

However, neural networks on graphs have an Achilles' heel: topological attacks. In high-security domains like finance or healthcare, an attacker might not be able to hack into a database to alter a user's profile (node features), but they can easily inject fake interactions or hide real ones (perturbing edges). Even minor structural tweaks can trick a GFM into misclassifying a node.

Figure 1: Empirical case study of adversarial attack and anti-attack recalibration on the CiteSeer dataset. The clean ego-graph, labeled Machine Learning, maintains intrinsic structural-semantic consistency. Topological attacks add noise edges, forcing misclassification as Database. Our framework proactively recalibrates via reverse optimization to prune adversarial edges and restore the correct semantic prediction.

Traditional defenses fall into two camps: cleaning the graph beforehand (purification) or adversarial training. Both rely on the training phase. For massive GFMs deployed in zero-shot settings, retraining is way too expensive, and static defenses crumble when faced with unfamiliar attack patterns at test time. Furthermore, blindly applying graph-cleaning algorithms to every input often strips away useful connections in clean data. We need a defense that works dynamically during inference, without ground-truth labels, and only intervenes when necessary.

Methods

Enter TRACE (Test-time gRaph recAlibration for enhancing robust zero-shot inferenCE). Keeping the pre-trained GFM completely frozen, TRACE operates on localized subgraphs around a target node (ego-graphs) in three clever stages:

Figure 2: Overview of the TRACE framework, which includes three components: spectral entropy diagnosis, fine-grained text generation, and anti-attack optimization. It separates adversarial from clean ego-graphs through the spectral entropy. For adversarial ego-graphs, LLM-generated fine- grained texts serve as the real uniform distribution on a hypersphere. Then, anti-attack optimization pulls the adversarial ego-graph G toward its original text attribute Tori and pushes it away from negative clusters, yielding a recalibrated ego-graph ˆ︁G. Finally, the graph embedding is aligned with label text embeddings via cosine similarity for zero-shot classification.
  1. The Diagnostic Trigger (Smoothed Spectral Entropy): Before fixing anything, TRACE checks if the ego-graph is actually broken. It applies a one-step graph smoothing filter—averaging each node's features with its neighbors'—and runs Singular Value Decomposition (SVD) on the result to measure normalized spectral entropy ($H \in [0, 1]$). In clean graphs, connected nodes usually share similar topics, yielding a correlated, low-entropy matrix. Attacks connect clashing topics, injecting high-frequency spatial noise that spikes entropy. If $H$ crosses a threshold ($\tau = 0.7$), TRACE sounds the alarm; otherwise, the clean graph passes through untouched.
  2. Uniformity-Guided Anti-Attack Objective: Once an adversarial graph is flagged, where do we steer it without test-time labels? TRACE uses an LLM to generate 100 fine-grained text descriptions per class, mapping them via a frozen text encoder onto a unit hypersphere as a uniform "clean manifold" prior. It then optimizes an objective with three forces: pushing the graph embedding away from its current poisoned state, pulling it toward the target node's original text attribute, and spreading it uniformly across the LLM-generated semantic clusters (an InfoNCE contrastive setup).
  3. Sparse Edge Flipping via Feature Gradient Proxy: Rewiring a discrete graph is combinatorial, and modern sparse graph encoders can't backpropagate gradients through non-existent edges (doing so densely requires $\mathcal{O}(N^2)$ memory). As a clever workaround, TRACE differentiates the objective with respect to the continuous input node features instead. Taking the inner product between a node's feature gradient and a potential neighbor's feature vector gives an instant first-order score for every possible edge. TRACE simply adds the highest-scoring missing edges and drops the lowest-scoring existing ones within a set budget.

Datasets

TRACE builds on the pre-trained GraphCLIP checkpoint (trained on ogbn-arxiv, Arxiv-2023, PubMed, ogbn-products, and Reddit). To ensure a true zero-shot evaluation, the authors test on ten completely unseen datasets—no new benchmarks are introduced, but existing ones are split into two distinct stress tests:

  • Standard Benchmarks (5): Cora, CiteSeer, WikiCS, History, and Children.
  • Heterophilous Graphs (5): Texas, Cornell, Washington, Wisconsin, and Actor—tricky networks where connected nodes naturally belong to different classes.

Key Insights and Ideas

  • Adversarial Attacks Cause "Variance Collapse": As attack intensity grows, spectral entropy doesn't just shift upward on average—its variance shrinks dramatically. Natural subgraphs have diverse structural complexities, whereas attacks force them into a uniform, cramped state of maximum disorder, making them surprisingly easy to spot without training a detector. Violin plots showing spectral entropy rising and narrowing (variance collapse) as attack perturbation rates increase.

  • Text Semantics Cure Homophily Bias: Standard graph defenses assume homophily (birds of a feather flock together), causing them to fail on heterophilous graphs where dissimilar nodes connect naturally. Because TRACE anchors its optimization in frozen language semantics rather than blind neighborhood similarity, it thrives even when local topology is naturally inverted.

  • Continuous Feature Gradients Unlock Sparse Topology Edits: Substituting inaccessible latent structural gradients with input feature gradients lets you score missing edges on the fly, sidestepping the $\mathcal{O}(N^2)$ dense-matrix bottleneck of classic adversarial defenses.
Figure 3: Quantitative analysis of spectral entropy H under PGD [31] and PRBCD [33] attacks. Violin plots visualize the distribution of H across varying perturbation rates, i.e., the greater the attack, the greater the mean entropy. The transition from broad, low-entropy distributions to concentrated, high-entropy distributions serves as a diagnostic basis for identifying adversarial graphs.

Key Results

Evaluated under PGD and PRBCD topological attacks (from 10% to 40% edge perturbation budgets), TRACE consistently outperforms self-supervised baselines (DGI, BGRL, G2P2) and leading GFMs (GraphGPT, OFA, ZeroG, GraphCLIP):

  • Resilience Under Heavy Fire: Under a severe 40% PRBCD attack on the History dataset, GraphCLIP's zero-shot accuracy plunges from 52.3% (clean) to 32.6%, while TRACE holds strong at 37.9% (and 46.4% average across all noise levels vs. GraphCLIP's 42.5%). On CiteSeer, TRACE boosts average robust accuracy from 54.9% to 60.3%.
  • Preserving Clean Data: Because selective entropy filtering skips unperturbed graphs, TRACE avoids "over-purifying" clean samples, matching or slightly edging out GraphCLIP on clean accuracy across all benchmarks (e.g., 66.4% vs. 65.7% on CiteSeer).
  • Crushing Heterophily: Across the five noisy heterophilous datasets, TRACE achieves a state-of-the-art 32.4% average zero-shot accuracy, jumping nearly 6 percentage points over GraphCLIP (26.6%) and more than doubling Wisconsin's accuracy from 11.3% to 26.4%.

Limitations and Future Work

  • Backbone Generalizability: Although TRACE is theoretically model-agnostic, all empirical evaluations in this paper rely on a single GFM backbone (GraphCLIP with a GraphGPS encoder). Validating whether this recalibration transfers smoothly to other open-source GFM architectures remains an open step.
  • Clean-vs-Robust Trade-off: Sensitivity analyses show that setting the entropy trigger $\tau = 0.7$ introduces a slight accuracy dip on purely unperturbed samples in exchange for major gains under attack.
  • Future Directions: The authors plan to test TRACE across a broader suite of open-source foundation models and expand the test-time recalibration paradigm to more generalized adversarial defense scenarios (such as beyond purely topological ego-graph attacks).

Summary updated

Abstract

This work investigates robust graph learning within graph foundation models. Prior studies primarily rely on data-centric structural purification or adversarial augmentation during training to achieve robustness. However, in practical zero-shot inference, such methods remain vulnerable to unseen adversarial structures because of static defenses and prohibitive retraining costs. We propose Test-time gRaph recAlibration for enhancing robust zero-shot inferenCE (TRACE). TRACE selectively learns a structural anti-attack directly on noisy graphs during inference, neutralizing adversarial perturbations while preserving clean-graph performance. Specifically, TRACE introduces a non-parametric diagnostic metric based on smoothed spectral entropy to quantify structural-semantic misalignment induced by adversarial attacks, providing an adaptive recalibration trigger. Furthermore, a uniformity-guided objective leverages semantic anchors from pretrained text encoders to guide the distorted graph back to the clean manifold. To ensure efficiency for sparse graph encoders, a first-order gradient-based edge-flipping strategy reconstructs the optimal graph structure directly in the discrete domain. Extensive experiments across benchmark datasets and graph attacks demonstrate TRACE's superiority over state-of-the-art baselines.
BibTeX
@inproceedings{chen2026test,
  author = {Chunchun Chen and Zhen Luo and Xing Wei and Yuxing Zhang and Xiaofeng Cao and Rui Fan and Ambuj Singh and Wei Ye},
  title = {{Test-Time Graph Recalibration: Enhancing Robust Zero-Shot Inference for Graph Foundation Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=2vn2dWrcD4},
}
Figure