Skip to content

Fix AttributeError in diffusion_dpo --loss_type ipo#13522

Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-diffusion-dpo-ipo-beta
Open

Fix AttributeError in diffusion_dpo --loss_type ipo#13522
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-diffusion-dpo-ipo-beta

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes an AttributeError in examples/research_projects/diffusion_dpo/train_diffusion_dpo.py that crashes the IPO loss path.

The IPO branch references args.beta:

elif args.loss_type == "ipo":
    losses = (logits - 1 / (2 * args.beta)) ** 2
    loss = losses.mean()

but this script only exposes --beta_dpo:

parser.add_argument(
    \"--beta_dpo\",
    type=int,
    default=2500,
    help=\"DPO KL Divergence penalty.\",
)

So running with --loss_type ipo crashes immediately with:

AttributeError: 'Namespace' object has no attribute 'beta'

The sigmoid and hinge branches above correctly use args.beta_dpo, and the SDXL sibling train_diffusion_dpo_sdxl.py also only uses args.beta_dpo. This was clearly intended to use the same hyperparameter.

Fix

 elif args.loss_type == \"ipo\":
-    losses = (logits - 1 / (2 * args.beta)) ** 2
+    losses = (logits - 1 / (2 * args.beta_dpo)) ** 2
     loss = losses.mean()

Before submitting

Who can review?

@sayakpaul

The IPO branch in `train_diffusion_dpo.py` references `args.beta`, but
this script only defines `--beta_dpo` — there is no `--beta` argument.
Running training with `--loss_type ipo` crashes immediately at the loss
computation with:

    AttributeError: 'Namespace' object has no attribute 'beta'

The `sigmoid` and `hinge` branches right above correctly use
`args.beta_dpo`, so IPO was clearly meant to use the same hyperparameter.
Swap to `args.beta_dpo` to unbreak `--loss_type ipo`.
@github-actions github-actions Bot added examples size/S PR with diff < 50 LOC labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant