GRPO Plus (v0.50.0)
22 features. Unsloth + axolotl GRPO parity.
7 GRPO variants
task: grpo
training:
grpo_variant: gspo # standard | gspo | dapo | dr_grpo | bnpo | two_sided | rft
grpo_delta: 0.5 # required for two_sided, optional for gspo (clip radius,
# default 0.2). (0, 1]. Rejected on every other variant
grpo_fp16: true # explicit FP16 mixed precisionEverything on this page is the transformers backend. backend: mlx trains GRPO natively since v0.77.1 (on a dense base, or since v0.77.2 a base pre-quantized by mlx-lm at 4 bits in affine mode, such as an mlx-community/...-4bit repository; both are covered only by the hosted macOS MLX test job and were not exercised by hand before the release), with TRL's default loss_type: dapo objective, the built-in accuracy and format rewards, and none of the variants, rewards, rollout backends or stability settings below: grpo_variant and judge_rank are refused at config load there. See GRPO on MLX.
The KL penalty: every variant applies grpo_beta (v0.76.0)
gspo, dapo, dr_grpo, bnpo, two_sided and rft train with a KL penalty of training.grpo_beta (default 0.1) against the reference policy (#1232). Each variant adds trl 0.29's per-token estimator exp(ref - logp) - (ref - logp) - 1, weighted by grpo_beta, to its per-token loss before its own reduction; rft applies it only to the completions it accepts and trains on. On a real trainer, the dapo loss and gradient equal trl's stock dapo ones at beta 0.1, 1 and 10 on the same generated batch. No speed or quality effect of the penalty is claimed.
(Since closed in v0.76.0: through v0.75.2 these variants validated grpo_beta and dropped it. The variant loss replaces trl's _compute_loss, the one place trl adds the KL term on Soup's path, so neither grpo_beta nor the beta the reward-hack controller sets at runtime changed the loss or the gradient, while trl still ran the reference forward on every step.) A variant config from v0.75.x trained with no KL term, and a v0.76.0 run of the same config will not reproduce it. If a recipe relied on the old behaviour (a dapo or dr_grpo recipe that expects to be KL-free), set grpo_beta: 0 explicitly.
grpo_beta: 0is valid (#1247). It turns the KL penalty off, as the KL-free DAPO and Dr. GRPO recipes do, and it skips the reference-model forward pass. It is refused together withreward_hack_mitigation: kl_controlorpid_lagrangian, because the controller needs a positive beta to steer:grpo_beta: 0 is mutually exclusive with reward_hack_mitigation='kl_control' (the mitigation controller requires a positive beta to steer); use grpo_beta > 0 or disable mitigation. A boolean or NaNgrpo_betais refused.- The
klmetric is logged again for a variant with a non-zerogrpo_beta, as trl's stock loss does: the masked batch mean of the per-token KL, averaged over the accepted tokens forrft(#1263). - Ratios are clamped before exponentiation (#1609). The kernels bound the importance ratio and the sequence ratio from above with a bound that adapts to the advantage's magnitude, and mask padding with a boolean mask, so a diverging policy no longer turns infinite terms into NaN parameter gradients. A run that went to NaN under a non-standard
grpo_variantbefore v0.76.0 may have hit this. - Non-finite steps are skipped, for every
task: grporun (#342). A gradient watchdog zeroes non-finite gradients before the optimizer step, so that step updates nothing and the adapter is preserved. The step still counts toward the step total and the learning-rate schedule. The skipped-step count and fraction are saved intrainer_state.json, a run that skipped 5% or more of its steps prints aGradient watchdog:warning at the end, andsoup adapters auditreports the figure. Since v0.77.0 each skipped step's warning names how many parameters went non-finite and the first three of them, andtrainer_state.jsonkeeps the count and the first five names per step and for the run (nan_param_count,nan_param_names) (#2060). Through v0.77.2 the names were read after the gradient clip, which upstream says one NaN makes non-finite everywhere, so a single NaN listed every trainable parameter. Since v0.78.0 (#2601, by @ybai08) they are read before the clip, and each skipped step and the run summary carrynan_param_names_source(before_clip, orafter_clipwhen that is not known). - One input-gradient hook, not one per step (v0.77.2, #2373, by @ybai08). With
training.gradient_checkpointingon, the trl GRPO loop switches checkpointing off and back on around generation, and each switch registered one more input-gradient hook on the policy's input embedding that transformers never removed, so every generated token ran one more hook per step already taken. Soup now removes the previous hook on each registration, so the count stays at its value after the first step and the embedding output still requires grad. The same change coversppoandonline_dpo. Read from upstream's changelog and tests; no speed figure is published for it. - Validation.
task: grpodoes not evaluate by default and does not holddata.val_splitout of training: the split is ignored, every row trains, and the run prints a one-line note saying so. Settraining.eval_stepsto hold the split out and evaluate it; the validation number is then the held-out reward,eval_reward(#1223, #1389). See Training methods. Onbackend: mlxthe split is always held out instead and scored once after training asval_reward, andeval_stepsis refused. - Gold answers.
reward_fn: accuracyand the verifiablemathdomain now read the gold the way they read the completion, and a gold that states no single final answer is refused before generation. See RLVR.
Re-run this
| If you trained | What was wrong | What to do |
|---|---|---|
task: grpo with grpo_variant other than standard | The variant dropped grpo_beta, so it trained with no KL term while trl still ran the reference forward each step (#1232). With reward_hack_mitigation, the controller moved a beta the loss ignored | Re-run if you need the KL-regularised behaviour. Set grpo_beta: 0 to keep the KL-free behaviour on purpose |
task: grpo with grpo_variant other than standard, and a run that went to NaN | Importance ratios were exponentiated without a bound, so a diverging policy could produce infinite terms and NaN gradients (#1609) | Re-run. v0.76.0 clamps the ratio |
task: grpo resumed with --resume, before v0.77.0 | Upstream: --resume "restored the optimizer and the step counter and trained a freshly initialised adapter" (#1768, #1797). grpo with grpo_beta: 0 writes no reference adapter and was not affected | Upstream: "Re-run any dpo, ipo or grpo training that was resumed from a checkpoint." |
task: grpo with grpo_beta above 0 and training.relora_steps, on v0.76.0 or v0.76.1 | Every ReLoRA restart merged the trained adapter into the base weights trl reads the reference from, "so from the first restart on the reference was the policy as of that step, without an error" (#1835, #1891). Refused at config load since v0.77.0 | Re-run without relora_steps, or with grpo_beta: 0, which keeps ReLoRA |
task: grpo with reward_fn: accuracy, or reward_fn: verifiable with verifiable_domain: math | See RLVR: the gold was compared raw, and accuracy paid 0.5 for a gold that merely appeared in the completion | Re-run if the logged reward sat near 0.0 |
LLM judge ranking reward: judge_rank (v0.77.0)
For a task with no checkable answer, reward_fn: judge_rank asks an LLM judge to compare each prompt's completions with each other (#2047, #2117, by @ybai08). GRPO compares completions only within one prompt's group, so one judge call sees all num_generations completions of a prompt and scores each from 0 to 1 against the others, in a fresh order on every call (seeded from training.seed). It also runs in an ensemble, such as reward_fn: "format,judge_rank". Where an answer can be checked, a rule-based reward (accuracy, verifiable, a .py file) is cheaper.
task: grpo
training:
reward_fn: judge_rank
grpo_judge: "ollama://llama3.1" # or https://host/model, http://localhost:8000/model
grpo_judge_max_calls: 20000 # required, no default
gradient_checkpointing: trueOptional: grpo_judge_rubric (a file under the working directory; only each criterion's name and description are used, and without one the judge uses Soup's default criteria; since v0.78.0 a rubric whose criteria repeat a name, compared lower-cased and trimmed, or that carries a weight that is not a finite number is refused before any request is sent, #2698 and #2700, checked on soup eval judge --rubric, which shares the loader, and not run through a GRPO config), grpo_judge_max_tokens (the judge's reply budget per call) and grpo_judge_max_failure_rate (the share of failed groups the run tolerates).
- It sends your data out. Every prompt and every completion goes to the judge host you configure.
grpo_judgetakes a judge URL (ollama://<model>,https://host/model, orhttp://to a loopback host) and is checked when the config loads: plainhttponly to a loopback host, and no private, link-local or reserved IP literal (see private addresses refused). (training.online_dpo_judgerefuses such an IP literal at load too, and checks plainhttplater, at trainer setup.) Judge replies are bounded to 1 MiB. - It has a cost ceiling, and you have to state it.
grpo_judge_max_callshas no default. After the dataset loads and before the model does,soup train(andsoup train --dry-run) counts the calls the run could make,(train rows x epochs + held-out rows x evaluations) x 2for the one retry of an unreadable reply, and refuses the run with exit 1 and aJudge budget:line naming the value to raise it to. Held-out rows count only whentraining.eval_stepsis set. Inside each counted call a 429, a 5xx, a timeout or a lost connection is retried up to twice, so the judge host can see up to three requests per counted call. - A group the judge failed on scores nothing, not zero. A reply that is not a JSON object with one score in [0, 1] per completion is asked for once more. A group that still has no scores gets no reward and no advantage. The run logs
judge/failed_group_rateandjudge/equal_score_group_rate(groups whose completions all scored the same), and stops with an error naming the judge once more thangrpo_judge_max_failure_rateof at least 20 training groups failed. A judge that cannot be reached ends the run. - Refused when the config loads:
judge_rankon any task butgrpo, onbackend: mlx, withmodality: vision(the judge would see the text and never the images), besidetraining.prm_reward(which replacesreward_fn) ortraining.rollout_backend(which replaces the prompts the budget counted);judge_rankwithoutgrpo_judgeorgrpo_judge_max_calls; and agrpo_judge*key withoutjudge_rankinreward_fn. Refused when the trainer is set up: more than one process (WORLD_SIZEabove 1), because each would judge only its own slice and keep its own failure count.
The policy learns to please the judge, not to be right, so read samples while it trains and keep a held-out check with a different judge or a person. Every new judge_rank field is off by default. No quality, speed or cost figure is claimed for judge_rank. (Separately, since v0.77.0 training.gradient_checkpointing reaches the GRPO trainer: with the default false a task: grpo run trains with checkpointing off, where TRL's own default used to apply, so set training.gradient_checkpointing: true, as the example above does, to keep the memory you had.)
Long-context & vision GRPO
long_context_grpo and vision_grpo are validation gates, not features: they check the task, the backend and, for vision, a known VLM base (and the vision modality), and nothing reads them afterwards. long_context_grpo does not extend rope scaling into rollouts, and no Tiled MLP code stands behind it. vision_grpo does not make GRPO multimodal: the GRPO trainer loads the base with AutoModelForCausalLM and a tokenizer, not a vision processor. Both are on the list of 31 staged fields that are validated and read by nothing, and since v0.77.0 they stop the load when set away from their default: training.long_context_grpo is accepted but read by nothing; refused as of v0.77. Delete the line. (soup train exits 1, soup doctor --config exits 2). An explicit false still loads. In v0.76 they only warned. Deleting the line changes nothing about what trains.
training.vllm_sleep_mode: true is refused at load on task: grpo since v0.78.0 (#2773): training.vllm_sleep_mode has no effect: GRPO does not use a vLLM server for rollouts in this version, so there is no vLLM engine to put to sleep between rollouts. Refused as of v0.78.0. Delete the line. (soup doctor --config exits 2; soup train --dry-run exits 1.) GRPO never starts a vLLM server for its rollouts, so through v0.77.2 the key was accepted, printed vLLM sleep mode enabled via TRL GRPOConfig (on trl 0.29, upstream's words) and changed nothing; this page used to list it as working, and it did not. Delete the line from any saved config you replay; training is unchanged. false, the default, still loads, and the refusals the key already had on other tasks (vllm_sleep_mode requires task='grpo') and on backend: mlx are unchanged.
Async rollout backends
task: grpo
training:
rollout_backend: openenv # art | ruler | nemo_gym | openenv
rollout_func: soup_cli.envs.calculator:rollout # required by openenvopenenv is the only backend that runs at v0.78.0. rollout_func is a module:function that receives the dataset prompts as seeds and returns the rows GRPO then trains on, which replace the dataset's prompts. It is not given the model and runs no interactive multi-turn episodes; the bundled soup_cli.envs.calculator:rollout is a single-shot seeder (see PRM-guided GRPO). art (OpenPipe ART), ruler (OpenPipe RULER, which ships inside openpipe-art) and nemo_gym are accepted names whose adapters are not wired: they raise an ImportError naming the missing package (openpipe-art for both art and ruler, nemo-gym for nemo_gym), and a "not yet validated" error when it is installed. Through v0.76.1 ruler named a package that is not on PyPI and counted PyPI's unrelated ruler package as installed (#2059). A rollout_backend cannot be combined with reward_fn: judge_rank (see judge_rank above).
Stability knobs (accepted; mostly record-only)
task: grpo
training:
ref_model_ema_alpha: 0.99 # EMA-style ref refresh
replay_buffer_size: 50000
tis_threshold: 1.5 # truncated importance sampling
mask_truncated_completions: true
defer_rerolling: true
skip_zero_advantage: true
off_policy_mask_threshold: 0.7
async_grpo_prefetch: trueAt v0.78.0 these eight keys are accepted for task: grpo and attach a callback that writes counters (replay_size, tis_alerts, ema_alpha) into the training log. The one thing that callback does to training is the gradient watchdog described above, which skips non-finite optimizer steps and is attached to every task: grpo run, with or without these keys. async_grpo_prefetch, mask_truncated_completions, defer_rerolling, skip_zero_advantage and off_policy_mask_threshold do not change what the trainer does: the callback's own notes call them advisory, a hint or record-only. The replay buffer is never fed and the TIS counter is never called. ref_model_ema_alpha can only act if the callback is handed a separate reference model, and the Hugging Face callback handler does not hand it one, so there is nothing for it to update; a LoRA run has no separate reference model anyway (read from the code, not run on a GPU). These eight keys are not among the 31 staged fields that v0.77.0 refuses at load, so they load without a message. What does work on this page: the seven grpo_variant objectives (with the grpo_beta KL penalty on the six non-standard ones), grpo_delta, grpo_fp16 and the openenv rollout.
New task: prm
task: prm (Process Reward Model) wired through the standard reward-model trainer. Gates: vision + GRPO compat checked.
v0.50.0 shipped the schema. v0.53.3 wired grpo_fp16 routing + the known-VLM-base gate for vision_grpo; v0.53.11 lit up real loss kernels for every non-standard variant (gspo / dapo / dr_grpo / bnpo / two_sided / rft) via make_grpo_trainer_variant, made task: prm live with per-step MSE + reward head, and attached GRPOStabilityCallback, which logs counters for the stability knobs above (most of them are record-only, as that section says). See v0.53.11 — GRPO Plus finish.
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.