Skip to content

Fix SFT loss type rewards being overwritten in dpo_loss()#5079

Merged
qgallouedec merged 1 commit intohuggingface:mainfrom
Mr-Neutr0n:fix/dpo-sft-reward-overwrite
Feb 16, 2026
Merged

Fix SFT loss type rewards being overwritten in dpo_loss()#5079
qgallouedec merged 1 commit intohuggingface:mainfrom
Mr-Neutr0n:fix/dpo-sft-reward-overwrite

Conversation

@Mr-Neutr0n
Copy link
Contributor

Summary

  • In dpo_loss(), the sft loss branch correctly sets chosen_rewards and rejected_rewards to zeros (since SFT has no preference rewards), but the unconditional reward computation at the end of the method overwrites these with standard DPO implicit rewards
  • This causes inflated reward metrics when using SFT as part of a multi-loss configuration (e.g., MPO with ["sigmoid", "bco_pair", "sft"]), because the SFT component contributes DPO-style rewards instead of the intended zeros
  • The fix guards the reward computation so it only runs for non-SFT loss types, preserving the correct zero rewards for SFT

Test plan

  • Existing test_train_with_multiple_loss_types test continues to pass
  • Run MPO training with loss_type=["sigmoid", "sft"] and verify reward metrics are no longer inflated by the SFT component
  • Verify single loss type training (e.g., loss_type="sigmoid") is unaffected

In dpo_loss(), the SFT loss branch correctly sets chosen_rewards and
rejected_rewards to zeros since SFT has no preference rewards. However,
the unconditional reward computation at the end of the method overwrites
these zeros with standard DPO implicit rewards.

This causes incorrect reward metrics when using SFT as part of a
multi-loss configuration (e.g., MPO with ["sigmoid", "bco_pair", "sft"]).
The accumulated rewards are inflated because the SFT component
contributes DPO-style rewards instead of zeros, leading to misleading
reward_accuracies and reward margin metrics.

The fix guards the reward computation so it only applies to non-SFT loss
types, preserving the intended zero rewards for SFT.
@qgallouedec qgallouedec self-assigned this Feb 11, 2026
Copy link
Member

@qgallouedec qgallouedec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this makes sense. Note that DPO is being refactored in #3906, I'm checking if we're not doing the same mistake.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec qgallouedec merged commit 8c232f6 into huggingface:main Feb 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments