From Uncertain to Safe: Conformal Adaptation of Diffusion Models for Safe PDE Control

Peiyan Hu, Xiaowei Qian, Wenhao Deng, Rui Wang, Haodong Feng, Ruiqi Feng, Tao Zhang, Long Wei, Yue Wang, Zhi-Ming Ma, Tailin Wu

TL;DR

Controlling complex physical systems governed by Partial Differential Equations (PDEs) requires strict safety guarantees, yet deep learning approaches often violate these boundaries when trained on messy, offline data. This paper introduces SafeDiffCon (Safe Diffusion Models for PDE Control), a novel framework that combines diffusion models with conformal prediction to quantify model uncertainty. By adapting the model's distribution during both post-training and inference, SafeDiffCon achieves optimal control performance while successfully satisfying 100% of safety constraints across challenging fluid dynamics and nuclear fusion tasks.

What Problem Does This Paper Address?

From managing plasma stability in a nuclear fusion reactor to controlling fluid flows, many critical scientific and engineering problems are framed as PDE-constrained control problems. Recently, diffusion models have emerged as a powerful tool for these tasks due to their ability to model high-dimensional, non-linear trajectories.

However, real-world deployment has a massive bottleneck: safety. Traditional deep learning control methods rarely provide formal safety guarantees. This is particularly problematic because safety-critical systems must be trained offline using pre-collected datasets to avoid catastrophic failures during exploration. These offline datasets are often highly suboptimal and contain unsafe examples. When a model tries to optimize for a control target, it inevitably shifts away from the training data distribution, leading to unpredictable prediction errors and severe safety violations.

Methods

The authors propose SafeDiffCon, which integrates Conformal Prediction (CP) into a diffusion-based control pipeline to rigorously quantify and mitigate model uncertainty.

The framework operates in four distinct phases:

  1. Pre-training: A standard diffusion model is trained on offline data to learn the joint distribution of system states and control sequences.
  2. Uncertainty Quantification via Conformal Prediction: To account for distribution shifts between the static training data and the model's generated trajectories, the authors compute a shifted score set using a calibration dataset. From this, they derive an uncertainty quantile ($Q$). This quantile defines a statistical boundary (conformal interval) within which the true safety score is guaranteed to lie with high probability.
  3. Post-training with Reweighted Loss: The pre-trained model is fine-tuned globally using a reweighted diffusion loss. Trajectories with lower safety risks (factoring in the uncertainty quantile) and better control objectives are assigned higher weights, steering the model's base distribution toward safer regions.
  4. Inference-time Fine-tuning: When given a specific control target, the model dynamically adjusts its parameters and generation process over a few iterations using both test-time guidance and localized fine-tuning.
Figure 1: Overview of SafeDiffCon. First, we pre-train a diffusion model pθ on the training data. Then, combined with the uncertainty quantile, we post-train the model to steer its distribution to safer regions with better control objectives. Finally, to improve performance and safety for specific control tasks, we conduct inference-time fine-tuning, again incorporating the uncertainty quantile into the process.

Datasets

The authors evaluated SafeDiffCon on three distinct simulated environments:

  • 1D Burgers' Equation: A fundamental equation for fluid and gas dynamics. The task is to guide the system to a target state while keeping the state magnitude below a strict safety threshold ($s_0 = 0.64$).
  • 2D Incompressible Fluid (Navier-Stokes): A complex smoke simulation containing obstacles and a designated "hazardous red region." The objective is to maximize smoke passing through a target bucket while ensuring less than 10% enters the hazardous zone. Notably, 53.1% of the training dataset consists of unsafe trajectories.
  • Tokamak Fusion Reactor (KSTAR Simulator): A highly non-linear, data-driven simulator based on the Korea Superconducting Tokamak Advanced Research device. The controller must manipulate plasma parameters ($\beta_p$ and $l_i$) while ensuring the safety factor ($q_{95}$) never drops below a critical threshold. 71.18% of the training samples here are unsafe.

Key Insights and Ideas

  • Embracing Overconfidence Protection: Instead of relying on a model's point-estimate prediction of safety, SafeDiffCon optimizes against the upper bound of the conformal interval. This ensures that even if the model is uncertain, the actual physical system remains safe.
  • Distribution-Shift Aware Calibration: Standard conformal prediction assumes data exchangeability. Because the diffusion model actively steers towards optimal (and thus out-of-distribution) trajectories, the authors dynamically reweight the calibration scores based on the likelihood ratio between the target and training distributions.
  • The Necessity of Two-Stage Adaptation: The ablation studies reveal that neither global post-training nor local inference-time fine-tuning is sufficient on its own. Post-training establishes a safe, broad prior, while inference-time tuning refines the model for highly specific, narrow control targets.

Key Results

SafeDiffCon was compared against a wide array of baselines, including Behavior Cloning (BC), Supervised Learning with Lagrangian constraints (SL-Lag), Model Predictive Control (MPC-Lag), Constrained Decision Transformers (CDT), and TREBI (a planning-focused diffusion baseline).

As shown in the results tables, SafeDiffCon was the only method to achieve a 0% unsafe rate ($R$) across all tasks while simultaneously delivering the lowest control error ($J$).

1D Burgers' Equation Results

While standard imitation learning (BC) suffered from a 38% unsafe trajectory rate, SafeDiffCon eliminated all violations while maintaining an exceptionally low control error ($J = 0.0011$).

Table 1: Results of 1D Burgers’ equation. Gray: there are unsafe trajectories. Black: all trajectories are safe. Bold: safe trajectories with lowest J .

2D Incompressible Fluid Results

In the highly complex 2D fluid environment, other advanced baselines like CDT and TREBI failed significantly, yielding 30% and 18% unsafe samples respectively. SafeDiffCon achieved perfect safety (0% violation) and a superior control objective score of -0.3548.

Table 2: 2D incompressible fluid control results. Gray: there are unsafe trajectories. Black: all trajectories are safe. Bold: safe trajectories with lowest J .

Limitations and Future Work

While SafeDiffCon demonstrates flawless safety in simulated environments, the authors note several areas for improvement:

  1. Real-World Deployment: The current validation relies entirely on numerical solvers and data-driven simulators (like the KSTAR LSTM simulator). Testing on physical hardware remains an open challenge.
  2. Architecture Agnosticism: The current framework is tailored strictly to diffusion models. The authors plan to explore how these conformal adaptation techniques can be extended to other generative architectures (e.g., flow matching or autoregressive models).
  3. Tightening Safety Bounds: Currently, ensuring absolute safety can sometimes lead to overly conservative control strategies. Future work will focus on developing stricter coverage metrics that preserve safety without sacrificing control agility.

Summary updated

Abstract

The application of deep learning for partial differential equation (PDE)-constrained control is gaining increasing attention. However, existing methods rarely consider safety requirements crucial in real-world applications. To address this limitation, we propose Safe Diffusion Models for PDE Control (SafeDiffCon), which introduce the uncertainty quantile as model uncertainty quantification to achieve optimal control under safety constraints through both post-training and inference phases. Firstly, our approach post-trains a pre-trained diffusion model to generate control sequences that better satisfy safety constraints while achieving improved control objectives via a reweighted diffusion loss, which incorporates the uncertainty quantile estimated using conformal prediction. Secondly, during inference, the diffusion model dynamically adjusts both its generation process and parameters through iterative guidance and fine-tuning, conditioned on control targets while simultaneously integrating the estimated uncertainty quantile. We evaluate SafeDiffCon on three control tasks: 1D Burgers' equation, 2D incompressible fluid, and controlled nuclear fusion problem. Results demonstrate that SafeDiffCon is the only method that satisfies all safety constraints, whereas other classical and deep learning baselines fail. Furthermore, while adhering to safety constraints, SafeDiffCon achieves the best control performance. The code can be found at https://github.com/AI4Science-WestlakeU/safediffcon.
BibTeX
@inproceedings{hu2025from,
  author = {Peiyan Hu and Xiaowei Qian and Wenhao Deng and Rui Wang and Haodong Feng and Ruiqi Feng and Tao Zhang and Long Wei and Yue Wang and Zhi-Ming Ma and Tailin Wu},
  title = {{From Uncertain to Safe: Conformal Adaptation of Diffusion Models for Safe PDE Control}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=XGJ33p4qwt},
}
Figure