Grpo Rlvr Training
Seth HobsonCommunityCreated by Seth Hobson
- Skill
- Tool integration
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a standardized recipe for using Group Relative Policy Optimization (GRPO) to refine LLM reasoning on tasks with algorithmically checkable success criteria. It emphasizes the importance of verifiable rewards, manual inspection of reward functions, and specific hardware-aware configurations for training stability. The approach is designed for tasks where the model already demonstrates baseline capability but requires reinforcement to improve consistency and reasoning depth.
What it does
- Defines the GRPO training configuration using TRL's GRPOTrainer.
- Provides a framework for implementing composite reward functions (format and correctness).
- Establishes a mandatory inspection gate for reward functions before training.
- Offers guidance on hardware-specific memory management for GRPO rollouts.
- Outlines variant selection for specific failure modes like entropy collapse or MoE instability.
When to use it
- When task success is algorithmically verifiable (e.g., code, math, JSON schema).
- When the model already succeeds inconsistently and needs policy refinement.
- When you need to optimize reasoning traces rather than just output preferences.
- When a GRPO run exhibits specific issues like reward hacking or length-bias.
Advantages
- Enables policy refinement without requiring large datasets of human demonstrations.
- Provides a clear, repeatable recipe for verifiable task training.
- Includes a critical inspection gate to prevent training on flawed reward logic.
- Offers specific variants to address common RL training instabilities.
Usage examples
- “I have a model that solves math problems but is inconsistent. How do I use GRPO to improve it?”
- The agent provides the GRPOTrainer configuration, explains the requirement for a verifiable correctness reward function, and details the mandatory inspection process.
- “My GRPO training run is reward hacking by just increasing output length. What should I do?”
- The agent identifies this as a length-normalization bias and recommends switching to the Dr.GRPO variant to decouple reward from completion length.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/wshobson/grpo-rlvr-training/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip grpo-rlvr-training.zip -d .agents/skills
Documentation by Seth Hobson
GRPO & RLVR Training
This skill assumes finetuning-method-selection
already routed here because the target behavior
has a verifiable pass/fail signal — not
demonstrations (lora-qlora-recipes) or
preference pairs (preference-optimization).
What follows is when RL is the right tool, the
reference recipe, the mandatory reward-inspection
gate, and how to pick a GRPO variant when the
base recipe misbehaves.
Input: a routing decision (RLVR via GRPO)
plus a verifier (code executor, test suite,
schema checker, or grader) for the target task.
Output format: a validated GRPO config — the
kwarg values in references/grpo-memory.md and
the reward functions in
references/reward-functions.md, not free-form
advice — that llm-finetuning-training-engineer
consumes directly.
When RL Applies
GRPO+RLVR only pays off when task success is
algorithmically checkable — a unit test
passes, a parser accepts the output, a tool call
matches an expected schema, a math answer matches
a ground truth. If grading the output requires
human judgment or a subjective rubric, that's an
eval-harness and judge-calibration problem first
— see eval-harness-first — not a reason to skip
straight to RL.
Before opening a GRPO run, confirm the model can sometimes succeed on the target task already. RL sharpens an existing capability by reweighting toward the samples that already work; it does not install a capability from zero.
The model never succeeds, even at low temperature across many samples: the gap is format or task understanding, not policy refinement. Route back to SFT first (
lora-qlora-recipes) and only return to this skill once the base success rate is nonzero.The model succeeds sometimes, inconsistently: this is the GRPO sweet spot — proceed to The Recipe below.
The standing rule for the whole plugin: DPO for
taste, GRPO for reasoning. If the signal is a
preference between two acceptable outputs, that's
preference-optimization, not this skill.
The Recipe
The reference recipe is TRL's GRPOTrainer with
vLLM-backed generation:
from trl import GRPOConfig, GRPOTrainer
grpo_args = GRPOConfig(
output_dir="./outputs-grpo",
use_vllm=True,
vllm_mode="colocate", # single GPU; "server" for multi-GPU
num_generations=8, # floor — fewer starves the group-relative baseline
learning_rate=5e-7, # settled range for GRPO
beta=0.01, # KL coefficient vs the reference policy
per_device_train_batch_size=8,
gradient_accumulation_steps=4,
bf16=True,
logging_steps=10,
seed=3407,
)
trainer = GRPOTrainer(
model=SFT_CHECKPOINT,
args=grpo_args,
reward_funcs=[format_reward, correctness_reward], # references/reward-functions.md
train_dataset=prompts, # prompt-only — GRPO generates its own completions
processing_class=tokenizer,
)
trainer.train()vllm_mode="colocate"runs generation and training on the same GPU — the default for a single-GPU box.vllm_mode="server"points at a separate vLLM server process and is the multi-GPU path — generation and training don't compete for the same device.num_generations≥ 8 is a floor, not a suggestion: GRPO's advantage estimate is relative to the group mean, and fewer than 8 samples per prompt produces a noisy baseline.Reward is composite — a format reward (did the output parse / match the required structure) plus a correctness reward (did the answer verify). A well-formed-but-wrong answer and a malformed one should not score identically; correctness alone loses that signal.
learning_rate=5e-7andbeta=0.01are the settled starting point; deviate only after the base run is stable and reward-inspected (below).
Memory sizing for this recipe by target size
class: references/grpo-memory.md.
The Inspection Rule
Run the reward function against 50–100 sampled outputs and manually read the results before starting the actual training run. This is a gate, not a one-time sanity check.
If the reward function's judgment disagrees with a human reading of that sample, fix the reward function first. Training against an uninspected reward, or tuning hyperparameters to compensate for one silently scoring the wrong thing, is how a run reward-hacks: the model optimizes cleanly toward the wrong target, and that doesn't surface as a training-loop bug.
This inspection is a Phase 1 gate input for
/finetune — the same 50–100-sample read that
catches a broken reward function here is what that
command checks for before it lets a GRPO brief
proceed.
Complete reward function implementations to
inspect against — exact-match, schema-validation,
unit-test-execution, a length-penalty wrapper, and
a rubric-as-reward judge pattern:
references/reward-functions.md.
Variant Selection
The base recipe above is the default. Reach for a variant only when a specific failure mode shows up, not preemptively:
| Failure mode | Variant | Why |
|---|---|---|
| Entropy collapse / degenerate long chain-of-thought | DAPO | Decouples clip bounds and relaxes the KL penalty that over-regularizes exploration on long reasoning traces |
| Reward or output length trends up regardless of quality | Dr.GRPO | Removes GRPO's length-normalization bias so reward tracks correctness, not completion length |
| Training a mixture-of-experts model | GSPO | Moves the importance-sampling ratio to the sequence level instead of per-token — per-token ratios are unstable on MoE routing, so GSPO is required here, not optional |
Start with plain GRPO. Watch for the specific symptom — collapsing entropy on long CoT, a length-reward correlation, or MoE instability — and only then swap in the matching variant above. Don't pre-select a variant before the base recipe has actually shown the failure mode.
VLM RL Is Reference-Only
Vision-language RL is not executed by this plugin in v1 — it's documented here for context, not as a runnable path. Tooling is fragmented across ms-swift and EasyR1-derived forks with no one-line TRL command yet, and naive text-only GRPO applied to a VLM tends to reward-hack by optimizing the text-reasoning trace while ignoring the image — the model learns to sound right without looking at the input. A VLM RL run is a research spike outside this skill's supported recipe, not a variant of The Recipe above.
References
references/reward-functions.md— complete Python reward functions (exact-match correctness, schema validation, unit-test execution, a length-penalty wrapper, and a rubric-as-reward judge pattern) to inspect under The Inspection Rule before any training run.references/grpo-memory.md— memory sizing by target size class, vLLM sleep-mode and optimizer-state tactics, Unsloth's long-context RL chunking, and the DGX Spark bandwidth caveat for decode-heavy rollouts.
Related skills: finetuning-method-selection
routes here once a verifiable pass/fail signal
exists; preference-optimization is the sibling
skill for preference pairs rather than verifiable
rewards; eval-harness-first covers judge
calibration for any reward that isn't purely
code-checkable. On DGX Spark, defer to the
dgx-spark-ops plugin's skills, when installed,
for the memory/thermal remediation ladder this
skill's memory table doesn't cover.
Files
- ATTRIBUTION.mdAdded by AutoGineer982 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md7.6 KiB
- references/grpo-memory.md3.5 KiB
- references/reward-functions.md11.5 KiB
references/grpo-memory.md
Last verified: 2026-07-13
GRPO Memory Sizing
GRPO's memory footprint is heavier than SFT or
DPO at the same parameter count: a training run
plus a co-resident (or server-side) vLLM
generation engine sampling num_generations
completions per prompt, on top of the usual
optimizer-state and activation costs. Base models
are never named here — anchors are size classes
only.
Memory Anchors by Size Class
| Size class | Feasible with |
|---|---|
| Small (≤~3B) | 24GB-class GPU — vLLM sleep mode + 8-bit AdamW + gradient checkpointing |
| ~32B-class | H200-class GPU |
| ~70B-class | B200-class GPU |
24GB-class is feasible for small models, but only with all three levers engaged together, not any one alone:
vLLM sleep mode releases the generation engine's KV-cache and weight memory between the rollout phase and the training-step phase instead of holding both resident simultaneously.
8-bit AdamW (
optim="adamw_8bit") cuts optimizer-state memory the same way it does for SFT/DPO — seelora-qlora-recipes.Gradient checkpointing trades recompute for activation memory, same tradeoff as elsewhere in the plugin.
H200-class is the anchor for ~32B-class models — the policy model, reference model (for the KL term), and co-resident vLLM generation engine no longer fit together below that class.
B200-class is the anchor for ~70B-class models, for the same three-way residency reason at greater scale.
These are starting anchors, not hard floors —
vllm_mode="server" (a separate generation
process, possibly on separate GPUs) changes the
residency math versus "colocate"; re-derive
before assuming a size class is out of reach on
a given box.
Unsloth Long-Context RL Chunking
Unsloth's chunked-loss RL path extends usable RL
context to roughly 7x longer than an
unchunked GRPO setup at the same memory budget —
an order-of-magnitude figure from Unsloth's own
published benchmarks, not re-measured here; verify
against the current Unsloth release notes before
sizing a context budget precisely on it. This
matters specifically for RL because rollouts
— especially long chain-of-thought completions —
are the memory pressure point GRPO adds on top of
the base training cost; chunking is the lever that
buys headroom there without changing
num_generations or batch size.
DGX Spark: Bandwidth-Bound Rollouts
GRPO's rollout phase is decode-heavy —
num_generations ≥ 8 completions sampled per
prompt, often with long chain-of-thought — and
decode is memory-bandwidth-bound, not
compute-bound. On DGX Spark, the shared memory
bandwidth ceiling is the constraint that bites
first for GRPO specifically, ahead of raw VRAM:
measured sustained bandwidth runs well below the
273 GB/s spec figure. This is gotcha G5 in the
dgx-spark-ops plugin's spark-training-gotchas
skill, when installed — that skill's bandwidth
budget (180–192 GB/s sustained, not the spec
ceiling) is the number to plan rollout throughput
against, not the headline spec.
Practical consequence: prefer small models for GRPO on Spark. A size class that would train comfortably via SFT or DPO on a single Spark can still bottleneck badly under GRPO once rollout decode saturates shared bandwidth — the Memory Anchors table above tells you whether it fits, this section tells you whether it runs fast enough to be worth doing on that hardware. When Spark rollout throughput is the binding constraint, dropping to a smaller size class is usually more effective than further GRPO hyperparameter tuning.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Seth Hobson
- Publisher
- Seth Hobson (Community)
- Source
- wshobson/agents · plugins/llm-finetuning/skills/grpo-rlvr-training · commit 4bde316
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Seth Hobson or Seth Hobson.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download grpo-rlvr-training.zip