Skip to content

Fix stale experimental.kto docstring cross-references in KTOTrainer/KTOConfig#6331

Closed
DaoyuanLi2816 wants to merge 1 commit into
huggingface:mainfrom
DaoyuanLi2816:fix/kto-stale-experimental-docstring-refs
Closed

Fix stale experimental.kto docstring cross-references in KTOTrainer/KTOConfig#6331
DaoyuanLi2816 wants to merge 1 commit into
huggingface:mainfrom
DaoyuanLi2816:fix/kto-stale-experimental-docstring-refs

Conversation

@DaoyuanLi2816

@DaoyuanLi2816 DaoyuanLi2816 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

PR #6175 promoted KTO from trl.experimental.kto to the stable trl.trainer API — it moved kto_trainer.py/kto_config.py and updated the >>> from trl.experimental.kto import ... code examples, but left four docstring cross-references still pointing at the old experimental path.

In KTOTrainer.__init__'s docstring:

args ([`experimental.kto.KTOConfig`], *optional*):
...
Will default to [`~experimental.kto.kto_trainer.DataCollatorForUnpairedPreference`] if the model is a
language model and [`~experimental.kto.kto_trainer.DataCollatorForVisionUnpairedPreference`] if the model

And in KTOConfig's class docstring:

Configuration class for the [`experimental.kto.KTOTrainer`].

trl/experimental/kto/ now contains only a deprecation shim __init__.py (the kto_trainer submodule itself was deleted), so:

  • the two collator references point at a module path that no longer exists (experimental.kto.kto_trainer isn't importable), and
  • the KTOConfig/KTOTrainer references resolve only to shim subclasses whose __post_init__/__init__ raise FutureWarning: ... Update your imports to from trl import KTOConfig``.

So the stable class's own docstring points readers at the exact import path its own code warns against.

This PR updates all four references to the stable self-referential form, matching DPOTrainer's already-correct pattern:

args ([`DPOConfig`], *optional*):
...
Will default to [`~trainer.dpo_trainer.DataCollatorForPreference`] if the model is a language model and

and

Configuration class for the [`DPOTrainer`].

Docstring-only change, no behavior change.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline, Pull Request section?

Note

Low Risk
Documentation-only edits with no code or behavior changes.

Overview
After KTO moved to the stable trl.trainer API, four docstring links still pointed at experimental.kto paths that no longer exist or only resolve through deprecation shims.

This PR retargets them to match DPOTrainer / DPOConfig: KTOConfig now references [KTOTrainer]; KTOTrainer.__init__ references [KTOConfig] and the default collators under [~trainer.kto_trainer.*]. Docstrings only — no runtime or API behavior change.

Reviewed by Cursor Bugbot for commit 29942a4. Bugbot is set up for automated code reviews on this repo. Configure here.

…TOConfig

PR huggingface#6175 promoted KTO from `trl.experimental.kto` to the stable
`trl.trainer` API, physically moving `kto_trainer.py`/`kto_config.py` and
updating the `>>> from trl.experimental.kto import ...` code examples, but
left four docstring cross-references pointing at the old experimental path:

- `KTOTrainer.__init__`'s `args` param referenced `[`experimental.kto.KTOConfig`]`
- its `data_collator` param referenced
  `[`~experimental.kto.kto_trainer.DataCollatorForUnpairedPreference`]` and
  `[`~experimental.kto.kto_trainer.DataCollatorForVisionUnpairedPreference`]`
- `KTOConfig`'s class docstring referenced `[`experimental.kto.KTOTrainer`]`

`trl/experimental/kto/` now contains only a deprecation shim `__init__.py`
(the `kto_trainer` submodule was deleted), so the collator references point
at a module path that no longer exists, and the KTOConfig/KTOTrainer
references resolve only to shim subclasses whose `__post_init__`/`__init__`
raise `FutureWarning: ... Update your imports to `from trl import
KTOConfig`` — i.e. the stable class's own docstring pointed readers at the
exact import path its own code warns against.

Update all four to the stable self-referential form, matching DPOTrainer's
already-correct pattern (`[`DPOConfig`]`, `[`~trainer.dpo_trainer.DataCollatorForPreference`]`,
`Configuration class for the [`DPOTrainer`].`).

Docstring-only change, no behavior change; no test applicable.
@DaoyuanLi2816

Copy link
Copy Markdown
Contributor Author

Superseded by #6345 (merged just now), which fixes this same stale experimental.kto reference along with a broader KTO-stable-trainer docs pass. Closing.

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.

1 participant