18.8 Rollout systems, GRPO variants, and training diagnostics
RL training repeatedly runs an inference workload inside the learning loop. Generation, scoring, optimization, and weight synchronization must fit together. A fast serving engine helps only when it supplies valid, fresh, correctly scored data to the learner.
Concepts from other sections (14)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- GRPO: a PPO-style RL method that replaces the critic with the group-normalized reward of several samples of the same prompt. Read more: 19.7 The training step and validation
- Policy lag: the gap between the learner and the policy that produced a rollout. Read more: 18.5 On-policy, off-policy, offline, and online learning
- backpressure: a slow consumer slowing its producer, so memory between them stays bounded. Read more: 1.9 Async Rust and tokio: futures, tasks, channels, cancellation, hyper in Programming and Algorithms
- Backpropagation: reverse-mode automatic differentiation that computes all parameter gradients in one backward pass. Read more: Chapter 2: Deep Learning
- PPO: a policy gradient method that clips the new-to-old probability ratio to keep updates small. Read more: 4.4 World models, multiple agents, and RLHF
- Outcome reward: feedback on a final answer or result. Read more: 18.7 Rewards, preference models, and independent evaluation
- Standard deviation: , the typical distance of a random variable from its mean, in the same units as the variable itself. Read more: Chapter 13: Probability and Statistics in Mathematics
- Regularization: penalizing model complexity to trade bias for lower variance. Read more: Chapter 1: Statistical Learning
- Variance: the expected squared distance from the mean; its square root is the standard deviation. Read more: 13.1 Random variables, expectation, variance, and normal draws by Box-Muller in Mathematics
- Entropy: , the average surprise of a distribution. Read more: 17.1 Entropy, cross-entropy, KL, JS, and the k3 estimator in Mathematics
- Compute budget: the training FLOP available, , which fixes the trade between parameters and tokens . Read more: A.1 Capstone: TinyStories, owned end to end
- Task success: whether an agent accomplished its objective end to end; the agent metric that matters most. Read more: Chapter 29: LLM Evaluation
- Clip fraction: a defined count of ratios outside the clipping interval; it is not the fraction of all gradients that are zero. Read more: 18.6 PPO with a critic and generalized advantage estimation
- Dropout: randomly zeroing activations during training to approximate an ensemble of subnetworks. Read more: Chapter 2: Deep Learning
Learning objectives
- Design synchronous and asynchronous actor/learner flows.
- Explain group size, normalization, and length-weighting choices in GRPO.
- Diagnose useful learning throughput rather than raw generation throughput.
Connect learner and rollout workers
Section titled “Connect learner and rollout workers”versioned prompts → rollout actors at revision k → checker/reward model ↓ behavior probabilities ↓ scores immutable trajectory records → learner updates ↑ ↓ new weights ← validated revision k+1In a synchronous design, actors finish a round before the learner updates and publishes new weights. It simplifies revision accounting but can idle GPUs during scoring or updates. In an asynchronous design, actors collect while the learner updates. Queues improve utilization but introduce policy lag, mixed revisions, and backpressure. The learner should define a maximum acceptable lag and reject, refresh, or explicitly correct stale samples according to its algorithm.
Colocation places learner and actor on shared devices, often with weight swapping or time-sharing. It saves hardware and potentially transfer work but complicates memory scheduling. Disaggregation gives generation and learning separate pools, allowing different TP/DP layouts and independent sizing. It adds weight-transfer cost and consistency requirements. Publish a new revision only after all necessary actor shards agree; mixing layer weights from two revisions creates a different, unintended policy.
SGLang and vLLM are examples of rollout runtimes. A trainer supplies data flow, objective, backpropagation, optimizer, and checkpoint state. An inference server is not by itself a PPO or GRPO trainer. Compare their local serving contracts on fixed tokens before integrating them with learning.
From a scalar toy loss to token-level GRPO
Section titled “From a scalar toy loss to token-level GRPO”For prompt , sample completions from an old policy and assign outcome rewards . Define group-normalized advantages and token ratios . A common original-style surrogate averages each sequence before averaging sequences:
counts valid generated actions according to the EOS/mask convention. Padding and prompt tokens do not participate. The same sequence advantage is broadcast across its generated tokens for outcome supervision; a process-reward variant requires a different credit construction. A whole-sequence probability ratio is not interchangeable with these per-token ratios.
The original GRPO formulation, section 4.1 removes a learned value baseline, not the cost of rollouts or a separate reward model when the task uses one. The earlier scalar implementation is a toy reduction over supplied entries; a production recipe must define the masks, token/sequence weighting, behavior distribution, and KL estimator explicitly.
Group size and the baseline
Section titled “Group size and the baseline”For Bernoulli success probability , the probability that a group contains both success and failure is
At this is . At it is about . Larger groups can reveal comparisons but cost more generation and do not fix an impossible task. Correlated samples can reduce diversity further; independence is an assumption of this calculation.
Subtracting an action-independent baseline preserves the expected policy gradient. The inclusive mean of a sampled group includes the current action’s reward and is not action-independent. Without standard-deviation normalization, its expected gradient has a finite-group factor under independent samples. A leave-one-out baseline removes this particular self-inclusion factor for . Dividing by sampled reward standard deviation adds further weighting and estimator effects. Avoid calling every group-normalized estimator unbiased.
An equal-reward group has zero centered policy advantages. Reference regularization or another objective can still update its tokens. Track zero-spread fraction by prompt difficulty and task, along with the denominator of discarded groups.
Variants are objective changes
Section titled “Variants are objective changes”| Design choice | Motivation | What must be compared |
|---|---|---|
| Per-sequence token mean | Give each sequence equal total weight | Length bias and task quality by generated length |
| Global valid-token mean | Weight tokens equally across sequences | Longer responses receive more total weight |
| Fixed length denominator | Remove a sampled-length-dependent denominator | Gradient scale as actual lengths vary |
| Group/batch/no standard-deviation scaling | Change how easy/hard prompts contribute | Difficulty weighting, advantage variance, and stability |
| Asymmetric ratio clipping | Change exploration and update incentives | Ratio tails, entropy, drift, and success |
| Filtering all-equal groups | Spend updates on nonzero comparisons | Resampling cost and changed prompt distribution |
| Length-cap penalties or masking | Handle incomplete generations | Truncation rate, denominator, and length-conditioned success |
DAPO and Dr. GRPO’s analysis motivate several such changes. The TRL 0.23.1 GRPO reference exposes choices including loss_type and reward scaling. A trainer’s current default should not be assumed to reproduce the original paper. Record the resolved recipe, not just the algorithm name.
Measure the complete learning system
Section titled “Measure the complete learning system”Log rollout tokens/sec, accepted fresh tokens/sec, scorer timeouts, weight-sync time, queue age, optimizer tokens/sec, total GPU-hours, and success per compute budget. Record raw reward components, independent task success, length, truncation, entropy, reference KL, old/current KL, clip fraction, and per-group reward spread. Explain each metric’s mask and denominator.
If generation throughput doubles but most data is stale, useful learning throughput can fall. If output lengths grow, reward may improve while successful answers per GPU-hour decline. If learner and actor probabilities disagree before an update, check sampling transforms, numerical execution, dropout, and model revisions before changing clipping.
Key terms
Section titled “Key terms”- Actor/learner architecture: a system separating experience generation from gradient updates.
- Zero-spread group: a prompt group with identical rewards and zero centered advantages.
- Recipe: objective, masks, normalizations, update schedule, and generation contract taken together.
Summary
Section titled “Summary”The serving runtime, estimator, and scheduling policy form one learning system. Optimize accepted evidence and task improvement per total cost, while keeping algorithmic changes visible.
Review questions
Section titled “Review questions”-
Why can global token averaging change the learned policy compared with sequence averaging?
Answer
It changes the relative weight assigned to long and short completions, so it changes the objective rather than merely implementation speed. -
Does removing the critic make GRPO automatically cheaper than PPO at the same quality?
Answer
No. More samples per prompt, scoring, synchronization, and different sample efficiency can outweigh critic-memory savings.