Refactor CLI [14/N] : Remove TrainingArguments import from core trainers#5257
Merged
albertvillanova merged 1 commit intoMar 10, 2026
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. |
songhappy
pushed a commit
to songhappy/trl
that referenced
this pull request
Apr 20, 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.
Remove TrainingArguments import from core trainers.
This PR is part of a refactoring to reduce the CLI latency.
This PR refactors multiple trainer configuration files to remove direct dependencies on
transformers.TrainingArgumentsand instead rely on the project's own_BaseConfigfor managing valid dictionary fields. This change improves modularity and reduces external coupling across the configuration classes.See upstream issue:
Dependency refactoring:
TrainingArgumentsfromtransformersin all trainer config files (dpo_config.py,grpo_config.py,reward_config.py,rloo_config.py,sft_config.py) to eliminate unnecessary dependency._VALID_DICT_FIELDSinitialization in all trainer config classes to use_BaseConfig._VALID_DICT_FIELDSinstead ofTrainingArguments._VALID_DICT_FIELDS, ensuring consistency and independence from external library internals.Note
Low Risk
Low risk refactor that only changes where
_VALID_DICT_FIELDSis sourced for several config dataclasses; behavior should remain equivalent because_BaseConfiginheritsTrainingArguments, but any divergence in_BaseConfig._VALID_DICT_FIELDScould affect CLI argument parsing/serialization.Overview
Reduces direct
transformerscoupling in trainer config modules by removingTrainingArgumentsimports fromDPOConfig,GRPOConfig,RewardConfig,RLOOConfig, andSFTConfig.Each config now builds
_VALID_DICT_FIELDSfrom_BaseConfig._VALID_DICT_FIELDS(plusmodel_init_kwargs) instead ofTrainingArguments._VALID_DICT_FIELDS, centralizing config/CLI field validation behind TRL’s base config.Written by Cursor Bugbot for commit 7b59a70. This will update automatically on new commits. Configure here.