Last reviewed: 2026-10 · Prerequisites: RL and language models, PPO clipping

Follow one response into training

In one lineA trace is not yet training data: record which tokens the model chose, with which weights, and why it stopped, or the loss has no clear positions.

A model receives a multiplication question, calls a calculator, reads the result, and answers. That gives us an execution trace, but not necessarily a training-ready example. Which tokens did the model choose? Which weights generated them? Did the task finish, or did a length limit stop collection?

These are not optional debugging logs. Without them, we may not even know where to apply the loss. Start with the rollout record, follow the dependencies between generation, scoring, and updates, then check log-probabilities and context. All numerical examples below are teaching assumptions, not framework benchmarks.

A rollout need not be a complete answer

In one lineOnly model-generated tokens take policy loss: 9 of 20 positions in the example. If collection stops mid-task, the TD target keeps the bootstrap.

A rollout runs a policy and collects actions, observations, and outcomes. It can run one task or a batch, and collect a whole task or a fragment. The term alone specifies neither the newest policy nor a learned reward model.

Term Meaning in the calculator task Distinction worth keeping
Completion Tokens generated by one model invocation A tool request can be a completion, not a final answer
Assistant turn One assistant message or tool request Exact boundaries depend on the conversation protocol
Episode The task from its start to success, failure, or another defined endpoint It may contain several model calls and environment responses
Fragment A collected part of that process Collection can stop before the task ends

An end marker may end only the current assistant turn; a pending tool result means the task is not yet complete. Conversely, for a task requiring just one answer, a completion can be the entire episode. These boundaries determine when scoring is possible and which actions belong to the same training record.

Keep policy actions separate from environment observations in the same conversation.
  1. Model generationRequest calculation → answerBoth assistant outputs can contain policy actions. Preserve sampled tokens, their log-probs, and the generation version.
  2. Environment responseThe calculator returns 12The result enters later context, but is not a sampled policy action. Do not apply policy loss to it directly.

What a usable training record contains

Break the calculator interaction into the following spans. Their invented lengths do not represent a real tokenizer's output:

Span Tokens Included as policy actions in loss? Reason
User question 6 No Input condition
Assistant tool request 4 Yes, under this task's convention Choices generated by the model
Calculator result 3 No Environment output, not policy sampling
Assistant final answer 5 Yes The model's generated answer
Padding 2 No Batch alignment only

There are 20 input positions but only 9 valid actions. If the objective averages policy loss over valid actions, the denominator is 9; dividing by 20 would change its scale. Tool results still condition later actions even though they receive no direct policy loss. Excluding their loss does not mean deleting them from context. Whether role or control markers are sampled actions depends on the generation protocol, not their appearance in a decoded string.

A record needs the following kinds of information; field names vary by implementation:

Information Why retain it?
Prompt / episode ID, token IDs, role boundaries, action mask Align logits, actions, and replay
Behavior-policy version, sampling configuration, action log-probs Establish how the data was collected
Stop reason, final observation, tool state and errors Separate termination, collection truncation, and execution failure
Reward source / version and scoring status Unscored is not zero; a tool timeout is not automatically an incorrect model answer
Old / reference log-probs, values, returns / advantages when required Identify which model computed each quantity and when

Rewards may come from tests, the environment, humans, or a learned scorer. Reference scores, values, and advantages need not be computed during generation—or all be required. Extra fields should not obscure algorithmic roles. A PPO rollout buffer generally supports a limited set of updates, not unrestricted replay of historical experience. The PPO paper describes alternating collection with multiple epochs of minibatch updates.

Small check: why average over 9 positions, not 20?

This example is already aligned to predicted target tokens; it does not demonstrate the logits shift. Values are arbitrary per-position teaching losses. A real implementation must also verify next-token shifting and the sampling protocol.

def action_mean(values, mask):
    if len(values) != len(mask) or any(flag not in (0, 1) for flag in mask):
        raise ValueError("aligned values and binary mask required")
    count = sum(mask)
    if count == 0:
        raise ValueError("no policy actions")
    return sum(value for value, flag in zip(values, mask) if flag) / count

mask = [0] * 6 + [1] * 4 + [0] * 3 + [1] * 5 + [0] * 2
values = [99.0] * 6 + [2.0] * 4 + [99.0] * 3 + [4.0] * 5 + [99.0] * 2
assert len(mask) == 20 and sum(mask) == 9
assert abs(action_mean(values, mask) - 28 / 9) < 1e-12

Did the task end, or did collection run out of time?

After aligning actions, check why collection ended. Suppose a step gives reward 0.2, the next-state value is 0.8, and the discount is $\gamma=0.9$. For a one-step TD target:

  • True task termination leaves no future return: target = 0.2.
  • An external collection limit interrupts a task that could continue: retain the bootstrap, giving 0.2 + 0.9 × 0.8 = 0.92.

This does not mean every length limit requires a value bootstrap. If the task is “finish within 10 steps or fail,” exhausting the budget is an endpoint of the task itself. A collector that merely pauses every 10 steps is different. Gymnasium's time-limit guide distinguishes termination and truncation; finite-horizon tasks also need sufficient observation information, such as remaining time.

Bootstrap from the interrupted trajectory's final observation, not the first observation after a reset. With GAE, collection boundaries usually also stop advantage recursion so errors from the next episode do not leak backward. The bootstrap mask and recursion-boundary mask can differ. Methods without a Critic should follow their own truncation and reward convention rather than add an unnecessary value field.

Find out where sampling time goes

In one lineTime may go to tool waits, scoring or sync, which GPU utilization hides. Async overlaps batches, not the steps within one, and adds policy lag.

A batch can pass through generation, tool waits, scoring, training, and weight synchronization. GPU utilization alone can make “waiting for a tool” look like “the model is too small.” As NVML defines it, the utilization in nvidia-smi is only the fraction of the sample period during which some kernel was running; it says nothing about how much compute is used. See Performance: the roofline, arithmetic intensity, and MFU. Before adding machines, inspect the dependencies to see which waits can actually be removed.

Within one batch, what has to wait?

In the calculator task, the final answer depends on the tool result, and scoring depends on the relevant answer or trajectory. For a batch intended for an update, check the following dependencies. They do not require every operation to run serially in one process.

Work Prerequisites What becomes available next
Generation and tool interaction Input context, the loaded behavior policy, and sampling settings Actions, observations, generation versions, and stop reasons
Scoring and training preparation The answer or trajectory needed for scoring; models and inputs required for each statistic Rewards, scoring status, and any old / reference log-probs, values, or other statistics the algorithm needs
Target computation and update Training records and required statistics; advantage estimation, for example, needs the relevant rewards and any required values Weights updated by backpropagation and optimizer steps using the action-masked loss
Weight publication A completed update, followed by loading and version confirmation on the generation side A new version that later rollouts can actually use

Reward scoring, reference-policy evaluation, and value estimation may run in parallel once their inputs are ready. Missing scores, however, cannot simply become zero rewards in an update. Nor does finishing an update mean the generator has loaded the new weights. For PPO's collection, advantage estimation, optimization, and policy handoff, see Algorithm 1 in Section 5 of the original paper. This is not a requirement that every method use both reference and value models.

Across batches, what can overlap?

Asynchronous execution interleaves work from different batches; it does not remove dependencies within a record. If each batch must use the weights updated and published by the previous batch, the next batch cannot begin generation early. Allowing that overlap introduces policy-version lag that must be managed.

Take hypothetical durations: 30 seconds sampling, 10 scoring, 20 training, and 5 synchronizing. Serial execution takes 65 seconds. If independent resources and early generation allow the first three stages to overlap perfectly across batches, while each 5-second synchronization cannot overlap other work, the steady-state interval has a lower bound of max(30, 10, 20) + 5 = 35 seconds: about 1.86× faster. The 35 seconds bounds the interval between completed batches in an ideal steady state, not one batch's generation-to-update latency. This is not a general asynchronous speedup. The first batch still traverses all stages; contention, stragglers, and networking add time.

Design What is easier or cheaper? What must be managed?
Collect synchronously, then update Clear policy versions and batch boundaries; generation and training can take turns on the same GPUs Stages can wait on one another
Bounded asynchronous queue Overlap some generation and training Policy lag, discard rules, and backpressure
Deep queue with continuous sampling Absorb bursts and slow tasks Potentially older data and greater memory use, not guaranteed faster useful updates

Track generated tokens/s, loss-bearing tokens/s, queue-wait quantiles, policy-version lag, timeout / discard rates, and task quality at equal wall time. Collecting invalid answers faster does not improve learning efficiency. See asynchronous policy learning for differences between objectives.

Identical weights can still produce different log-probs

In one lineRaw, sampling and trainer log-probs can differ. In the example, a wrong denominator turns 0.75 into 1.25, so a less likely action looks more likely.

Version records tell us how old the data is, but not whether its probabilities agree with the trainer's. Separate the raw model distribution, the sampling distribution after temperature / top-p processing, and the distribution recomputed by the trainer. These may or may not coincide. A field named logprob does not establish which one it represents.

For example, raw probabilities [0.8, 0.2] become [2/3, 1/3] under temperature 2. If the new model gives the second action probability 0.25, its ratio to actual behavior is 0.25 / (1/3) = 0.75. Using the raw 0.2 denominator instead gives 1.25—even reversing whether that action has become more likely. Top-p truncation also changes support; ordinary importance sampling cannot recover actions that collection never sampled.

Which distribution goes in the denominator

This figure needs JavaScript.

When actual behavior policy $b$ is the chosen anchor, the action ratio is:

$$ r_t(\theta)=\frac{\pi_\theta(a_t\mid s_t)}{b(a_t\mid s_t)}. $$

Other implementations use a trainer-recomputed old policy as the PPO anchor and separately correct the rollout-to-old mismatch. The denominator neither always comes from the inference engine nor can always be replaced by a trainer score. Check how distributions enter the objective. verl's rollout-correction guide distinguishes these designs; this discussion checks its 2026-09-23 revision, not a promise that configuration names will stay fixed.

The guide draws on several primary sources worth reading directly. The blog post “Your Efficient RL Framework Secretly Brings You Off-Policy RL Training” points out that an inference engine (such as vLLM) and a training framework compute different probabilities for the same token. Training meant to stay on-policy can therefore carry an off-policy bias even while it keeps collecting fresh samples. Its correction truncates the training-to-inference probability ratio to an interval and multiplies it into the gradient: truncated importance sampling (TIS).

“When Speed Kills Stability” (Liu et al., 2025) links this mismatch to RL training collapse and compares token-level with sequence-level corrections. IcePop, in the Ring-1T report (Ling Team, 2025), masks and clips tokens whose mismatch is too large.

Frameworks are adopting these corrections too. As of October 2026, TRL v1.16.0 turns on this kind of correction by default when generating with vLLM (vllm_importance_sampling_correction=True; the default mode in the config signature is sequence_mask, which masks whole sequences, with vllm_importance_sampling_clip_max=3.0). Enabling a correction by default does not mean the problem is solved: find where the mismatch comes from before choosing between truncating and discarding.

The configuration field definitions at the same version confirm sequence_mask as the actual default, although the file's mode descriptions still label token_truncate as the default. Follow the field definition rather than conflating the two modes.

After aligning sampling semantics, inspect kernels, precision, templates, positions, and masks. Score the same tokens with the same weights on both sides. Examine differences over valid actions, including quantiles, extremes, and length-based slices. Bitwise equality across hardware is not the requirement. Large ratios alone do not prove data staleness: alignment errors and numerical differences can also cause them.

Why is the mean difference insufficient?

Two action log-prob differences of +0.7 and −0.7 average to zero. Their exponentiated ratios are about 2.01 and 0.50, and do not average to one. This illustrates nonlinearity, not a measured error distribution.

Also distinguish what you monitor: a raw ratio outside the clipping interval does not necessarily have a clipped gradient. PPO's active branch depends on the advantage sign. See PPO clipping; one clip-fraction metric cannot by itself establish training failure.

Removed context is information the policy no longer has

In one lineA constraint trimmed to fit the window is missing when the model decides. Compression changes what the policy observes, so version it with the templates.

Probability agreement is not enough; also check what the model could see. Return to the tool task. The user initially says “do not modify the original file.” Several turns later, the system removes that sentence to fit the context window. If the model then changes the file, reward design is not the only issue: the constraint was missing when it made the decision. For how truncation and compression affect scoring and the loss in multi-turn agent training, see the section “When episodes get long” in the frontier draft on agent credit assignment and training.

Approach Benefit What to validate
Keep recent turns Simple and bounded Whether early goals and constraints disappear
Preserve goals, trim repetitive tool output Avoid an extra summarization call Whether trimming removes needed evidence
Summarize old history and retrieve original records when needed Retain useful information across longer tasks Summary errors, omissions, and retrieval failures

These choices affect completion, answer quality, and latency—not just whether context fits. Changing compression changes the policy's observations, not necessarily the underlying environment transitions. Losing necessary history can also make observations non-Markov. Version templates, summarizers / retrievers, raw tool records, and external state so experiments can be compared and tasks resumed.

Trace a small batch before scaling up

In one lineTrace a small batch first: action counts, stop reasons, rewards, versions. Changing truncation rewards, filtering or sampling can alter the objective.

You do not need the most elaborate asynchronous system first. Fix a small set of tasks and trace sampling through loss: reconcile action counts, explain stop reasons, verify rewards, and track generation and update versions before optimizing waits. The point is not that algorithms matter less than engineering; it is to rule out code that does not implement the objective you think it does.

Nor are these changes all objective-preserving. Changing truncated-response rewards, filtering, or sampling transformations can change the training distribution, estimator, or task definition. Record what changed rather than grouping everything under “performance optimization.”

Before a larger run, I would check

In one lineFive questions: can a record be realigned, are unscored and failed samples zeroed, which policy is which, is data age reported, what resume restores.

  1. Can one raw record reconstruct tokens, roles, the policy mask, and next-token logits alignment?
  2. Have unscored data, tool failure, task failure, and length truncation quietly become the same zero reward?
  3. What are old, current, reference, and actual behavior distributions? Is sampling configuration recorded?
  4. Does the synchronous / asynchronous comparison report throughput, data age, and quality at equal time?
  5. Beyond weights, is there an explicit resume policy for queues, samplers, tools, and context state? Can you verify which version the generator actually loaded?

The one thing to retain

In one lineA rollout must record which choices the model made and under what conditions. Get that right for scoring and updates before making collection faster.

A rollout is more than generated training text. It must preserve enough information to explain which choices the model made and under what conditions. Make sure that record supports correct scoring and updates before making collection faster.