Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

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

Daniel Han59977f95c318
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 62ef9e916a4..b5cadf2deae 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -1370,6 +1370,9 @@ def _patch_trl_rl_trainers_impl(trainer_file = "grpo_trainer"):
# [TODO] See https://fengyao.notion.site/off-policy-rl
# https://github.com/huggingface/trl/pull/3867 (August 7th)
"vllm_importance_sampling_correction": False,
+ # TRL >= 1.7.0 enables the MoE router aux loss by default (0.001); the optimized
+ # GRPO forward does not compute it, so default off. Opt in via router_aux_loss_coef > 0.
+ "router_aux_loss_coef": 0.0,
}
for k, v in replacements.items():
x = f"{k}( = [^,\n]{{1,}})?,\n"