Skip to content

Commit 7a0a615

Browse files
authored
Warnings pointing to RFC (#4224)
1 parent c38cb69 commit 7a0a615

File tree

9 files changed

+76
-5
lines changed

9 files changed

+76
-5
lines changed

trl/trainer/bco_trainer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717
import random
1818
import textwrap
19+
import warnings
1920
from collections import defaultdict
2021
from contextlib import contextmanager, nullcontext
2122
from operator import itemgetter
@@ -360,6 +361,13 @@ def __init__(
360361
embedding_func: Optional[Callable] = None,
361362
embedding_tokenizer: Optional[PreTrainedTokenizerBase] = None,
362363
):
364+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
365+
warnings.warn(
366+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
367+
"it and want it to remain, please share your comments here: "
368+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
369+
"TRL_EXPERIMENTAL_SILENCE=1."
370+
)
363371
if embedding_func is not None and not (is_sklearn_available() and is_joblib_available()):
364372
raise ImportError(
365373
"BCOTrainer with UDM requires the scikit-learn and joblib libraries. Please install it with `pip install scikit-learn joblib`."

trl/trainer/cpo_trainer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
# limitations under the License.
1414

1515
import inspect
16+
import os
1617
import random
1718
import textwrap
19+
import warnings
1820
from collections import defaultdict
1921
from contextlib import nullcontext
2022
from pathlib import Path
@@ -142,6 +144,13 @@ def __init__(
142144
peft_config: Optional[dict] = None,
143145
compute_metrics: Optional[Callable[[EvalLoopOutput], dict]] = None,
144146
):
147+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
148+
warnings.warn(
149+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
150+
"it and want it to remain, please share your comments here: "
151+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
152+
"TRL_EXPERIMENTAL_SILENCE=1."
153+
)
145154
if args.model_init_kwargs is None:
146155
model_init_kwargs = {}
147156
elif not isinstance(model, str):

trl/trainer/gkd_trainer.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
import random
1617
import textwrap
18+
import warnings
1719
from typing import Any, Callable, Optional, Union
1820

1921
import torch
@@ -38,11 +40,7 @@
3840
from ..models.utils import unwrap_model_for_generation
3941
from .gkd_config import GKDConfig
4042
from .sft_trainer import SFTTrainer
41-
from .utils import (
42-
DataCollatorForChatML,
43-
disable_dropout_in_model,
44-
empty_cache,
45-
)
43+
from .utils import DataCollatorForChatML, disable_dropout_in_model, empty_cache
4644

4745

4846
if is_peft_available():
@@ -127,6 +125,13 @@ def __init__(
127125
peft_config: Optional["PeftConfig"] = None,
128126
formatting_func: Optional[Callable] = None,
129127
):
128+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
129+
warnings.warn(
130+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
131+
"it and want it to remain, please share your comments here: "
132+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
133+
"TRL_EXPERIMENTAL_SILENCE=1."
134+
)
130135
# Ensure Trainer does not drop non-signature columns used by the collator (e.g., "prompts")
131136
args.remove_unused_columns = False
132137
# Respect a user-provided data_collator; otherwise, provide a ChatML collator that

trl/trainer/kto_trainer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
# limitations under the License.
1414

1515
import inspect
16+
import os
1617
import random
1718
import textwrap
19+
import warnings
1820
from collections import defaultdict
1921
from contextlib import contextmanager, nullcontext
2022
from operator import itemgetter
@@ -353,6 +355,13 @@ def __init__(
353355
model_adapter_name: Optional[str] = None,
354356
ref_adapter_name: Optional[str] = None,
355357
):
358+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
359+
warnings.warn(
360+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
361+
"it and want it to remain, please share your comments here: "
362+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
363+
"TRL_EXPERIMENTAL_SILENCE=1."
364+
)
356365
if type(args) is TrainingArguments:
357366
raise ValueError("Please use `KTOConfig` instead TrainingArguments.")
358367

trl/trainer/online_dpo_trainer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ def __init__(
206206
reward_model: Optional[Union[PreTrainedModel, nn.Module]] = None,
207207
reward_processing_class: Optional[PreTrainedTokenizerBase] = None,
208208
) -> None:
209+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
210+
warnings.warn(
211+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
212+
"it and want it to remain, please share your comments here: "
213+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
214+
"TRL_EXPERIMENTAL_SILENCE=1."
215+
)
209216
if ref_model is model:
210217
raise ValueError(
211218
"`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the "

trl/trainer/orpo_trainer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
# limitations under the License.
1414

1515
import inspect
16+
import os
1617
import random
1718
import textwrap
19+
import warnings
1820
from collections import defaultdict
1921
from contextlib import nullcontext
2022
from pathlib import Path
@@ -144,6 +146,13 @@ def __init__(
144146
peft_config: Optional[dict] = None,
145147
compute_metrics: Optional[Callable[[EvalLoopOutput], dict]] = None,
146148
):
149+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
150+
warnings.warn(
151+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
152+
"it and want it to remain, please share your comments here: "
153+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
154+
"TRL_EXPERIMENTAL_SILENCE=1."
155+
)
147156
if args.model_init_kwargs is None:
148157
model_init_kwargs = {}
149158
elif not isinstance(model, str):

trl/trainer/ppo_trainer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import textwrap
1919
import time
20+
import warnings
2021
from collections import defaultdict
2122
from contextlib import contextmanager, nullcontext
2223
from pathlib import Path
@@ -159,6 +160,13 @@ def __init__(
159160
callbacks: Optional[list[TrainerCallback]] = None,
160161
peft_config: Optional["PeftConfig"] = None,
161162
) -> None:
163+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
164+
warnings.warn(
165+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
166+
"it and want it to remain, please share your comments here: "
167+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
168+
"TRL_EXPERIMENTAL_SILENCE=1."
169+
)
162170
if ref_model is model:
163171
raise ValueError(
164172
"`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the "

trl/trainer/prm_trainer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
import textwrap
17+
import warnings
1618
from itertools import chain
1719
from pathlib import Path
1820
from typing import Callable, Optional, Union
@@ -117,6 +119,13 @@ def __init__(
117119
preprocess_logits_for_metrics: Optional[Callable[[torch.Tensor, torch.Tensor], torch.Tensor]] = None,
118120
peft_config: Optional[dict] = None,
119121
):
122+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
123+
warnings.warn(
124+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
125+
"it and want it to remain, please share your comments here: "
126+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
127+
"TRL_EXPERIMENTAL_SILENCE=1."
128+
)
120129
if peft_config is not None or (is_peft_available() and isinstance(model, PeftModel)):
121130
model = prepare_peft_model(model, peft_config, args)
122131

trl/trainer/rloo_trainer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ def __init__(
275275
ref_policy=None,
276276
data_collator=None,
277277
):
278+
if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"):
279+
warnings.warn(
280+
"This trainer will soon be moved to trl.experimental and is a candidate for removal. If you rely on "
281+
"it and want it to remain, please share your comments here: "
282+
"https://github.com/huggingface/trl/issues/4223. Silence this warning by setting environment variable "
283+
"TRL_EXPERIMENTAL_SILENCE=1."
284+
)
278285
# Handle deprecated parameters
279286
if config is not None:
280287
warnings.warn(

0 commit comments

Comments
 (0)