SwinGNN: Rethinking Permutation Invariance in Diffusion Models for Graph Generation

Qi Yan, Zhengyang Liang, Yang Song, Renjie Liao, Lele Wang

Abstract

Permutation-invariant diffusion models of graphs achieve the invariant sampling and invariant loss functions by restricting architecture designs, which often sacrifice empirical performances. In this work, we first show that the performance degradation may also be contributed by the increasing modes of target distributions brought by invariant architectures since 1) the optimal one-step denoising scores are score functions of Gaussian mixtures models (GMMs) whose components center on these modes and 2) learning the scores of GMMs with more components is often harder. Motivated by the analysis, we propose SwinGNN along with a simple yet provable trick that enables permutation-invariant sampling. It benefits from more flexible (non-invariant) architecture designs and permutation-invariant sampling. We further design an efficient 2-WL message passing network using the shifted-window self-attention. Extensive experiments on synthetic and real-world protein and molecule datasets show that SwinGNN outperforms existing methods by a substantial margin on most metrics.

Introduction

Generating graphs—from social networks to complex protein structures—is a notoriously difficult task for AI. One of the biggest hurdles is permutation invariance: a graph is the same regardless of how you label its nodes. Traditionally, researchers have built "invariant-by-design" models to solve this, but these models often struggle with performance.

In graph generation, we want our model to assign the same probability to two graphs if they are isomorphic (i.e., identical in structure but with different node orderings). To achieve this, most existing diffusion models use permutation-invariant architectures. However, these models often perform poorly on complex or large graphs. The authors identify a "hidden cost" to this approach: when you force a model to be invariant during training, you exponentially increase the number of "modes" (peaks) in the target probability distribution. Instead of learning one way to represent a graph, the model has to learn all $n!$ possible permutations.

The Mode Surge Hypothesis

The paper provides a theoretical and empirical investigation showing that invariant models fail because they are trying to learn a Gaussian Mixture Model (GMM) with $O(n!)$ more components than their non-invariant counterparts. This "mode surge" makes the learning task significantly harder, leading to the performance gaps seen in current state-of-the-art models like DiGress or GDSS.

Illustration of an invariant target distribution $p^*$ where all permutations $A_i$ have equal probability $1/n!$.

Non-invariant models achieve much higher "recall" on toy datasets because they can focus on a single, canonical orientation of the data during training, drastically simplifying the score function the model must learn.

Illustration of a non-invariant distribution $p$ focusing on a single mode $A_1$, significantly simplifying the learning task.

Methodology: SwinGNN

The authors propose a two-pronged solution:

1. The Invariance Trick

They prove (Lemma 4.2) that a model doesn't need to be invariant during training to produce an invariant distribution. You can train a powerful, non-invariant model and simply apply a random permutation to the nodes of the generated graph at the end. This "reclaims" invariant sampling without the training headache.

2. SwinGNN Architecture

With the freedom to use non-invariant designs, they built SwinGNN, inspired by the Swin Transformer but adapted for graphs.

  • 2-WL Message Passing: Most GNNs are "1-WL," updating node features based on neighbors. SwinGNN performs "2-WL" message passing, which operates on edges (node pairs). This is much more expressive but usually computationally expensive ($O(n^4)$).
  • Shifted-Window Attention: To make 2-WL scalable, SwinGNN treats the adjacency matrix like an image and applies self-attention within local windows. By shifting these windows between layers, the model achieves global "edge-to-edge" communication with only $O(n^2)$ complexity.
  • EDM Framework: The model uses the "Elucidating Diffusion Models" (EDM) framework, which provides better noise scheduling and sampling than standard DDPM approaches.

Experimental Results

SwinGNN was evaluated on synthetic (Ego-small, Community-small, 2D Grid), protein (DD), and molecule (QM9, ZINC250k) datasets. It outperformed existing methods across almost all metrics:

  • Structural Accuracy: On the Grid dataset, SwinGNN achieved a Degree MMD of 1.91e-7, compared to 3.78e-1 for the invariant GDSS model.
  • Scalability: It successfully generated protein-like graphs with up to 500 nodes, where previous diffusion models often failed.
  • Efficiency: SwinGNN trained 7x faster and performed inference 4x faster than DiGress on the grid dataset.
  • Chemical Validity: On ZINC250k, it achieved the best scores in chemical validity and neighborhood subgraph MMD (NSPDK).

Conclusion

SwinGNN demonstrates that relaxing architectural invariance constraints in favor of non-invariant training with post-generation shuffling leads to superior graph generation. By leveraging an efficient 2-WL message-passing scheme via shifted-window attention, SwinGNN provides a scalable and expressive framework for complex graph structures. Future work includes extending these insights to discrete diffusion frameworks and further scaling to graphs with thousands of nodes.

Summary updated

BibTeX
@article{yan2024swingnn,
  author = {Qi Yan and Zhengyang Liang and Yang Song and Renjie Liao and Lele Wang},
  title = {{SwinGNN: Rethinking Permutation Invariance in Diffusion Models for Graph Generation}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=abfi5plvQ4},
}
Figure