Skip to content

Conversation

@behroozazarkhalili
Copy link
Collaborator

Summary

This PR migrates KTOTrainer and KTOConfig to trl.experimental.kto as part of the TRL V1 refactoring effort.

Changes

  • New experimental module: trl/experimental/kto/
    • Moved kto_config.py with all configuration parameters
    • Moved kto_trainer.py with updated relative imports (.....)
    • Removed TRL_EXPERIMENTAL_SILENCE warning (no longer needed in experimental)
  • Deprecation stubs: Created backward-compatible stubs in trl/trainer/ that inherit from experimental versions and display FutureWarning
  • Import updates: Updated all tests, examples, scripts, and CLI to use experimental imports
  • Documentation:
    • Updated all code examples to use from trl.experimental.kto import KTOConfig, KTOTrainer
    • Moved KTO from Trainers to Experimental section in documentation toctree
    • Updated Liger Kernel and memory reduction guides

Migration Path

Users can continue using existing imports until TRL 0.29:

# Still works with deprecation warning
from trl import KTOConfig, KTOTrainer

# New recommended import
from trl.experimental.kto import KTOConfig, KTOTrainer

Related Issues

Testing

  • All existing tests updated to use experimental imports
  • Deprecation stubs maintain backward compatibility
  • No breaking changes until TRL 0.29

This commit migrates KTO trainer and config to the experimental module
as part of the TRL V1 refactoring effort.

Changes:
- Create experimental module: trl/experimental/kto/
  - Move kto_config.py with updated imports
  - Move kto_trainer.py with updated imports (.. → ...)
  - Remove TRL_EXPERIMENTAL_SILENCE warning
- Add deprecation stubs in trl/trainer/ with FutureWarning
- Update imports in tests and examples
- Update documentation and move KTO to Experimental section in toctree

Related: #4463, #4374, #4223
@HuggingFaceDocBuilderDev

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.

behroozazarkhalili and others added 3 commits November 5, 2025 19:16
…experimental

# Conflicts:
#	docs/source/_toctree.yml
- Updated trainer references in index.md, dataset_formats.md, and example_overview.md
- Moved test file to tests/experimental/ directory
- Updated test imports from relative to parent directory
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.

Move KTOTrainer to trl.experimental

3 participants