Skip to content

GRPO: default router_aux_loss_coef to 0 on TRL >= 1.7.0 - #6938

Merged
danielhanchen merged 1 commit into
mainfrom
danielhanchen/grpo-aux-loss-default-off
Jul 7, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
danielhanchen/grpo-aux-loss-default-off

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Default router_aux_loss_coef to 0 for GRPO on TRL >= 1.7.0.

TRL 1.7.0 added the MoE router load-balancing auxiliary loss to GRPO and enables it by default: router_aux_loss_coef defaults to 0.001, and the trainer sets aux_loss_enabled = is_moe and router_aux_loss_coef != 0.0, so it is on for any MoE model. Unsloth's optimized GRPO forward returns hidden states and does not compute the reduced aux_loss. Rather than add or log a placeholder value, this defaults the coefficient to 0 so the term is genuinely off, matching every pre-1.7.0 release. Users who want it can still opt in with router_aux_loss_coef > 0.

This reuses the existing GRPO config-default override block in _patch_trl_rl_trainers_impl (next to beta, loss_type, etc.), so it is scoped to grpo_trainer only and is a no-op on TRL < 1.7.0 where the argument does not exist.

Testing

Verified on TRL 1.7.1 (tiny Qwen3-MoE) and TRL 0.25.1:

  • GRPO default: router_aux_loss_coef=0.0, aux_loss_enabled=False, trains, no aux metric.
  • GRPO opt-in (router_aux_loss_coef=0.01): aux_loss_enabled=True, trains without error.
  • SFT and DPO train unchanged.
  • No-op on TRL < 1.7.0.

Related to #6904 (GRPO support for TRL >= 1.7.0), which carries the accompanying crash fixes.

TRL 1.7.0 enables the MoE router load-balancing aux loss by default
(router_aux_loss_coef = 0.001). Unsloth's optimized GRPO forward does not
compute it, so default the coefficient to 0, matching pre-1.7.0 behaviour.
Users can still opt in with router_aux_loss_coef > 0. No-op on TRL < 1.7.0.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 2de3a3f5c4

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 59977f9 into main Jul 7, 2026
50 checks passed
@danielhanchen
danielhanchen deleted the danielhanchen/grpo-aux-loss-default-off branch July 7, 2026 12:49
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.

1 participant