Skip to content

Refactor CLI [14/N] : Remove TrainingArguments import from core trainers#5257

Merged
albertvillanova merged 1 commit into
huggingface:mainfrom
albertvillanova:refactor-cli-14
Mar 10, 2026
Merged

Refactor CLI [14/N] : Remove TrainingArguments import from core trainers#5257
albertvillanova merged 1 commit into
huggingface:mainfrom
albertvillanova:refactor-cli-14

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Mar 10, 2026

Copy link
Copy Markdown
Member

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.TrainingArguments and instead rely on the project's own _BaseConfig for managing valid dictionary fields. This change improves modularity and reduces external coupling across the configuration classes.

See upstream issue:

Dependency refactoring:

  • Removed import of TrainingArguments from transformers in all trainer config files (dpo_config.py, grpo_config.py, reward_config.py, rloo_config.py, sft_config.py) to eliminate unnecessary dependency.
  • Changed _VALID_DICT_FIELDS initialization in all trainer config classes to use _BaseConfig._VALID_DICT_FIELDS instead of TrainingArguments._VALID_DICT_FIELDS, ensuring consistency and independence from external library internals.

Note

Low Risk
Low risk refactor that only changes where _VALID_DICT_FIELDS is sourced for several config dataclasses; behavior should remain equivalent because _BaseConfig inherits TrainingArguments, but any divergence in _BaseConfig._VALID_DICT_FIELDS could affect CLI argument parsing/serialization.

Overview
Reduces direct transformers coupling in trainer config modules by removing TrainingArguments imports from DPOConfig, GRPOConfig, RewardConfig, RLOOConfig, and SFTConfig.

Each config now builds _VALID_DICT_FIELDS from _BaseConfig._VALID_DICT_FIELDS (plus model_init_kwargs) instead of TrainingArguments._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.

@albertvillanova albertvillanova changed the title Refactor CLI [14/N] : Move TrainingArguments import from base trainers Refactor CLI [14/N] : Remove TrainingArguments import from base trainers Mar 10, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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 qgallouedec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@albertvillanova albertvillanova changed the title Refactor CLI [14/N] : Remove TrainingArguments import from base trainers Refactor CLI [14/N] : Remove TrainingArguments import from core trainers Mar 10, 2026
@albertvillanova albertvillanova merged commit 41602bc into huggingface:main Mar 10, 2026
12 checks passed
songhappy pushed a commit to songhappy/trl that referenced this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants