Skip to content

Move disable_config=True from generate to GenerationConfig#5384

Merged
qgallouedec merged 5 commits into
mainfrom
fix-deprecated
Mar 28, 2026
Merged

Move disable_config=True from generate to GenerationConfig#5384
qgallouedec merged 5 commits into
mainfrom
fix-deprecated

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Mar 27, 2026

Copy link
Copy Markdown
Member
from datasets import load_dataset
from trl import GRPOTrainer
from trl.rewards import accuracy_reward

dataset = load_dataset("trl-lib/DeepMath-103K", split="train[:7]")

trainer = GRPOTrainer(
    model="Qwen/Qwen2.5-0.5B-Instruct",
    reward_funcs=accuracy_reward,
    train_dataset=dataset,
)
trainer.train()

Before

Loading weights: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 290/290 [00:00<00:00, 1315.45it/s]
The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'bos_token_id': None, 'pad_token_id': 151643}.
  0%|                                                                                                                                     | 0/21 [00:00<?, ?it/s]
Passing `generation_config` together with generation-related arguments=({'disable_compile'}) is deprecated and will be removed in future versions. Please pass either a `generation_config` object OR all generation parameters explicitly, but not both.                                                

After

Loading weights: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 290/290 [00:04<00:00, 69.44it/s]
The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'bos_token_id': None, 'pad_token_id': 151643}.

Note

Low Risk
Low risk behavioral change that only affects how disable_compile is passed into Transformers generation, primarily to avoid deprecation warnings; generation outputs should remain the same aside from compile/graph behavior.

Overview
Moves disable_compile=True from individual model.generate(...) calls into the trainers’ GenerationConfig construction (GRPO, RLOO, SDFT, and experimental self-distillation), and updates generation call sites to pass only generation_config.

This eliminates the Transformers deprecation warning about mixing generation_config with extra generation kwargs while keeping compilation disabled during rollout generation.

Written by Cursor Bugbot for commit 528f44b. This will update automatically on new commits. Configure here.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81d5f90e68

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if args.generation_kwargs is not None:
generation_kwargs.update(args.generation_kwargs)
self.generation_config = GenerationConfig(**generation_kwargs)
self.generation_config = GenerationConfig(**generation_kwargs, disable_compile=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle user-provided disable_compile without crashing

Because args.generation_kwargs is merged into generation_kwargs immediately above, this constructor will now fail with TypeError if a caller already passes disable_compile in generation_kwargs (for example from CLI/JSON config), since Python sees the key twice (**generation_kwargs and disable_compile=True). That makes training crash during init for a previously valid input path; the same duplicated pattern is also present in the corresponding RLOO and self-distillation constructors.

Useful? React with 👍 / 👎.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread trl/experimental/dppo/dppo_trainer.py Outdated
Comment thread trl/trainer/grpo_trainer.py

@albertvillanova albertvillanova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks.

@qgallouedec qgallouedec merged commit 79e6e79 into main Mar 28, 2026
14 of 15 checks passed
@qgallouedec qgallouedec deleted the fix-deprecated branch March 28, 2026 14:52
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.

3 participants