NVIDIA-NeMo/RL #5006, head 77d3b094; vLLM 0.29.0.
check_sampler_support: a captured list that looks full but misses the sampled token raises and ends training.Three pages on this PR, one question each. This one: when replay's own safety check kills a healthy run.
top_logprobs
most likely tokens with their probabilities. Tokens its top-k filter removed get probability 0 (log-prob βinf).
Replay treats the tokens in that list as "the tokens vLLM could have sampled" (page 1). So the list must contain the token
vLLM actually sampled. If it does not, the code must decide between two explanations:
the list was too short (normal, rare: drop the token from the loss) or the data is broken (a bug: stop the run).
It decides with one test on the list's probabilities, shown below.Settings: top_k = 3 (vLLM may sample only the 3 most likely tokens) and
top_logprobs = 3 (vLLM records 3 tokens). Setup allows this, since it only asks for top_logprobs β₯ top_k,
and the guide's own example uses 64 and 64. Pretend the vocabulary has 5 tokens. Here are vLLM's numbers for one position:
| rank | token id | logit (raw score) | probability after the top-k filter | vLLM may sample it? | in the recorded list of 3? |
|---|---|---|---|---|---|
| 1 | 17 | 2.0 | 0.6456 | yes | yes |
| 2 | 4 | 1.4 | 0.3543 | yes | yes |
| 3 | 9 | β8.0 | 0.0000293 | yes | yes |
| 3 (tie) | 23 | β8.0 | 0.0000293 | yes, tied with 9 | no, list is full |
| 5 | 31 | β9.5 | 0 (cut) | no | no |
"the capture is corrupt". Training stops.| case | what happened | recorded list | sum of its probabilities | sampled | today | after the fix |
|---|---|---|---|---|---|---|
| A | the example above: tie at 3rd place, tied tokens unlikely (0.0000293 each) | 17, 4, 9 | 0.99997 β "complete" | 23 | run stops | token dropped, counted |
| B | same tie, but the tied tokens are likelier (logit β3.0, 0.0043 each) | 17, 4, 9 | 0.9957 β "short" | 23 | token dropped, counted | token dropped, counted |
| C | no tie; top_logprobs = 4, so the 4th slot holds a cut token at probability 0. A sampled token outside the list means broken data | 17, 4, 9, (23 at 0) | 1.0 β "complete" | 23 | run stops (right) | run stops (right) |
A and B are the same event. Only the size of the left-out token differs, yet one is dropped quietly and the
other ends training. "Dropped, counted" means the token is left out of the loss and added to the
policy_support_excluded_tokens metric. C is how real corruption looks: the list has a slot at probability 0, so it
already held every token vLLM could sample, and a token outside it cannot be explained by a tie.
Where the fix lands: RL only, one function, check_sampler_support.
No vLLM change: keeping ties is vLLM's documented small-batch behaviour.
@@ nemo_rl/distributed/model_utils.py L739-L742 Β· check_sampler_support - head_mass = sampler_topk_logprobs.to(support.device).float().exp().sum(-1) - complete = head_mass >= 1.0 - 1e-4 - sampled = input_ids.to(support.device).unsqueeze(-1) - if not (support == sampled).any(-1)[active & complete].all(): + head_mass = sampler_topk_logprobs.to(support.device).float().exp().sum(-1) + sampled = input_ids.to(support.device).unsqueeze(-1) + in_support = (support == sampled).any(-1) + # vLLM keeps every token tied at the top_k-th logit on small batches, so a + # head with no -inf slot can miss the sampled token: drop it, don't raise. + tie_miss = (support >= 0).all(-1) & ~in_support + complete = (head_mass >= 1.0 - 1e-4) & ~tie_miss + if not in_support[active & complete].all(): raise ValueError( "sampler replay: a sampled token is not in its captured sampler "
In case A the list has no slot at probability 0 and misses the sampled token, so tie_miss is true: the position counts as short, and the loss drops and counts the token, as in case B. In case C the list has a slot at probability 0, so tie_miss is false and the error still fires. That keeps the PR's broken-data test passing. The simpler idea, "any miss means short", would also drop case C and break that test. Raising top_logprobs above top_k only makes case A rarer, because a tie can be wider than the extra room.
π΄ review comment C1 β model_utils.py:739