Fix missing PEFT availability check when passing peft_config to experimental trainers#5665
Merged
albertvillanova merged 21 commits intomainfrom Apr 28, 2026
Merged
Fix missing PEFT availability check when passing peft_config to experimental trainers#5665albertvillanova merged 21 commits intomainfrom
albertvillanova merged 21 commits intomainfrom
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
Apr 27, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d236c55. Configure here.
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.

Fix missing PEFT availability check when passing peft_config to experimental trainers.
This PR adds improved error handling for cases where a
peft_configis provided without the requiredpeftlibrary installed in both the distillation and TPO experimental trainers. This ensures users receive a clear, actionable error message if they attempt to use PEFT features without having the necessary dependencies.Related to:
Changes
Error handling improvements for PEFT:
trl/experimental/distillation/distillation_trainer.pyto raise anImportErrorwith installation instructions ifpeft_configis provided but thepeftlibrary is missing.trl/experimental/tpo/tpo_trainer.pyto ensure thepeftlibrary is installed whenpeft_configis used, raising an informativeImportErrorif not.Note
Low Risk
Changes are limited to trainer initialization validation and error messaging around PEFT, with minimal impact beyond earlier/clearer failures for misconfigured setups.
Overview
Standardizes PEFT setup across experimental trainers by validating
peft_configearly and failing fast with clearer errors.When
peft_configis provided, trainers now (1) raise an actionableImportErrorifpeftisn’t installed (withpip install trl[peft]guidance) and (2) enforce thatpeft_configis apeft.PeftConfiginstance (e.g.LoraConfig), before proceeding; several trainers also update PEFT imports to includePeftConfigand keep the existing guard against passing an already-wrappedPeftModelalongside a new config.Reviewed by Cursor Bugbot for commit 70b898f. Bugbot is set up for automated code reviews on this repo. Configure here.