Repository navigation
GRPO: default router_aux_loss_coef to 0 on TRL >= 1.7.0 - #6938
Merged
Merged
Conversation
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.
Contributor
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This was referenced Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Default
router_aux_loss_coefto 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_coefdefaults to0.001, and the trainer setsaux_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 reducedaux_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 withrouter_aux_loss_coef > 0.This reuses the existing GRPO config-default override block in
_patch_trl_rl_trainers_impl(next tobeta,loss_type, etc.), so it is scoped togrpo_traineronly 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:
router_aux_loss_coef=0.0,aux_loss_enabled=False, trains, no aux metric.router_aux_loss_coef=0.01):aux_loss_enabled=True, trains without error.Related to #6904 (GRPO support for TRL >= 1.7.0), which carries the accompanying crash fixes.