Skip to content

Conversation

@behroozazarkhalili
Copy link
Collaborator

Summary

This PR moves ORPOTrainer and ORPOConfig from trl.trainer to trl.experimental.orpo as part of the TRL V1 refactoring effort.

Changes

  • Moved ORPOTrainer and ORPOConfig to trl.experimental.orpo
  • Created deprecation stubs in trl.trainer with FutureWarning (removal planned for TRL 0.29.0)
  • Updated all imports in:
    • Tests (tests/test_orpo_trainer.py)
    • Examples (examples/scripts/orpo.py)
    • Documentation (docs/source/orpo_trainer.md, docs/source/_toctree.yml)
  • Removed ORPO from main trl.trainer exports
  • Maintained full backward compatibility through deprecation stubs

Testing

  • All existing tests pass with updated imports
  • Deprecation warnings are shown when using old imports
  • Example scripts work correctly with new import paths

Fixes #4465
Contributes to #4374

- Move ORPOTrainer and ORPOConfig to trl.experimental.orpo
- Add deprecation warnings in trl.trainer with removal planned for TRL 0.29.0
- Update imports in tests, examples, and documentation
- Maintain backward compatibility through deprecation stubs

Fixes #4465
@qgallouedec
Copy link
Member

nice, you'll need to replace all [`ORPOTrainer`] by [`experimental.orpo.ORPOTrainer`] as well

Comment on lines 124 to 131
[[autodoc]] ORPOTrainer
- train
- save_model
- push_to_hub

## ORPOConfig

[[autodoc]] ORPOConfig
Copy link
Member

Choose a reason for hiding this comment

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

You need to update this as well

[[autodoc]] experimental.orpo.ORPOTrainer
[[autodoc]] experimental.orpo.ORPOConfig

Comment on lines 117 to 118
from .orpo_config import ORPOConfig
from .orpo_trainer import ORPOTrainer
Copy link
Member

Choose a reason for hiding this comment

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

you need to revert this change, otherwise from trl import ORPOTrainer won't work anymore

Copy link
Member

Choose a reason for hiding this comment

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

could you move this file to tests/experimental


from ..data_utils import maybe_apply_chat_template, maybe_extract_prompt
from .base_trainer import BaseTrainer
from ..experimental.orpo import ORPOTrainer as ExperimentalORPOTrainer
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from ..experimental.orpo import ORPOTrainer as ExperimentalORPOTrainer
from ..experimental.orpo import ORPOTrainer as _ORPOTrainer

for consistency


if is_wandb_available():
import wandb
class ORPOTrainer(ExperimentalORPOTrainer):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class ORPOTrainer(ExperimentalORPOTrainer):
class ORPOTrainer(_ORPOTrainer):

@qgallouedec
Copy link
Member

there are some tests in tests/test_trainers_args.py that need to be moved to test/experimental/test_trainer_args.py as well

Comment on lines 52 to 54
from ..base_trainer import BaseTrainer
from .orpo_config import ORPOConfig
from ..utils import (
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from ..base_trainer import BaseTrainer
from .orpo_config import ORPOConfig
from ..utils import (
from ...trainer.base_trainer import BaseTrainer
from .orpo_config import ORPOConfig
from ...trainer.utils import (


import numpy as np
import pandas as pd
import torch
Copy link
Member

Choose a reason for hiding this comment

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

torch import should remain, some type hints need it

- Restore ORPO imports in trl/trainer/__init__.py for backward compatibility
- Fix deprecation stub naming from ExperimentalORPOTrainer to _ORPOTrainer
- Add torch import to deprecation stub for type hints
- Fix relative import paths in trl/experimental/orpo/orpo_trainer.py
- Update autodoc references to experimental.orpo.ORPOTrainer
- Update all documentation references to use experimental namespace
- Move ORPO test from test_trainers_args.py to experimental/test_trainers_args.py
@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.

- Remove unused 'import os' and 'import warnings' from trl/experimental/orpo/orpo_trainer.py
- Remove unused 'from typing import Any' from trl/trainer/orpo_trainer.py
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 ORPOTrainer to trl.experimental

4 participants