How a replayed sampling mask would reach the trainer once token capture is on
#3937 (sampling mask replay, draft, head 0d62c9a4)
next to #4818 (score centering, head f0d9860e). Gym checked at
bbf3cff4 (#4818's pin) and d8f4db46 (Gym#4930 merged).
Before
#3937 carries vLLM's mask inside Gym's HTTP response. That works only when token capture is off. Gym has no code for the field yet.
This PR
#4818 builds a second route: per-token tensors staged by the vLLM worker into the data plane, never passing through Gym. A mask has the same shape.
Status
Proposed โ not implemented. No PR moves a mask through token capture today. This page shows where it would go.
Six pages on this PR, one question each โ this one: which route a sampling mask can take.
Background. A
sampling mask
is one short list of token ids per generated token. In
token capture
mode, the driver no longer reads per-token data out of Gym's reply: it
switches to receipt mode
and skips the function #3937 reads the mask in. Dotted words have a short explanation: hover or tap them.
Same 3 generated tokens, both routes
Example: top_k=4, top_p=0.8. Supports of size 3, 2 and 1 for the 3 tokens. #4818's lane uses K=2 recorded candidates.
What replay on the token-capture route needs โ proposed, not in any PR
Where it would land: RL only. Copy #4818's pattern for its two columns.
No Gym change in token-capture mode: the tensors skip Gym, and top_k is pinned on the vLLM server
(#3937 does this,
because Gym's Responses API cannot send top_k). Gym needs work only for the token-capture-off route.
Nothing below is implemented. It is a sketch of where each piece would go.
@@ vllm_worker_async.py ยท _finish_request_capture, next to #4818's sampler_topk attach (L968-L973)+ if self._return_sampling_mask_enabled(): # helper from #3937
+ # vLLM's per-token support, padded to top_k; sizes mark the real length.
+ attachments.update(
+ sampling_mask_token_ids=mask_ids, # int32 [3, 4] = [[17,4,9,0],[8,23,0,0],[5,0,0,0]]
+ sampling_mask_sizes=mask_sizes, # int32 [3] = [3, 2, 1]
+ )@@ setup.py ยท partition fields, as #4818 adds SAMPLER_TOPK_FIELDS (L341-L342, L371)+ + (list(SAMPLING_MASK_FIELDS) if sampling_mask_replay else [])@@ rollout_reassembler.py ยท finalizer, as #4818 zero-fills top-K rows+ # prompt/tool rows get size 0; generated rows must equal the call's token count
A possible shortcut, not tested. With logprobs_mode=processed_logprobs, vLLM computes
the reported log-probs over the filtered logits, so tokens the filter cut come back as -inf
(model.py L255,
sampling_mask.md).
So #4818's own columns with top_logprobs = top_k would already hold the support: the ids whose log-prob is finite.
Two things stop that today: #4818's extraction rejects any non-finite log-prob
(extract_score_centering_samples),
and setup forbids filters with score centering. Ties at the top-k edge would also need checking.
So what. Asking Gym to carry the mask only helps runs with token capture off. For token-capture
runs, the mask should ride the route #4818 just built, and Gym needs no change. #3937 is a draft from August,
written against an older main, so it needs a rebase either way. #4818 is not the place to add this, but its staging
slot for per-token columns is the piece mask replay would reuse.