A Unified Invariant Learning Framework for Graph Classification

Yongduo Sui, Jie Sun, Shuyao Wang, Zemin Liu, Qing Cui, Longfei Li, Xiang Wang

TL;DR

Graph Neural Networks (GNNs) frequently fail when deployed in real-world scenarios where the test data distribution shifts from the training data. This paper introduces Unified Invariant Learning (UIL), a framework that achieves robust out-of-distribution (OOD) generalization by enforcing both semantic invariance in embedding space and structural invariance in graph space. By leveraging graphons to align and stabilize the underlying generative patterns of causal subgraphs across different environments, UIL successfully filters out deceptive, spurious correlations.

What Problem Does This Paper Address?

Standard GNNs operate under the assumption that training and testing data are independently and identically distributed (i.i.d.). When this assumption is violated—such as evaluating a molecular property predictor on molecules with completely novel scaffolds—performance plummets.

To combat this, researchers turn to invariant learning. The goal is to isolate "stable features" (causal subgraphs that directly determine the label) from "environmental features" (spurious correlations). However, most existing methods only enforce invariance within the semantic space (the graph embeddings), as shown in Figure 1.

Figure 1: The workflow of several prevalent methods grounded in invariant graph learning.

The authors point out a critical flaw in this approach: if certain environmental features happen to remain constant across training environments, semantic-only models will mistakenly treat them as stable features. When the model encounters true OOD data where these "stable-environmental" features finally change, it fails. To find the minimal stable features (the true causal core), we need a way to enforce structural consistency directly within the graph space.

Methods

The Unified Invariant Learning (UIL) framework bridges this gap by combining two distinct invariance principles:

  1. Stable & Environmental Feature Separator: UIL uses a GNN-based encoder coupled with Multi-Layer Perceptrons (MLPs) to generate soft node and edge masks. These masks split the input graph into an estimated stable subgraph ($\hat{g}_{st}$) and an environmental subgraph ($\hat{g}_{en}$).
  2. Structural Invariance via Graphons: To constrain the graph space, the authors turn to graphons—non-parametric mathematical objects that represent the limit of a sequence of graphs and capture their underlying generative topology. UIL estimates a stable graphon for each graph class across different environments and minimizes the cut distance between them. This forces the feature separator to only select subgraphs that share a globally consistent structural pattern.
  3. Semantic Invariance: Simultaneously, the extracted stable features are passed to a GNN encoder and classifier. UIL ensures that predictions remain invariant across environments by mixing stable representations from one graph with environmental representations from others. If environment labels are missing, UIL infers them using K-means clustering on the environmental embeddings.

The overall architecture is unified into a joint optimization objective balancing classification accuracy, mask regularization, structural invariance, and semantic invariance, as illustrated in Figure 2.

Figure 2: The overview of the proposed Unified Invariant Learning (UIL) framework.

Datasets

The authors evaluated UIL on both synthetic and real-world OOD benchmarks:

  • Synthetic: SYN-b, SYN5 (a newly curated dataset with varying numbers of stable parts to test structural complexity), Motif, and CMNIST (Color MNIST superpixel graphs).
  • Real-World: Molhiv and Molbbbp from the Open Graph Benchmark (OGB) and GOOD benchmarks, featuring distribution shifts based on molecular size and scaffold structure.

Key Insights and Ideas

  • The Deception of Semantic Invariance: Embedding spaces are highly flexible. A model can easily map structurally disparate, non-causal subgraphs to similar embeddings if they happen to correlate with the label during training, highlighting why semantic-only constraints fail.
  • Graphons as Structural Anchors: By lifting discrete graph structures into the continuous graphon space, UIL gains a mathematically rigorous way to align and compare the topological distributions of subgraphs across entirely different environments.
  • The Power of Synergy: Ablation studies revealed that enforcing structural invariance alone or semantic invariance alone often performs worse than standard Empirical Risk Minimization (ERM). They must be used together: semantic invariance filters out unstable environmental noise, while structural invariance prevents the model from latching onto stable but non-causal environmental features.

Key Results

UIL consistently outperformed state-of-the-art graph generalization and data augmentation methods across the board:

  • Superior Average Performance: Across all tested datasets, UIL achieved an average accuracy/AUC of 70.90%, outperforming standard ERM (66.11%) and strong baselines like CAL (65.92%) and GREA (66.78%).
  • Massive Gains on CMNIST: On the highly biased CMNIST dataset, UIL achieved 35.68% accuracy, a massive jump over ERM (28.60%) and the best baseline, DIR (33.20%).
  • Precision in Causal Extraction: Qualitative visualizations confirmed that UIL's masks accurately pinpointed ground-truth causal subgraphs (like the specific house or grid motifs) while completely ignoring random environmental noise.

Limitations and Future Work

While UIL marks a significant step forward, the authors note a couple of limitations:

  • Node Feature Neglect in Graphons: The graphon estimation step focuses heavily on structural topology (adjacency matrices) and largely neglects complex, high-dimensional node features.
  • Computational Overhead: Estimating graphons and calculating cut distances adds complexity. UIL's training time is roughly 1.5 to 2 times longer than a standard baseline GNN, though it remains highly competitive with other advanced invariant learning frameworks like CAL.

Future work could involve extending the graphon framework to naturally incorporate rich node attributes.

Summary updated

BibTeX
@inproceedings{sui2025unified,
  author = {Yongduo Sui and Jie Sun and Shuyao Wang and Zemin Liu and Qing Cui and Longfei Li and Xiang Wang},
  title = {{A Unified Invariant Learning Framework for Graph Classification}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2025},
  url = {https://openreview.net/forum?id=0KoTX9AvdW},
}
Figure