Skip to content

PRM-guided GRPO (v0.71.30)

soup train with task: grpo can now use a trained Process Reward Model as the per-step reward signal, the o1-era process-supervision idea: grade every reasoning step, not just the final answer. Point it at a PRM you trained with soup train with task: prm and it scores each step of a generated answer, folding the per-step scores into one reward that GRPO optimizes.

We have not found another OSS fine-tuning CLI that uses a PRM as the per-step GRPO reward.

Config

yaml
task: grpo
backend: transformers        # required (the PRM reward runs a transformers forward)
modality: text               # required
data:
  format: chatml
  train: ./grpo_prompts.jsonl
training:
  prm_reward: ./my-prm       # a `soup train` with `task: prm` checkpoint dir, or an HF id
  prm_aggregate: min         # min (weakest-link, default) | prod | last
  num_generations: 4
  grpo_beta: 0.04
  gradient_checkpointing: true   # since v0.77.0 the default false turns it off on GRPO
  • prm_reward is a local directory or a Hub id. A Hub id (org/name, optionally org/name@revision) is downloaded before training through Soup's Hub download wrapper: the repo-id, revision and namespace-pin checks run first, and only weights, tokenizer files and custom-code modules are fetched. A value that is not a Soup-trained PRM (no reward head), a failed download, or a string that is neither an existing directory nor a repo id stops the run with one message naming the value, before any training, and an existing local path with no reward head now fails early too. (Since closed in v0.76.0 (#1466): through v0.75.2 an org/name value loaded the tokenizer and the model and then died at the first reward call with "path is not a directory".)
  • prm_reward replaces reward_fn; TRL logs it as rewards/prm_reward, and the v0.71.26 reward-hack controller observes it like any other reward.
  • prm_aggregate folds the per-step scores into one number. min is the weakest-link default and the safe choice; prod assumes calibrated [0,1] step scores (it can blow up or flip sign on uncalibrated labels); last uses the final step.
  • Step boundaries are a newline heuristic; each step is scored with one PRM forward pass.
  • prm_reward cannot be combined with reward_fn: judge_rank, the LLM-judge ranking reward added in v0.77.0 (see GRPO Plus): the PRM replaces reward_fn, so the judge would never run, and the config is refused at load.
  • training.gradient_checkpointing reaches the GRPO trainer since v0.77.0. With the default false, a GRPO run now trains with checkpointing off, where TRL's own default (on) used to apply. Set training.gradient_checkpointing: true, as the fence above does, to keep the memory you had; upstream's shipped GRPO recipes now set it.

Training the PRM (task: prm), changes in v0.76.0

The PRM you point prm_reward at comes from soup train with task: prm. Three things changed for that task in v0.76.0:

  • It trains on fp32 master weights on every device (#1235). On CUDA it used to load the base and the reward head in bf16 with no fp32 copy for the optimizer. Since v0.74.0 that made the first step fail (outside DeepSpeed) with mat1 and mat2 must have the same dtype, and before that the base trained in pure bf16, where most AdamW steps at PRM learning rates round away: an RMSNorm weight at 1.0 never moves at lr 1e-5 or 2e-5. With the default optimizer, expect about 16 bytes per parameter before activations instead of about 8, a saved checkpoint in fp32 (without DeepSpeed), and about twice the host RAM of a bf16 load to read it. A PRM trained on CUDA before this fix did not train in fp32.
  • It reads optimizer, scheduler, warmup_ratio, weight_decay and max_grad_norm (#805). Through v0.75.2 the PRM trainer did not read them, so a run that set them trained with defaults it had not been given. batch_size: auto is also resolved for this task now (it prints Auto batch size (PRM)); before that it fell back to 1.
  • soup train --resume resumes it (#1220). It used to restart at step 0 and overwrite the checkpoints.

The trainer fine-tunes every base parameter, so a non-default training.lora block is refused when the config loads (task='prm' does not apply training.lora: the PRM trainer fine-tunes every base parameter. Remove the lora block (or set lora.r: 0).). An explicit training.quantization: 4bit or 8bit (or load_in_8bit: true) is refused at load since v0.77.0, because the trainer never quantises the base: training.quantization: 4bit has no effect on task='prm': its trainer never quantises the base, so no run can honour it. Delete the line or set quantization: none. Refused as of Soup v0.77. v0.76 loaded it with a warning and treated it as none.

Under gradient accumulation (v0.77.0, #1444, #1771). The PRM trainer returns a per-micro-batch mean; before this release a run at gradient_accumulation_steps (G) above 1 (the default is 4) "logged and clipped losses G times too large", in upstream's words. Since v0.77.0 the logged loss, train_loss and grad_norm match a gradient_accumulation_steps: 1 run, and max_grad_norm clips the gradient for the stated loss.

The LM head runs on one position (v0.77.2, #2372, by @ybai08). The PRM score reads only the last hidden state, so a task: prm step used to build full-vocabulary logits that nothing read. Since v0.77.2 the PRM trainer's forward, and the two forwards of the GRPO PRM reward (prm_reward), pass logits_to_keep=1 where the model's forward takes that argument, so the LM head runs on the last position only; the hidden states the reward head reads, the loss and every gradient are unchanged, and a forward without the argument keeps the old call. The VRAM estimate behind the soup train pre-flight, soup profile, soup plan and the MCP profile tool charges a PRM step's logits term on that one position (vocab x batch x 6 bytes) except for eight model types whose forward has no logits_to_keep (gemma4_assistant, gemma4_unified_assistant, musicgen, musicgen_melody, prophetnet, trocr, whisper, xlstm) and for remote-code bases (auto_map in config.json), which keep the full-sequence charge (#2337). It is a change in memory, not in the result, so there is nothing to re-run; read from upstream's changelog and tests, and no measured peak is published for it.

Re-run this

If you trainedWhat was wrongWhat to do
task: prm on CUDAThe base and head were bf16 with no fp32 master weight: the run either stopped at step 1 (outside DeepSpeed) or trained in pure bf16 where most AdamW steps round away (#1235)Re-run if the PRM mattered; a GRPO run that used it as its reward inherits it
task: prm with optimizer, scheduler, warmup_ratio, weight_decay or max_grad_norm setThe trainer did not read them (#805)Re-run if the defaults it used mattered
soup train --resume on task: prmIt restarted at step 0 and overwrote the checkpoints (#1220)Do not trust a PRM that was "resumed" on an earlier version
task: prm at gradient_accumulation_steps above 1 (the default is 4), before v0.77.0Logged and clipped losses were gradient_accumulation_steps times too large, so max_grad_norm clipped against a loss G times the stated one (#1444, #1771)Read old loss and grad_norm logs as G times too large; re-run if the PRM mattered

Bundled rollout environments

v0.71.30 also ships three deterministic, pure-Python toy environments so the GRPO openenv rollout path works with no external setup:

yaml
training:
  rollout_backend: openenv
  rollout_func: soup_cli.envs.calculator:rollout   # or retrieval_qa | guess_number
  reward_fn: verifiable
  verifiable_domain: math

Ready-made recipes: grpo-env-calculator, grpo-env-retrieval-qa, grpo-env-guess-number (part of catalog 134 to 137). They are single-shot prompt/answer seeders (the live openenv contract passes seed prompts, not the model), not interactive multi-turn episodes.

Honesty

Proof-of-mechanism only, validated on SmolLM2-135M with a tiny synthetic PRM and synthetic reward on a single RTX 3050, not a production reward-model claim. Scale validation is tracked in issue #286.

See also

  • GRPO Plus — the 7 GRPO variants, rollout backends, and stability controls this builds on.
  • Online DPO — the judge-in-the-loop RL alternative when you have a judge instead of a PRM.
  • RLVR — verifiable rewards for math / code / JSON with no reward model at all.

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.