Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions trl/trainer/bco_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import random
import textwrap
import warnings
from collections import defaultdict
from contextlib import contextmanager, nullcontext
from operator import itemgetter
Expand Down Expand Up @@ -360,6 +361,13 @@ def __init__(
embedding_func: Optional[Callable] = None,
embedding_tokenizer: Optional[PreTrainedTokenizerBase] = None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if embedding_func is not None and not (is_sklearn_available() and is_joblib_available()):
raise ImportError(
"BCOTrainer with UDM requires the scikit-learn and joblib libraries. Please install it with `pip install scikit-learn joblib`."
Expand Down
9 changes: 9 additions & 0 deletions trl/trainer/cpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# limitations under the License.

import inspect
import os
import random
import textwrap
import warnings
from collections import defaultdict
from contextlib import nullcontext
from pathlib import Path
Expand Down Expand Up @@ -142,6 +144,13 @@ def __init__(
peft_config: Optional[dict] = None,
compute_metrics: Optional[Callable[[EvalLoopOutput], dict]] = None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if args.model_init_kwargs is None:
model_init_kwargs = {}
elif not isinstance(model, str):
Expand Down
15 changes: 10 additions & 5 deletions trl/trainer/gkd_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import random
import textwrap
import warnings
from typing import Any, Callable, Optional, Union

import torch
Expand All @@ -38,11 +40,7 @@
from ..models.utils import unwrap_model_for_generation
from .gkd_config import GKDConfig
from .sft_trainer import SFTTrainer
from .utils import (
DataCollatorForChatML,
disable_dropout_in_model,
empty_cache,
)
from .utils import DataCollatorForChatML, disable_dropout_in_model, empty_cache


if is_peft_available():
Expand Down Expand Up @@ -127,6 +125,13 @@ def __init__(
peft_config: Optional["PeftConfig"] = None,
formatting_func: Optional[Callable] = None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
# Ensure Trainer does not drop non-signature columns used by the collator (e.g., "prompts")
args.remove_unused_columns = False
# Respect a user-provided data_collator; otherwise, provide a ChatML collator that
Expand Down
9 changes: 9 additions & 0 deletions trl/trainer/kto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# limitations under the License.

import inspect
import os
import random
import textwrap
import warnings
from collections import defaultdict
from contextlib import contextmanager, nullcontext
from operator import itemgetter
Expand Down Expand Up @@ -353,6 +355,13 @@ def __init__(
model_adapter_name: Optional[str] = None,
ref_adapter_name: Optional[str] = None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if type(args) is TrainingArguments:
raise ValueError("Please use `KTOConfig` instead TrainingArguments.")

Expand Down
7 changes: 7 additions & 0 deletions trl/trainer/online_dpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ def __init__(
reward_model: Optional[Union[PreTrainedModel, nn.Module]] = None,
reward_processing_class: Optional[PreTrainedTokenizerBase] = None,
) -> None:
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if ref_model is model:
raise ValueError(
"`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the "
Expand Down
9 changes: 9 additions & 0 deletions trl/trainer/orpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# limitations under the License.

import inspect
import os
import random
import textwrap
import warnings
from collections import defaultdict
from contextlib import nullcontext
from pathlib import Path
Expand Down Expand Up @@ -144,6 +146,13 @@ def __init__(
peft_config: Optional[dict] = None,
compute_metrics: Optional[Callable[[EvalLoopOutput], dict]] = None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if args.model_init_kwargs is None:
model_init_kwargs = {}
elif not isinstance(model, str):
Expand Down
8 changes: 8 additions & 0 deletions trl/trainer/ppo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import textwrap
import time
import warnings
from collections import defaultdict
from contextlib import contextmanager, nullcontext
from pathlib import Path
Expand Down Expand Up @@ -159,6 +160,13 @@ def __init__(
callbacks: Optional[list[TrainerCallback]] = None,
peft_config: Optional["PeftConfig"] = None,
) -> None:
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if ref_model is model:
raise ValueError(
"`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the "
Expand Down
9 changes: 9 additions & 0 deletions trl/trainer/prm_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import textwrap
import warnings
from itertools import chain
from pathlib import Path
from typing import Callable, Optional, Union
Expand Down Expand Up @@ -117,6 +119,13 @@ def __init__(
preprocess_logits_for_metrics: Optional[Callable[[torch.Tensor, torch.Tensor], torch.Tensor]] = None,
peft_config: Optional[dict] = None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
if peft_config is not None or (is_peft_available() and isinstance(model, PeftModel)):
model = prepare_peft_model(model, peft_config, args)

Expand Down
7 changes: 7 additions & 0 deletions trl/trainer/rloo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ def __init__(
ref_policy=None,
data_collator=None,
):
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
warnings.warn(
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
"it and want it to remain, please share your comments here: "
"https://github.com/huggingface/trl/issues/1234. Silence this warning by setting environment variable "
"TRL_EXPERIMENTAL_SILENCE=1."
)
# Handle deprecated parameters
if config is not None:
warnings.warn(
Expand Down
Loading