What "top-p support" for score centering would mean, and how it relates to mask replay

NVIDIA-NeMo/RL #4818 (head f0d9860e), next to community draft #4833 and the public Miles score-centering guide.

Before
#4818 lets score centering run only with unfiltered sampling (top_p = 1, no top_k).
This PR
Rejects top-p and top-k at setup (config.py L1419).
Status
Proposed — a follow-up after #4818 lands. Nothing below is in #4818.

Six pages on this PR, one question each — this one: what adding top-p to score centering would take.

Background. "Top-p support" means: let vLLM sample with a top-p filter (bounded by a top-k filter) and still use score centering. Two things then have to happen, and they are both. The trainer must score tokens over the same kept set vLLM sampled from: that is sampling-mask replay. And score centering must use the cut distribution. The trick is that both can come from the same top-K columns #4818 already ships. Dotted words have a short explanation: hover or tap them.

One generated token, today vs. with top-p support

Same six-token example as the "two top-ks" page. vLLM q = 0.45, 0.25, 0.15, … for ids 17, 4, 9; trainer p = 0.50, 0.32, 0.10. Right lane: top_k = 4, top_p = 0.8, so vLLM keeps {17, 4, 9}; K = 6 slots recorded. All values computed with the PR's own compute_score_centering_term.

#4818 today: no filter, K = 2 with top-p support: top_k 4, top_p 0.8, K = 6 1 · WHAT vLLM SAMPLES FROM all 6 tokens: 0.45, 0.25, 0.15, 0.08, 0.05, 0.02 no cut only {17, 4, 9}, renormalized: 0.529, 0.294, 0.176 processed_logprobs: everything cut is −inf 2 · WHAT THE K SLOTS HOLD ids [17, 4], q [0.45, 0.25] the other 0.30 of vLLM's mass is unseen [17, 4, 9 | −inf, −inf, −inf] whole kept set + spare cut slots (proof nothing was dropped) 3 · TRAINER'S p full softmax: 0.50, 0.32 at ids 17, 4 rest 0.18 replayed over {17, 4, 9}: 0.543, 0.348, 0.109 this step IS sampling-mask replay 4 · THE REST OF THE VOCABULARY estimated as ρ·p, ρ = 0.30 ÷ 0.18 = 1.667 guess: right total, maybe wrong shape vLLM's leftover is 0, so ρ = 0 nothing to estimate 5 · CORRECTION c AT RECORDED IDS c = q − ρ·p = −0.383, −0.283 c = q′ = 0.529, 0.294, 0.176 (exact) exact estimated

So is it mask replay or score centering? Both, from one payload. With a top-k bound and processed_logprobs, vLLM's K recorded slots contain its whole kept set, with cut tokens marked −inf. The trainer reads the kept set from those slots and renormalizes over it: that is the replay. Score centering on the same slots then has no "rest" to guess, so it becomes exact. Miles calls this "support mode": "H is then the full sampling distribution and nothing is approximated." It needs a positive top_k, and K at least that large.

What a follow-up would change on top of #4818 — proposed, not in any merged code

Where it would land: RL only. Same two columns, same token-capture route. No Gym change: the tensors never pass through Gym on this route.

Piece#4818 todayWith top-p support
Setup checkrejects top_p < 1 and any top_kallow them; require processed_logprobs and top_logprobs K larger than top_k (ties at the cut can need more)
vLLM worker extractionrejects any non-finite log-prob (extract_score_centering_samples)keep −inf slots as padding; check the kept mass is 1 and at least one slot is cut
Trainer log-prob of the sampled tokenfull softmaxrenormalized over the kept slots (the replay), for both the current and old log-probs
Correction termtop-K exact, rest estimatedwhole kept set exact; padding slots masked out

A team branch already does this padding-and-masking for Gym without token capture, and is planned as a follow-up once #4818 lands. Two other designs get the kept set from vLLM's separate return_sampling_mask instead of from the top-K slots: #3937 (mask replay only) and community draft #4833, which uses it for score centering on native vLLM rollouts and Gym without token capture (see the vs #4833 and moving a mask pages).

So what. Top-p support is not a new transport. It reuses #4818's top-K columns. What changes is that the vLLM worker stops rejecting cut (−inf) slots, and the trainer renormalizes over the kept ones. In return the score-centering estimate becomes exact, because the "rest" is empty. The one real constraint: K must be larger than the kept set, so top_k has to bound it. Pure top-p with no top-k cannot fit in K slots. For #4818 itself, nothing changes: it is right to reject filters until this lands.