Skip to content

[cherrypick from #40986] [Sampling] Stream sampling masks as per-request arrays - #41270

Merged
yueming-yuan merged 1 commit into
sgl-project:sglang-milesfrom
nanjiangwill:cherrypick-40986-sglang-miles
Sep 26, 2026
Merged

yueming-yuan merged 1 commit into
sgl-project:sglang-milesfrom
nanjiangwill:cherrypick-40986-sglang-miles

Conversation

@nanjiangwill

@nanjiangwill nanjiangwill commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Port #40986 to the sglang-miles branch.

  • Sampling masks travel from the sampler to the tokenizer manager as per-request int32/float32 arrays (SamplingMaskChunk), instead of nested Python lists at every hop.
  • The response contract is unchanged: output_token_sampling_mask, output_token_sampling_logprobs and output_token_sampling_mask_length are byte-identical to before, in selected and support mode, streaming and non-streaming.
  • The sampler and mask capture are untouched, and requests without masks do no extra work.

See #40986 for the design, the removed checks and their justification, and the performance results. Examples from there: support-mode decode at top_k=1000 × 256 goes from 6645 to 16032 tok/s, and staggered top_k=8192 RL rollouts from 97.2 to 73.0 s (selected) and 131.5 to 83.1 s (support).

Port notes

Testing

All on this branch, against sglang-miles in the same runs:

  • CPU: test/registered/unit/{managers,disaggregation,sampling} plus the OpenAI protocol and serving-chat tests. 1434 passed, against 1431 on sglang-miles; the difference is [Sampling] Stream sampling masks as per-request arrays #40986's three new tests.
    • The 38 failures and 3 errors are identical on sglang-miles without this port.
    • They come from existing test/code mismatches on the branch, e.g. SchedulerOutputStreamer.__init__() missing 1 required keyword-only argument: 'is_multimodal_gen'.
  • GPU: test/registered/sampling/test_sampling_mask.py on 2×H100: 35 passed with 28 subtests.
  • Equivalence: [Sampling] Stream sampling masks as per-request arrays #40986's 54-request workload is sent to sglang-miles twice, then to this branch, under --enable-deterministic-inference. Responses are compared floats bitwise and by each number's JSON text.
    • All five configurations are 54/54 identical: one at a time, concurrent, incremental streaming, --tokenizer-worker-num 2 and msgpack IPC.
    • No server log has a traceback.

CI States

Latest PR Test (Base): ❌ Run #36180648282
Latest PR Test (Extra): ❌ Run #36180647919
Latest PR Test (AMD ROCm 10): ❌ Run #36180648193

@nanjiangwill
nanjiangwill marked this pull request as ready for review September 25, 2026 19:36
@yueming-yuan
yueming-yuan merged commit ab4f767 into sgl-project:sglang-miles Sep 26, 2026
78 of 87 checks passed
@nanjiangwill
nanjiangwill deleted the cherrypick-40986-sglang-miles branch September 27, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants