Skip to content

Fix support for model_init_kwargs in GKD/GOLD when passed as CLI JSON string#5266

Merged
albertvillanova merged 1 commit into
huggingface:mainfrom
albertvillanova:fix-missing-model-init-kwargs
Mar 11, 2026
Merged

Fix support for model_init_kwargs in GKD/GOLD when passed as CLI JSON string#5266
albertvillanova merged 1 commit into
huggingface:mainfrom
albertvillanova:fix-missing-model-init-kwargs

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Mar 10, 2026

Copy link
Copy Markdown
Member

Fix support for model_init_kwargs when passed as CLI JSON string

  • Add missing model_init_kwargs to _VALID_DICT_FIELDS

Note that GKDConfig and GOLDConfig both subclass SFTConfig, but they were extending the _VALID_DICT_FIELDS class attribute from TrainingArguments instead of the one from their direct parent. As a result, model_init_kwargs (which is defined in SFTConfig) was not included in the valid dictionary fields for these configs, causing it to be ignored when passed as a CLI JSON string.

This PR ensures that model_init_kwargs is properly recognized and parsed in the GKDConfig and GOLDConfig classes. The main change is to ensure that these classes reference their base class SFTConfig for valid dictionary fields instead of the external TrainingArguments class, improving consistency and maintainability.

Configuration logic improvements:

  • Changed _VALID_DICT_FIELDS in both GKDConfig and GOLDConfig to reference SFTConfig._VALID_DICT_FIELDS instead of TrainingArguments._VALID_DICT_FIELDS, ensuring proper inheritance and avoiding unnecessary dependency on transformers, concretely to ensure the presence of model_init_kwargs.

Dependency cleanup:

  • Removed unused imports of TrainingArguments from trl/experimental/gkd/gkd_config.py and trl/experimental/gold/gold_config.py to streamline the code and reduce external dependencies.

Note

Low Risk
Low risk: updates config metadata used for CLI/JSON parsing and removes an unused transformers.TrainingArguments import, with no changes to training logic itself.

Overview
Fixes GKDConfig and GOLDConfig dict/CLI JSON parsing by deriving _VALID_DICT_FIELDS from SFTConfig (their actual base class) instead of TrainingArguments, so model_init_kwargs is no longer dropped when provided via CLI.

Also removes the now-unneeded TrainingArguments imports from both config modules.

Written by Cursor Bugbot for commit 68c101f. This will update automatically on new commits. Configure here.

@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.

@albertvillanova albertvillanova merged commit 11be774 into huggingface:main Mar 11, 2026
4 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