Repository navigation
GRPO: default to TRL's dapo loss with beta 0, cap CISPO weights at 5.0 - #12088
Conversation
… 5.0 loss_type and beta now default to None sentinels resolved in the generated config: loss_type -> "dapo" on TRL >= 0.22 (TRL's default since huggingface/trl#3938; older TRL has no dapo and passes no num_items_in_batch, so "bnpo" stays there), beta -> 0.0 for dapo / dr_grpo and 0.001 otherwise. Explicit values are kept. Only an explicit loss_type="dapo" gets the DAPO paper's epsilon_high = 0.28 and mask_truncated_completions = True; the default keeps TRL's, since masking every truncated row zeroes the update when all rows are truncated. CISPO: TRL clamps the IS weight at epsilon_high itself, and an unset epsilon_high falls back to epsilon = 0.2, capping every weight below 1. Default it to 5.0 (ScaleRL eps_max, TRL's documented recipe, SkyRL's 1 + 4) and warn on an explicit value below 1. An unsloth_zoo without unsloth-zoo#1369 divides dapo / cispo / vespo by the whole generation batch; rescale num_items_in_batch to one accumulation window in that case so steps_per_generation != gradient_accumulation_steps matches TRL (huggingface/trl#6024).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
@codex security review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
… 5.0 (unslothai#12088) loss_type and beta now default to None sentinels resolved in the generated config: loss_type -> "dapo" on TRL >= 0.22 (TRL's default since huggingface/trl#3938; older TRL has no dapo and passes no num_items_in_batch, so "bnpo" stays there), beta -> 0.0 for dapo / dr_grpo and 0.001 otherwise. Explicit values are kept. Only an explicit loss_type="dapo" gets the DAPO paper's epsilon_high = 0.28 and mask_truncated_completions = True; the default keeps TRL's, since masking every truncated row zeroes the update when all rows are truncated. CISPO: TRL clamps the IS weight at epsilon_high itself, and an unset epsilon_high falls back to epsilon = 0.2, capping every weight below 1. Default it to 5.0 (ScaleRL eps_max, TRL's documented recipe, SkyRL's 1 + 4) and warn on an explicit value below 1. An unsloth_zoo without unsloth-zoo#1369 divides dapo / cispo / vespo by the whole generation batch; rescale num_items_in_batch to one accumulation window in that case so steps_per_generation != gradient_accumulation_steps matches TRL (huggingface/trl#6024).
…rch (unslothai#12274) * tests: skip two version_compat suites where the daily sweep has no torch daily-fresh-fetch in version-compat-ci.yml runs all of tests/version_compat/ after installing nothing but pytest. The other suites there that need torch skip in that job, eight of them on a module-scope find_spec("torch") guard, and two of those say why: "daily-fresh-fetch collects this directory with only pytest installed." test_trl_config_defaults_contract.py (unslothai#12069, unslothai#12088) and test_pref_max_length_clamp.py (unslothai#12069) have no guard. They pass in grpo-fake-run, which installs torch, and in the sweep every `import unsloth` stops at unsloth/_gpu_init.py's `import numpy`. The sweep passed daily up to 2026-09-26 and has failed daily since unslothai#12069 merged: 43 failed on 09-28 and 09-29, all 43 in these two files on that ModuleNotFoundError. The 09-27 run exited 1 and its log has expired. The defaults contract imports unsloth in every test, so it takes its neighbours' guard at module scope. In the clamp file seven tests read rl.py as text and still run in the sweep, so only test_patched_trainer_carries_the_clamp, which imports unsloth and trl, is guarded. test_the_daily_sweep_skips_what_it_cannot_import runs every suite the sweep collects outside the pip-free bundle in a subprocess with torch, numpy, transformers, trl, peft, accelerate and unsloth_zoo hidden, and fails on any test that fails rather than skips. workflow-trigger-lint runs that file on every pull request with no torch installed, so a suite added without the guard now fails its own pull request instead of the next morning's cron. It fails on main with the sweep's 43 tests and passes here. One consequence worth naming: the new test adds about 2 s to workflow-trigger-lint on every pull request, measured in that job's environment. * Tighten comments in the version-compat sweep guard --------- Co-authored-by: Daniel Han <[email protected]>
Follow up to #11951 and #12069. Three GRPO defaults move to match TRL and the other RL frameworks.
Changes
loss_typewhen unset"bnpo""dapo"(TRL >= 0.22). TRL 0.20 / 0.21 stay on"bnpo", since they have nodapobetawhen unset0.0010.0fordapoanddr_grpo,0.001otherwise. An explicitbetais always keptepsilon_highforloss_type="cispo"when unsetepsilon= 0.25.0A default run prints one line saying GRPO now defaults to
loss_type = 'dapo'withbeta = 0.0, and how to get the previous default back (loss_type = 'bnpo', beta = 0.001).Token-level loss is the common default now
loss_type="dapo"(huggingface/trl#3938)loss_agg_mode="token-mean"(verl-project/verl#623)loss_reduction="token_mean"(skyrl-project/SkyRL#90)loss_denominator="token"(allenai/open-instruct#1161)The DAPO paper's other two settings (
epsilon_high = 0.28,mask_truncated_completions = True) are still filled only whenloss_type="dapo"is passed explicitly, exactly as today. TRL does not turn them on for its default either, and masking every truncated row zeroes the whole update when a shortmax_completion_lengthtruncates every completion (reproduced on the tiny GRPO job: grad norm 0, adapter unchanged).beta = 0 for dapo and Dr GRPO
TRL has defaulted to
beta = 0.0since v0.19 (huggingface/trl#3516). The DAPO paper removes the KL term.beta = 0also skips the reference model forward, so memory drops.CISPO cap
TRL's CISPO loss clamps the importance sampling weight at
epsilon_highitself, not1 + epsilon_high:clamp(coef_1, max=epsilon_high).detach(). Withepsilon_highunset, TRL falls back toepsilon= 0.2, so every weight is capped at 0.2 and the gradient shrinks about 5x.5.0is the value in TRL's own docs and SkyRL's effective cap, and sits inside the range ScaleRL (arXiv 2510.13786) found equivalent ({4, 5, 8}). An explicit value is kept; one below 1 prints a warning.Who sees a change
loss_typeon TRL >= 0.22:bnpo->dapo,beta0.001 -> 0.0. Clip range and truncation masking are unchanged.dapo/dr_grpowithoutbeta: 0.001 -> 0.0.cispowithoutepsilon_high: cap 0.2 -> 5.0.HfArgumentParser/ YAML configs (the parser passes TRL's field defaults explicitly): unchanged.Tests
tests/version_compat/test_trl_config_defaults_contract.pyadds cases for the default loss type, the default keeping TRL's clip and truncation settings, beta when unset and when explicit, and the CISPO cap.test_trl_loss_normalization_contract.pynow expectsdapoon TRL >= 0.22.Base (main) vs this branch, contract files plus the preference clamp file:
jobs/grpo.py --tiny --backend unsloth --max-steps 5with a fresh compile cache passes on both sides for the default,dr_grpoandcisporuns; losses are finite, 0 graph breaks on both sides, and unique graphs drop from 10 to 7 withbeta = 0because the reference forward is skipped.cispograd norm rises from 0.0075 to 0.0373, which is the removed 0.2 cap.