Diffusion-SDPO: Safeguarded Direct Preference Optimization for Diffusion Models
📝 Introduction
Diffusion-SDPO
is a plug-in training rule for preference alignment of diffusion models. It computes an adaptive scale for the loser branch based on the alignment between winner and loser output-space gradients, so that each update theoretically
does not increase the winner's loss to first order
. This preserves the preferred output while still widening the preference margin. The safeguard is model-agnostic and drops into Diffusion-DPO, DSPO, and DMPO with negligible overhead. See
our paper
for details (derivation of the safety bound, the output-space approximation, and the closed-form solution).
This repository is the official implementation of paper
Diffusion-SDPO
.
🔧 Setup
pip install -r requirements.txt
📦 Model Checkpoints
All checkpoints are initialized from Stable Diffusion (SD1.5 or SDXL) and trained as described in the paper.
Each name below means
{base model} + {DPO variant} with our safeguarded winner-preserving rule (SDPO)
:
Example: SD1.5 + Diffusion-DPO with SDPO safeguard
Start training by running the provided script. It auto-detects the number of GPUs and launches with
accelerate
.
bash scripts/train/sd15_diffusion_dpo.sh
Key arguments in this example
--train_method
selects Diffusion-DPO as the baseline. Choices : [diffusion-dpo, dspo, dmpo]
--beta_dpo
controls the DPO temperature or strength.
--use_winner_preserving
enables our SDPO safeguard that rescales only the loser branch’s backward signal to avoid increasing the winner loss to first order.
--winner_preserving_mu
sets the safeguard strength. Larger values are more conservative.
--mixed_precision bf16
and
--allow_tf32
improve throughput on recent NVIDIA GPUs.
📊 Evaluation
We provide one-click evaluation scripts for SD1.5 and SDXL. They take a
unet.pth
checkpoint and will:
generate images for three prompt groups:
papv2
,
hpsv2
,
partiprompts
# A/B win-rate comparison across all prompts from one group (papv2, hpsv2, partiprompts)# A.json / B.json are the generation manifests produced by your eval runs.
bash scripts/eval/test_vs.sh \
--json_a path/to/A.json \
--json_b path/to/B.json \
--label_a "your label A" \
--label_b "your label B"
If you find TeEFusion helpful, please cite our paper:
@article{fu2025diffusion,
title={{Diffusion-SDPO}: Safeguarded Direct Preference Optimization for Diffusion Models},
author={Fu, Minghao and Wang, Guo-Hua and Cui, Tianyu and Chen, Qing-Guo and Xu, Zhao and Luo, Weihua and Zhang, Kaifu},
journal={arXiv:2511.03317},
year={2025}
}
This project is licensed under the Apache License, Version 2.0 (SPDX-License-Identifier: Apache-2.0) with additional use restrictions. You can find the full text of the license(s) in the following path: ./LICENSE
🚨 Disclaimer
We used compliance checking algorithms during the training process, to ensure the compliance of the trained model(s) to the best of our ability. Due to complex data and the diversity of language model usage scenarios, we cannot guarantee that the model is completely free of copyright issues or improper content. If you believe anything infringes on your rights or generates improper content, please contact us, and we will promptly address the matter.
Runs of AIDC-AI Diffusion-SDPO on huggingface.co
0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs
More Information About Diffusion-SDPO huggingface.co Model
Diffusion-SDPO huggingface.co is an AI model on huggingface.co that provides Diffusion-SDPO's model effect (), which can be used instantly with this AIDC-AI Diffusion-SDPO model. huggingface.co supports a free trial of the Diffusion-SDPO model, and also provides paid use of the Diffusion-SDPO. Support call Diffusion-SDPO model through api, including Node.js, Python, http.
Diffusion-SDPO huggingface.co is an online trial and call api platform, which integrates Diffusion-SDPO's modeling effects, including api services, and provides a free online trial of Diffusion-SDPO, you can try Diffusion-SDPO online for free by clicking the link below.
AIDC-AI Diffusion-SDPO online free url in huggingface.co:
Diffusion-SDPO is an open source model from GitHub that offers a free installation service, and any user can find Diffusion-SDPO on GitHub to install. At the same time, huggingface.co provides the effect of Diffusion-SDPO install, users can directly use Diffusion-SDPO installed effect in huggingface.co for debugging and trial. It also supports api for free installation.