Fail early for unsupported PEFT + Liger Kernel in DPO#5709
Merged
Conversation
|
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
reviewed
May 6, 2026
Comment on lines
+712
to
+713
| if is_peft_model(model): | ||
| raise NotImplementedError("Liger DPO loss is not implemented for PEFT models.") |
Member
There was a problem hiding this comment.
maybe we could remove this then?
trl/trl/trainer/dpo_trainer.py
Lines 1101 to 1102 in 62a66af
Member
Author
There was a problem hiding this comment.
I thought the same! But codex told me to keep it... I should have followed my intuition.
qgallouedec
approved these changes
May 6, 2026
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.
Fail early for unsupported PEFT + Liger Kernel in DPO.
This pull request introduces a check to prevent the use of the Liger DPO loss with PEFT models, as this combination is not yet supported. It also adds a corresponding test to ensure that initializing a
DPOTrainerwith both Liger Kernel and PEFT raises a clear error.Changes
Validation and error handling improvements:
DPOTrainerinitializer to raise aNotImplementedErrorif bothuse_liger_kernelis enabled and the model is a PEFT model, with a clear error message.Testing enhancements:
test_init_fails_with_peft_and_liger) intests/test_dpo_trainer.pyto verify that initializingDPOTrainerwith both Liger Kernel and PEFT fails as expected, raising the correct error.Note
Low Risk
Low risk: adds an early validation guard and a regression test, without changing supported training flows beyond producing a clearer error sooner for an already-unsupported configuration.
Overview
Prevents unsupported configurations by failing fast when initializing
DPOTrainerwithuse_liger_kernel=Trueon a PEFT-wrapped model, raising a clearNotImplementedError.Adds a regression test (
test_init_fails_with_peft_and_liger) to ensure the PEFT+Liger combination errors at init time, and removes the now-redundant PEFT check from the Liger loss computation path.Reviewed by Cursor Bugbot for commit 623f168. Bugbot is set up for automated code reviews on this repo. Configure here.