Diffusion-warm sampling of the XY model enables fast thermalization at scale

Sehmimul Hoque, Roger G Melko, Pooya Ronagh

TL;DR

Simulating continuous-spin physical systems at scale usually requires agonizingly slow Monte Carlo runs from scratch. By training a diffusion model on tiny $20 \times 20$ spin grids and using its output as a "warm start" for much larger systems, researchers cut the time required to reach physical equilibrium by an entire order of magnitude. It turns out generative AI doesn't need to know the exact global physics—it just needs to get traditional algorithms into the right neighborhood.

What Problem Does This Paper Address?

Imagine a massive 2D grid of tiny compass needles, each free to point in any continuous angle from $0$ to $2\pi$, nudging its neighbors to align. In condensed matter physics, this is the 2D XY model—a foundational playground for understanding magnetism, superfluids, and superconductors.

To study these systems at a given temperature, physicists need independent snapshots of the grid in thermal equilibrium (Gibbs sampling). The gold standard is Markov Chain Monte Carlo (MCMC), specifically using cluster-flipping "Wolff steps." The catch? Starting from a random jumble of angles, MCMC suffers from brutal "thermalization times"—the burn-in period needed to reach equilibrium. At low temperatures, long-range correlations lock the system into tricky energy landscapes, causing thermalization time to scale exponentially with grid size.

Pure machine learning approaches haven't cracked this either: neural networks trained on small grids accumulate exponentially growing errors when asked to generate larger grids, and data-free variational methods frequently suffer from mode collapse.

Methods

Instead of trying to replace MCMC, the authors build a launchpad for it, introducing diffusion-warmed MCMC.

Figure 2: The figure shows the whole pipeline of diffusion-warmed MCMC. Random configurations are passed through the reverse diffusion process at a given temperature. The colourbar represents the spin values between −π to π. The reverse diffusion process applies the stochastic differential equation sequentially from t = 1 to t = 0 as shown in the top left panel. k steps of Wolff MCMC are then applied on diffusion-warmed samples. The top right panel shows one step of Wolff MCMC where a cluster is first formed and then all the spins in the cluster are reflected across a random direction. The highlighted spins in the image show the spins belonging in the cluster. The last row demonstrates the full pipeline at β = 1 for a 60 × 60 system. Here reverse diffusion is done for 500 steps using the model trained at 20 × 20 and k is chosen to be 30 for Wolff MCMC.

Here is how the hybrid pipeline marries standard physics simulation with generative AI:

  • Toroidal Diffusion: Because spin angles wrap around at $2\pi$, a $L \times L$ grid lives on a hypertorus. The authors use a standard Variance Exploding Stochastic Differential Equation (SDE) framework adapted so the forward noising process converges to a uniform angle distribution rather than a Gaussian.
  • Size-Agnostic Score Network: The denoising network is built from Convolutional Neural Networks (CNNs) with periodic convolutions (matching the XY model's periodic boundaries) and sine-cosine embeddings for angle periodicity. Because CNN filters slide across grids of any dimension, a network trained on $20 \times 20$ grids can natively run inference on $100 \times 100$ grids. Global rotational symmetry is handled by zero-meaning sample angles during training and applying a random global rotation after generation.
  • Temperature Conditioning: Using Classifier-Free Guidance (CFG), a single model learns to generate configurations across a continuous range of inverse temperatures ($\beta = 1/T$), using an annealed guidance schedule that increases alignment strength as temperatures drop.
  • The MCMC Polish: After generating a large grid via 500 reverse diffusion steps, the authors run a handful of traditional Wolff MCMC steps (e.g., 20 to 40 steps) to iron out long-range physical inaccuracies.

Datasets

There are no external benchmark datasets here; data is generated via physics simulations of the 2D XY model:

  • Training Data: Equilibrium configurations of small $20 \times 20$ lattices generated across a grid of 11 inverse temperatures ranging from $\beta = 0.5$ to $\beta = 1.6$ (spanning across the critical phase transition temperature $T_c = 0.89$, or $\beta_c \approx 1.12$).
  • Evaluation Data: Ground-truth observables (energy, magnetization, heat capacity, helicity modulus, and spin-spin correlations) obtained via long, fully thermalized Wolff MCMC runs starting from 1,000 random configurations on larger lattices ($40 \times 40$ up to $100 \times 100$).

Key Insights and Ideas

  • Why Zero-Shot Size Extrapolation Fails Physics: A diffusion model trained on a $20 \times 20$ periodic grid physically cannot learn spin waves with wavelengths longer than the box itself, nor can it avoid artificial wrap-around correlations beyond 10 lattice sites. Consequently, raw diffusion outputs on $50 \times 50$ grids underestimate spin correlations at low temperatures and overestimate them at high temperatures.
  • Local Accuracy is Enough for a Warm Start: Even though raw diffusion misses global thermodynamic properties (like the helicity modulus, which measures system-wide stiffness against a twist), it nails the local spin neighborhoods. Giving Wolff MCMC a locally plausible state bypasses almost the entire random-walk burn-in phase.
  • Beating Naive Tiling: Simply copy-pasting $20 \times 20$ patches to make a bigger grid introduces harsh boundary artifacts and severely underestimates long-range correlations compared to CNN-based diffusion extrapolation.

Key Results

Convergence and runtime speedup of diffusion-warmed MCMC

Figure 1: The figure demonstrates samples generated from the diffusion model provide an efficient warm start for MCMC, substantially reducing the thermalization time required to reach equilibrium configurations in large XY model systems. The diffusion model was trained on 20 × 20 XY model samples on a grid of temperatures ranging from β = 0.5 to β = 1.6. Left panel: Energy per spin (blue) and helicity modulus (purple) compared against MCMC steps for randomly initialized samples (solid lines) versus samples initialized from the trained diffusion model (dashed lines) for a 60 × 60 system at β = 1.5. The system initialized using the diffusion samples thermalizes in very few MCMC steps, demonstrating that the diffusion samples are a very good warm start for MCMC. The dashed vertical lines show the steps when the observables initialized in the two different ways converge. Right panel: Total runtime for thermalization at different temperatures across the phase transition plotted against system size for pure MCMC and the diffusion-warmed MCMC method. The thermalization time reported for the Diffusion-warmed MCMC method is the sum of (1) time taken by the diffusion model to generate the samples and (2) time taken for Wolff MCMC steps until the samples are thermalized. The shaded area represents the standard deviation error bars in thermalization time. In the diffusion-warmed MCMC method, the trained diffusion model is used to do inference starting from random configurations and then a few steps of MCMC are done until thermalization (see section A for details on computing thermalization time). This demonstrates approximately one order of magnitude speedup in thermalization time using diffusion-warmed MCMC method compared to the pure MCMC method.
  • 10x Speedup: Across system sizes from $60 \times 60$ to $100 \times 100$ and temperatures spanning the phase transition ($\beta = 0.8, 1.0, 1.5$), diffusion-warmed MCMC reduces total wall-clock thermalization time—including diffusion inference overhead—by roughly one order of magnitude compared to pure Wolff MCMC.
  • Rapid Observable Correction: On a $50 \times 50$ lattice, applying just 20 to 40 Wolff MCMC steps completely eliminates the long-range spin-spin correlation errors left behind by the $20 \times 20$-trained diffusion model. Similarly, expected energy and helicity modulus on $40 \times 40$ and $60 \times 60$ grids snap onto ground-truth curves within 30 MCMC steps.
Figure 4: The figure demonstrates that a small number of Wolff MCMC updates is sufficient to correct the spin-spin correlations of samples generated by the diffusion model for a 50×50 system. The lines labeled diffusion-warmed MCMC (20) and diffusion-warmed MCMC (40) represent the spin-spin correlation function C(r) computed from samples generated by the diffusion model followed by 20 and 40 Wolff MCMC updates respectively. The error bars represent the standard deviation around the mean. The dotted line represents the C(r) obtained from fully thermalized systems obtained from long MCMC runs. The inset plots show the long range correlations in more detail.

Limitations and Future Work

  • Asymptotic Scaling: While diffusion-warmed MCMC delivers a massive constant-factor speedup (~10x), it does not magically cure exponential complexity. At low temperatures ($\beta = 1.5$), thermalization time still appears to scale exponentially with lattice size $L$, and the exact theoretical scaling of the hybrid pipeline needs deeper study.
  • Measuring Equilibrium: Confirming true thermalization is an exponentially hard problem; the authors rely on tracking when the slowest known observables plateau, which is standard practice in physics but technically doesn't guarantee mathematical equilibrium.
  • Next Steps: Future work will explore testing this warm-start paradigm on other continuous-symmetry physical models and investigating whether conditional models can extrapolate out-of-distribution in temperature, not just grid size.

Summary updated

Abstract

We introduce a novel technique for scalable sampling of spin-system states with continuous symmetries using diffusion models. By applying our approach to the XY model, a fundamental continuous-spin model in condensed matter physics, we show that our technique addresses the shortfalls of the Markov chain Monte Carlo (MCMC) in generalization to varying system sizes. More specifically, we show that training a temperature-conditioned diffusion model on smaller-size XY model lattices enables the generation of accurate samples in larger lattice sizes. By tracking physically important observables of the model, such as spin correlations, our experiments demonstrate that diffusion sampling followed by few MCMC steps reduces the thermalization time by an order of magnitude relative to the standard MCMC with random initialization. Our study provides valuable insight as to how generative models can be used to study continuous-state condensed matter systems at scale.
BibTeX
@inproceedings{hoque2026diffusion,
  author = {Sehmimul Hoque and Roger G Melko and Pooya Ronagh},
  title = {{Diffusion-warm sampling of the XY model enables fast thermalization at scale}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=3vCVCEk7Px},
}
Figure