NVIDIA-NeMo/RL #5006, stacked on the merged
#4818 (score centering). All links pinned to head 77d3b094.
top_k/top_p sampling, the trainer re-applies the same filters to its own logits. When its numbers differ a little from vLLM's, its kept set can differ, and the sampled token is dropped from the loss. Score centering refuses filters entirely.policy.generation.sampler_replay (off by default): the trainer reads vLLM's kept set from the top-K list it already captures and scores the token over exactly that set.Three pages on this PR, one question each. This one: what replay is and where it differs from today. Background on the idea: #4818 "top-p support" page.
grpo_train, PPO, distillation) reject it at setup
(grpo.py).
Turn it on with:
policy:
generation:
top_k: 3 # replay needs a top_k: it bounds the kept set
top_p: 1.0
top_logprobs: 4 # (id, log-prob) pairs recorded per token; must be >= top_k
sampler_replay:
enabled: true
vllm_cfg:
logprobs_mode: processed_logprobs # filtered tokens come back as -inf
token_capture:
enabled: true
Dotted words have a short explanation: hover or tap them.Example: top_k = 3 (vLLM may only sample from the 3 most likely tokens) and top_logprobs = 4 (vLLM records the 4 most likely tokens with their log-probs). They are two different settings: top_logprobs must be at least top_k so the record holds every token vLLM could sample, and the spare 4th slot comes back −inf. vLLM's logits for ids 17, 4, 9, 23 are
2.00, 1.40, 0.31, 0.30, so it keeps {17, 4, 9} and samples 9. The trainer, in different precision, gets 2.00, 1.40, 0.30, 0.31:
ids 9 and 23 swap places at the cut. Probabilities below are computed from those logits.
top_k = 3 on its own logits and returns the 4 best processed log-probs. The cut id 23 comes back as −inf.SamplerSupportLogprob). Every sampled token is inside that set, so none is dropped.| Pass | Recompute (today) | Replay (this PR) |
|---|---|---|
| Actor loss | get_next_token_logprobs_from_logits with the filters |
sampler_support_logprobs (packed path: L712) |
| Old ("prev") log-probs | same filter recompute | same helper, on Megatron and Automodel; the head is fetched a second time for this pass |
| Reference KL | full vocabulary in both: the reference pass resets the sampling params, so it never replays | |
| Setup checks | none new | top_k set, top_logprobs ≥ top_k (config.py), processed_logprobs, no fused linear logprobs |
They join at the loss: both hand ClippedPGLossFn one log-prob per token. After that the only difference is
that replay also hands over the recorded slots, which score centering uses, and marks a token −inf when its captured slots look short
(that rule is where the bug on page 2 lives). The PR also makes the vLLM HTTP server pin top_k and turn off
min_p and the repetition penalty for every Gym run, since vLLM would otherwise fill them from the model's
generation_config.json.
top_k is required (pure top-p cannot fit in a fixed number of recorded slots), vLLM must
return top_logprobs ≥ top_k log-probs per token, and the head is fetched twice. The review asks for step-time numbers, replay vs
recompute, since the guide's "not slower" has none yet.