Raise ValueError instead of NotImplementedError for Liger DPO with PEFT#6225
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
approved these changes
Jun 30, 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.
This PR changes the exception raised by
DPOTrainerwhenuse_liger_kernel=Trueis combined with a PEFT model, fromNotImplementedErrortoValueError.Motivation
NotImplementedError(a subclass ofRuntimeError) is meant for abstract methods that subclasses must override, or as a development placeholder. Rejecting an invalid combination of constructor arguments is not that case: the user passed arguments of the right type whose combination is unsupported, which is idiomatically aValueError.This also restores consistency. The two sibling Liger guards in the same block (
compute_metricsandprecompute_ref_log_probs) already raiseValueError, as does the analogous Liger + PEFT guard inGRPOTrainer.Changes
ValueErrorinstead ofNotImplementedErrorwhenuse_liger_kernel=Trueis used with a PEFT model in DPOTrainer.use_liger_kernel=False).ValueErrorand the new message.Note
Low Risk
Only the exception type and message change at init for an already-unsupported configuration; training behavior is unchanged for valid setups.
Overview
When
DPOTraineris constructed withuse_liger_kernel=Trueand a PEFT model, it now raisesValueErrorinstead ofNotImplementedError, matching the other Liger configuration guards in the same block and the style used inGRPOTrainer.The error text now states that the flag combination is unsupported and tells callers to set
use_liger_kernel=Falseto train with PEFT.test_init_fails_with_peft_and_ligerexpectsValueErrorand the updated message.Reviewed by Cursor Bugbot for commit 1049f92. Bugbot is set up for automated code reviews on this repo. Configure here.