Adversarial Attack and Defense for Machine Learning in Statistical Physics

Zhao-Rong Lai, Qiantong Liang, Jian WengNeurIPS 2026

TL;DR

Machine learning models built for statistical physics often assume pristine, idealized data, leaving them shockingly vulnerable to tiny, real-world noises. Because physicists only observe macroscopic averages, mean-zero random noise completely vanishes during observation—yet behind the scenes, it hijacks neural network gradients and ruins scientific parameter estimation. This paper exposes this stealthy vulnerability and introduces a plug-and-play mathematical regularizer that restores physical order and accuracy.

What Problem Does This Paper Address?

Imagine trying to deduce the room temperature of a vast grid of microscopic magnets (spins). In statistical physics, you can't look at every single magnet simultaneously; you only observe bulk, macroscopic averages across millions of samples. Recently, physicists have started using ML to reverse-engineer macroscopic parameters—like inverse temperature ($\beta$)—by matching the statistical features of observed physical systems with neural-network-transformed simulations.

The catch? These ML pipelines are typically tested in pristine virtual sandboxes. In reality, physical detectors suffer from thermal jitter (like Johnson-Nyquist noise), and simulations can face subtle perturbations. Because these ML systems rely on sensitive components like Gumbel-Softmax attention mechanisms—and often operate near chaotic physical "phase transitions"—even microscopic input noise gets violently amplified, causing the model to hallucinate completely wrong physical laws.

Methods

The authors build a closed-loop attack-and-defense framework for ML in statistical physics:

  • The Stealth Attack: The attacker injects tiny, independent, mean-zero Gaussian noise into individual links between neighboring spins (or uses stronger Projected Gradient Descent, PGD). Because macroscopic observables average over massive sample sizes, the mean-zero noise averages out to zero—making the attack practically invisible and physically plausible. Yet inside the neural network, this noise blurs the statistical boundaries between local features, corrupting the attention heads and creating a cascading feedback loop of noisy gradients during backpropagation.
  • The Defense (ADSP): To fight back without gutting the physics model, the authors propose Adversarial Defense for Statistical Physics (ADSP). While standard Total Variation (TV) smooths out noise across discrete pixel grids in images, physics ML relies on abstract functional spaces. The authors invent Functional Local Variation (FLV): the $L_2$ norm of the gradient of the base loss with respect to the system's key physical features ($F(\tilde{\beta}, \theta) = \|\partial_{\phi^a} \mathcal{L}(\tilde{\beta}, \theta)\|_2$). Plugging FLV into the loss function penalizes erratic fluctuations caused by random noise while preserving ordered physical structures.
Figure 2: Left: the attack chain of adversarial perturbations ˜δ⟨ij⟩at the learnable parameters θ1 and θ2 in the target system. Right: the defense strategy ADSP first extracts the FLV F(˜β, θ) from the key physical features ϕa and the base loss L, then plugs it in the total loss LADSP . Minimizing LADSP can suppress the adversarial perturbations ˜δ⟨ij⟩by reducing the random fluctuation of L w.r.t. ϕa.
  • Making it Trainable: There is a mathematical hiccup: FLV isn't differentiable everywhere, and the physical parameter $\tilde{\beta}$ relies on stochastic Markov Chain Monte Carlo (MCMC) sampling, which breaks standard PyTorch autograd. The authors bypass this using Fréchet subdifferentials (setting gradients to zero at the non-differentiable point) and swapping differentiation and expectation operators so everything plays nicely with standard backpropagation.
Making non-differentiable physics modules compatible with autograd

Datasets

Rather than static benchmark datasets, this domain relies on dynamic MCMC-sampled spin configurations generated from canonical theoretical physics models:

  • 2D Ising Model: A classic square lattice of binary magnetic spins ($\pm 1$) tested across four ground-truth inverse temperatures $\beta \in \{0.2, 0.3, 0.4, 0.44\}$ (where $0.44$ sits precariously close to an unstable phase transition).
  • 3-State Potts Model: A generalized periodic square lattice where spins take one of three states $\{0, 1, 2\}$, used to demonstrate that the method generalizes across multi-state spin systems.

No new static benchmark datasets are introduced, though the authors evaluate across perturbed raw spin inputs, clean inputs, and directly perturbed high-level physical features.

Key Insights and Ideas

  • The Law of Large Numbers is a Double-Edged Sword: The exact statistical property that makes macroscopic physics clean and predictable—averaging over massive ensembles—acts as the ultimate camouflage for an attacker. Noise vanishes in the observable expectation value while quietly wrecking the underlying neural network weights.
  • Weaponizing Randomness Against Itself: Why does FLV work? Because physical features (like local angular correlations and gauge-invariant quantities) are inherently ordered, whereas Gaussian noise is chaotic. Penalizing the sensitivity of the loss to feature distortions selectively dampens random adversarial jitter without erasing true thermodynamic signals.
  • Standard Adversarial Training Fails Physics: You can't just throw standard computer-vision Adversarial Training (AT) at physics models. Under PGD attacks, standard empirical risk minimization remains hyper-sensitive to distortions in high-order statistical features, causing massive estimation drift.

Key Results

  • 2D Ising Model: Under small Gaussian noise, the baseline ML system completely fails to converge, with loss values and Hessian determinants fluctuating wildly. With ADSP, the model smoothly converges to the ground-truth $\beta$ within 5% relative error across all temperatures—estimating $0.210$ (for $\beta=0.2$), $0.285$ (for $0.3$), $0.392$ (for $0.4$), and $0.428$ (for the near-critical $0.44$).
  • Clean Data Bonus: Even with zero noise present, the original baseline struggles with instability at $\beta \in \{0.3, 0.44\}$, whereas ADSP stabilizes gradients and maintains $<5\%$ relative error.
  • 3-State Potts Model (PGD Attack): Against a PGD attack, standard Adversarial Training (AT) severely overestimates $\beta$, drifting to $0.5706$ (target $0.2000$) and $1.0335$ (target $0.3000$) at step 1000. ADSP nails the targets within 5% error, hitting $0.1948$, $0.2887$, $0.3832$, and $0.4203$ for targets $0.20, 0.30, 0.40,$ and $0.44$, respectively.

Limitations and Future Work

  • Model Expressiveness & Precision: Because ADSP is a plug-and-play regularizer wrapped around an existing, relatively simple ML architecture, recovery accuracy still hovers around a ~5% relative error margin, and residual volatility remains noticeable near physical phase transitions ($\beta = 0.44$). Designing more inherently robust, complex architectures could push this accuracy further.
  • Stronger Threat Models: While Gaussian noise and PGD were tested, exploring more sophisticated white-box attacks tailored specifically to physical constraints remains an open avenue.
  • Higher-Stakes Domains: Statistical lattices are great testbeds, and the authors highlight an urgent need to investigate these stealthy statistical vulnerabilities in high-stakes scientific pipelines like climate modeling, particle physics, and pharmaceutical engineering.

Summary updated

BibTeX
@inproceedings{lai2026adversarial,
  author = {Zhao-Rong Lai and Qiantong Liang and Jian Weng},
  title = {{Adversarial Attack and Defense for Machine Learning in Statistical Physics}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=I0iY7DbMc6},
}
Figure