[DPO] Add hinge, bco_pair, robust, exo_pair, discopop loss types#1204
Open
kashif wants to merge 1 commit intolinkedin:mainfrom
Open
[DPO] Add hinge, bco_pair, robust, exo_pair, discopop loss types#1204kashif wants to merge 1 commit intolinkedin:mainfrom
kashif wants to merge 1 commit intolinkedin:mainfrom
Conversation
Brings Liger's fused linear DPO loss closer to TRL's DPOTrainer by adding five additional loss variants on top of the existing sigmoid / apo_zero / apo_down / sppo_hard / nca_pair set: - hinge: relu(1 - beta * (chosen - rejected)) - bco_pair: -logsigmoid(beta * chosen) - logsigmoid(-beta * rejected) - robust (cDPO): label-smoothed sigmoid loss with flipped-pair correction - exo_pair: KL(p_fθ || [1-eps, eps]) for K=2 (EXO-pref, paper 2402.00856) - discopop: blended logistic / exponential loss (DiscoPOP, paper 2406.08414) Also threads two new kwargs through LigerFusedLinearDPOLoss / LigerFusedLinearDPOFunction: - label_smoothing (used by robust and exo_pair; validated at construction) - discopop_tau (temperature for the DiscoPOP modulation term) Tests: adds HF reference implementations for each new loss type and a parametrized test_correctness_extra_loss_types covering all five variants across bf16/fp32, with/without bias, with/without ref bias, and compute_nll_loss on/off (320 cases). Adds test_label_smoothing_validation for the label_smoothing range checks. The existing test_invalid_loss_type is updated to cover the new supported set. All 800 DPO test cases pass on H100.
0420345 to
9428a54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings Liger's fused linear DPO loss closer to TRL's DPOTrainer by adding five additional loss variants on top of the existing sigmoid / apo_zero / apo_down / sppo_hard / nca_pair set:
Also threads two new kwargs through LigerFusedLinearDPOLoss / LigerFusedLinearDPOFunction:
Tests: adds HF reference implementations for each new loss type and a parametrized test_correctness_extra_loss_types covering all five variants across bf16/fp32, with/without bias, with/without ref bias, and compute_nll_loss on/off (320 cases). Adds test_label_smoothing_validation for the label_smoothing range checks. The existing test_invalid_loss_type is updated to cover the new supported set.
All 800 DPO test cases pass on H100.
Summary
Testing Done
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence