From fc7a40159748f325ae621e55ccac155c77e9ae73 Mon Sep 17 00:00:00 2001 From: Taha YASSINE Date: Tue, 11 Nov 2025 23:10:57 +0100 Subject: [PATCH 1/6] Replace `wandb_log_unique_prompts` with `log_unique_prompts` --- trl/trainer/grpo_config.py | 28 +++++++++++++++++++++++++--- trl/trainer/grpo_trainer.py | 4 ++-- trl/trainer/rloo_config.py | 29 ++++++++++++++++++++++++++--- trl/trainer/rloo_trainer.py | 4 ++-- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/trl/trainer/grpo_config.py b/trl/trainer/grpo_config.py index a244647b7c5..236e2a7fbd4 100644 --- a/trl/trainer/grpo_config.py +++ b/trl/trainer/grpo_config.py @@ -258,9 +258,19 @@ class GRPOConfig(TrainingArguments): `trackio`. num_completions_to_print (`int`, *optional*): Number of completions to print with `rich`. If `None`, all completions are logged. + log_unique_prompts (`bool`, *optional*, defaults to `False`): + Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are + logged. wandb_log_unique_prompts (`bool`, *optional*, defaults to `False`): Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts are logged. + + + + Parameter `wandb_log_unique_prompts` is deprecated and will be removed in version 0.x.0. Use + `log_unique_prompts` instead. + + """ _VALID_DICT_FIELDS = TrainingArguments._VALID_DICT_FIELDS + ["model_init_kwargs"] @@ -671,13 +681,16 @@ class GRPOConfig(TrainingArguments): default=None, metadata={"help": "Number of completions to print with `rich`. If `None`, all completions are logged."}, ) - wandb_log_unique_prompts: bool | None = field( + log_unique_prompts: bool = field( default=False, metadata={ - "help": "Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, " - "all prompts are logged." + "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged." }, ) + wandb_log_unique_prompts: bool | None = field( + default=False, + metadata={"help": "Deprecated, use `log_unique_prompts` instead."}, + ) def __post_init__(self): self.bf16 = not (self.fp16) if self.bf16 is None else self.bf16 @@ -741,3 +754,12 @@ def __post_init__(self): if self.delta is not None and self.use_liger_kernel: raise ValueError("Liger kernel does not support two-sided GRPO loss yet.") + + if self.wandb_log_unique_prompts is not False: + warnings.warn( + "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please use " + "`log_unique_prompts` instead.", + FutureWarning, + stacklevel=2, + ) + self.log_unique_prompts = self.wandb_log_unique_prompts diff --git a/trl/trainer/grpo_trainer.py b/trl/trainer/grpo_trainer.py index 3fa73c26ba9..b66a328ad38 100644 --- a/trl/trainer/grpo_trainer.py +++ b/trl/trainer/grpo_trainer.py @@ -532,7 +532,7 @@ def cast_outputs_to_original_dtype(module, args, output): self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} self._total_train_tokens = 0 self.log_completions = args.log_completions - self.wandb_log_unique_prompts = args.wandb_log_unique_prompts + self.log_unique_prompts = args.log_unique_prompts self.num_completions_to_print = args.num_completions_to_print # Keep logs sized to the generation batch to record only outputs from the latest model update. self._logs = { @@ -1969,7 +1969,7 @@ def log(self, logs: dict[str, float], start_time: float | None = None) -> None: else: df = df_base - if self.wandb_log_unique_prompts: + if self.log_unique_prompts: df = df.drop_duplicates(subset=["prompt"]) logging_backend.log({"completions": logging_backend.Table(dataframe=df)}) diff --git a/trl/trainer/rloo_config.py b/trl/trainer/rloo_config.py index 1645d4741bf..ebdc6f1ae3c 100644 --- a/trl/trainer/rloo_config.py +++ b/trl/trainer/rloo_config.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings from dataclasses import dataclass, field from transformers import TrainingArguments @@ -191,9 +192,19 @@ class RLOOConfig(TrainingArguments): `trackio`. num_completions_to_print (`int`, *optional*): Number of completions to print with `rich`. If `None`, all completions are logged. + log_unique_prompts (`bool`, *optional*, defaults to `False`): + Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are + logged. wandb_log_unique_prompts (`bool`, *optional*, defaults to `False`): Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts are logged. + + + + Parameter `wandb_log_unique_prompts` is deprecated and will be removed in version 0.x.0. Use + `log_unique_prompts` instead. + + """ _VALID_DICT_FIELDS = TrainingArguments._VALID_DICT_FIELDS + ["model_init_kwargs"] @@ -520,13 +531,16 @@ class RLOOConfig(TrainingArguments): default=None, metadata={"help": "Number of completions to print with `rich`. If `None`, all completions are logged."}, ) - wandb_log_unique_prompts: bool | None = field( + log_unique_prompts: bool = field( default=False, metadata={ - "help": "Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, " - "all prompts are logged." + "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged." }, ) + wandb_log_unique_prompts: bool | None = field( + default=False, + metadata={"help": "Deprecated, use `log_unique_prompts` instead."}, + ) def __post_init__(self): self.bf16 = not (self.fp16) if self.bf16 is None else self.bf16 @@ -576,3 +590,12 @@ def __post_init__(self): "RLOO requires at least 2 generations per prompt to calculate the advantages. You provided " f"{self.num_generations}, which is less than the minimum required." ) + + if self.wandb_log_unique_prompts is not False: + warnings.warn( + "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please use " + "`log_unique_prompts` instead.", + FutureWarning, + stacklevel=2, + ) + self.log_unique_prompts = self.wandb_log_unique_prompts diff --git a/trl/trainer/rloo_trainer.py b/trl/trainer/rloo_trainer.py index d4a192f9bb3..7c8f9248d65 100644 --- a/trl/trainer/rloo_trainer.py +++ b/trl/trainer/rloo_trainer.py @@ -449,7 +449,7 @@ def __init__( self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} self._total_train_tokens = 0 self.log_completions = args.log_completions - self.wandb_log_unique_prompts = args.wandb_log_unique_prompts + self.log_unique_prompts = args.log_unique_prompts self.num_completions_to_print = args.num_completions_to_print # Keep logs sized to the generation batch to record only outputs from the latest model update. self._logs = { @@ -1564,7 +1564,7 @@ def log(self, logs: dict[str, float], start_time: float | None = None) -> None: else: df = df_base - if self.wandb_log_unique_prompts: + if self.log_unique_prompts: df = df.drop_duplicates(subset=["prompt"]) logging_backend.log({"completions": logging_backend.Table(dataframe=df)}) From deabf3f13a36cef09fe91dc6c7c316c372599510 Mon Sep 17 00:00:00 2001 From: Taha YASSINE Date: Wed, 12 Nov 2025 13:44:52 +0100 Subject: [PATCH 2/6] Update deprecation notice to version 0.27.0 --- trl/trainer/grpo_config.py | 7 ++++++- trl/trainer/rloo_config.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/trl/trainer/grpo_config.py b/trl/trainer/grpo_config.py index 236e2a7fbd4..d7bc2b45768 100644 --- a/trl/trainer/grpo_config.py +++ b/trl/trainer/grpo_config.py @@ -261,13 +261,16 @@ class GRPOConfig(TrainingArguments): log_unique_prompts (`bool`, *optional*, defaults to `False`): Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged. + + > Deprecated arguments + wandb_log_unique_prompts (`bool`, *optional*, defaults to `False`): Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts are logged. - Parameter `wandb_log_unique_prompts` is deprecated and will be removed in version 0.x.0. Use + Parameter `wandb_log_unique_prompts` is deprecated and will be removed in version 0.27.0. Use `log_unique_prompts` instead. @@ -687,6 +690,8 @@ class GRPOConfig(TrainingArguments): "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged." }, ) + + # Deprecated arguments wandb_log_unique_prompts: bool | None = field( default=False, metadata={"help": "Deprecated, use `log_unique_prompts` instead."}, diff --git a/trl/trainer/rloo_config.py b/trl/trainer/rloo_config.py index ebdc6f1ae3c..fa1e6609f64 100644 --- a/trl/trainer/rloo_config.py +++ b/trl/trainer/rloo_config.py @@ -195,13 +195,16 @@ class RLOOConfig(TrainingArguments): log_unique_prompts (`bool`, *optional*, defaults to `False`): Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged. + + > Deprecated arguments + wandb_log_unique_prompts (`bool`, *optional*, defaults to `False`): Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts are logged. - Parameter `wandb_log_unique_prompts` is deprecated and will be removed in version 0.x.0. Use + Parameter `wandb_log_unique_prompts` is deprecated and will be removed in version 0.27.0. Use `log_unique_prompts` instead. @@ -537,6 +540,8 @@ class RLOOConfig(TrainingArguments): "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged." }, ) + + # Deprecated arguments wandb_log_unique_prompts: bool | None = field( default=False, metadata={"help": "Deprecated, use `log_unique_prompts` instead."}, From 780144bd967dc785d31b7ab2a13576ea3e6e91d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Gallou=C3=A9dec?= <45557362+qgallouedec@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:27:02 -0700 Subject: [PATCH 3/6] Apply suggestions from code review --- trl/trainer/grpo_config.py | 8 +++----- trl/trainer/rloo_config.py | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/trl/trainer/grpo_config.py b/trl/trainer/grpo_config.py index d7bc2b45768..3de734d742f 100644 --- a/trl/trainer/grpo_config.py +++ b/trl/trainer/grpo_config.py @@ -264,9 +264,7 @@ class GRPOConfig(TrainingArguments): > Deprecated arguments - wandb_log_unique_prompts (`bool`, *optional*, defaults to `False`): - Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts - are logged. + wandb_log_unique_prompts (`bool`, *optional*): @@ -693,7 +691,7 @@ class GRPOConfig(TrainingArguments): # Deprecated arguments wandb_log_unique_prompts: bool | None = field( - default=False, + default=None, metadata={"help": "Deprecated, use `log_unique_prompts` instead."}, ) @@ -760,7 +758,7 @@ def __post_init__(self): if self.delta is not None and self.use_liger_kernel: raise ValueError("Liger kernel does not support two-sided GRPO loss yet.") - if self.wandb_log_unique_prompts is not False: + if self.wandb_log_unique_prompts is not None: warnings.warn( "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please use " "`log_unique_prompts` instead.", diff --git a/trl/trainer/rloo_config.py b/trl/trainer/rloo_config.py index fa1e6609f64..40e25dd59f7 100644 --- a/trl/trainer/rloo_config.py +++ b/trl/trainer/rloo_config.py @@ -198,7 +198,7 @@ class RLOOConfig(TrainingArguments): > Deprecated arguments - wandb_log_unique_prompts (`bool`, *optional*, defaults to `False`): + wandb_log_unique_prompts (`bool`, *optional*): Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts are logged. @@ -543,7 +543,7 @@ class RLOOConfig(TrainingArguments): # Deprecated arguments wandb_log_unique_prompts: bool | None = field( - default=False, + default=None, metadata={"help": "Deprecated, use `log_unique_prompts` instead."}, ) @@ -596,7 +596,7 @@ def __post_init__(self): f"{self.num_generations}, which is less than the minimum required." ) - if self.wandb_log_unique_prompts is not False: + if self.wandb_log_unique_prompts is not None: warnings.warn( "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please use " "`log_unique_prompts` instead.", From e5fdd5df606fdc6f77209c0ec85d24b7d602ce27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Gallou=C3=A9dec?= Date: Wed, 12 Nov 2025 23:29:13 +0000 Subject: [PATCH 4/6] last fixes --- trl/trainer/grpo_config.py | 6 +++--- trl/trainer/rloo_config.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/trl/trainer/grpo_config.py b/trl/trainer/grpo_config.py index 3de734d742f..be2f611ee2c 100644 --- a/trl/trainer/grpo_config.py +++ b/trl/trainer/grpo_config.py @@ -264,7 +264,7 @@ class GRPOConfig(TrainingArguments): > Deprecated arguments - wandb_log_unique_prompts (`bool`, *optional*): + wandb_log_unique_prompts (`bool`, *optional*): @@ -760,8 +760,8 @@ def __post_init__(self): if self.wandb_log_unique_prompts is not None: warnings.warn( - "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please use " - "`log_unique_prompts` instead.", + "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please " + "use `log_unique_prompts` instead.", FutureWarning, stacklevel=2, ) diff --git a/trl/trainer/rloo_config.py b/trl/trainer/rloo_config.py index 40e25dd59f7..9dd35205703 100644 --- a/trl/trainer/rloo_config.py +++ b/trl/trainer/rloo_config.py @@ -537,7 +537,8 @@ class RLOOConfig(TrainingArguments): log_unique_prompts: bool = field( default=False, metadata={ - "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are logged." + "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all " + "prompts are logged." }, ) @@ -598,8 +599,8 @@ def __post_init__(self): if self.wandb_log_unique_prompts is not None: warnings.warn( - "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please use " - "`log_unique_prompts` instead.", + "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.27.0. Please " + "use `log_unique_prompts` instead.", FutureWarning, stacklevel=2, ) From 5a7e33036b4293ec16d524f4d340d7dae43c54f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Gallou=C3=A9dec?= Date: Wed, 12 Nov 2025 23:29:40 +0000 Subject: [PATCH 5/6] version fix --- trl/trainer/grpo_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trl/trainer/grpo_config.py b/trl/trainer/grpo_config.py index be2f611ee2c..dfb2af4a32c 100644 --- a/trl/trainer/grpo_config.py +++ b/trl/trainer/grpo_config.py @@ -760,7 +760,7 @@ def __post_init__(self): if self.wandb_log_unique_prompts is not None: warnings.warn( - "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.x.0. Please " + "The `wandb_log_unique_prompts` argument is deprecated and will be removed in version 0.27.0. Please " "use `log_unique_prompts` instead.", FutureWarning, stacklevel=2, From 1daf009476daf6a995283837c8192d23862bc641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Gallou=C3=A9dec?= Date: Wed, 12 Nov 2025 23:30:48 +0000 Subject: [PATCH 6/6] rm desc --- trl/trainer/rloo_config.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/trl/trainer/rloo_config.py b/trl/trainer/rloo_config.py index a22fc0a4cdb..eb893c604c8 100644 --- a/trl/trainer/rloo_config.py +++ b/trl/trainer/rloo_config.py @@ -199,8 +199,6 @@ class RLOOConfig(TrainingArguments): > Deprecated arguments wandb_log_unique_prompts (`bool`, *optional*): - Whether to log unique prompts in wandb. If `True`, only unique prompts are logged. If `False`, all prompts - are logged.