Repository navigation
[Sampling] Add selected/support sampling logprob modes - #40932
Merged
ByronHsu merged 5 commits intoSep 24, 2026
Merged
Conversation
nanjiangwill
requested review from
BBuf,
ByronHsu,
Duyi-Wang,
Edwardf0t1,
Fridge003,
HaiShaw,
JustinTong0323,
ShangmingCai,
Ying1123,
ch-wan,
hnyls2002,
ispobock,
merrymercy,
sogalin and
xiezhq-hermann
as code owners
September 23, 2026 15:21
nanjiangwill
marked this pull request as draft
September 23, 2026 15:28
nanjiangwill
force-pushed
the
feat/sampling-distribution-metadata
branch
from
September 23, 2026 17:13
e2058ba to
130295d
Compare
This was referenced Sep 23, 2026
nanjiangwill
force-pushed
the
feat/sampling-distribution-metadata
branch
from
September 23, 2026 20:29
130295d to
3dd6ddc
Compare
nanjiangwill
force-pushed
the
feat/sampling-distribution-metadata
branch
from
September 23, 2026 20:35
3dd6ddc to
d03166b
Compare
nanjiangwill
force-pushed
the
feat/sampling-distribution-metadata
branch
from
September 23, 2026 21:37
d03166b to
960a136
Compare
nanjiangwill
force-pushed
the
feat/sampling-distribution-metadata
branch
2 times, most recently
from
September 23, 2026 23:25
820a0b7 to
74b08b3
Compare
ByronHsu
reviewed
Sep 23, 2026
ByronHsu
reviewed
Sep 23, 2026
ByronHsu
reviewed
Sep 23, 2026
nanjiangwill
force-pushed
the
feat/sampling-distribution-metadata
branch
from
September 24, 2026 01:04
74b08b3 to
76443ca
Compare
nanjiangwill
marked this pull request as ready for review
September 24, 2026 01:29
ByronHsu
approved these changes
Sep 24, 2026
Collaborator
|
/tag-and-rerun-ci |
Collaborator
|
/rerun-test test/registered/npu/basic_function/dllm/test_npu_llada2_mini.py |
Contributor
|
Results for ⛔ |
Collaborator
|
/rerun-failed-ci |
ByronHsu
approved these changes
Sep 24, 2026
guapisolo
pushed a commit
that referenced
this pull request
Sep 24, 2026
This was referenced Sep 24, 2026
This was referenced Sep 24, 2026
nanjiangwill
added a commit
to modal-projects/sglang
that referenced
this pull request
Sep 29, 2026
jvmncs
pushed a commit
to modal-projects/sglang
that referenced
this pull request
Oct 2, 2026
…rob modes (sgl-project#40932) (cherry picked from commit c3685df) Preserve the v0.5.20 wire prefix and inline device-index construction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sampling_logprobs_mode: Literal["selected", "support"].output_token_sampling_logprobs[t]is the selected output token behavior logprob."support"mode, returnoutput_token_sampling_logprobs[t]aslist[float], aligned elementwise withoutput_token_sampling_mask[t].API contract
For output position
t, letw_tbe the exact post-filter weights captured from the sampler,S_t = {a | w_t(a) > 0}, andWith
return_sampling_mask=false,sampling_logprobs_modemust be omitted.With
return_sampling_mask=true:sampling_logprobs_modeor setting it to"selected"returnslog q_t(output_ids[t])as a float. This keeps the existing default response shape.sampling_logprobs_mode="support"returns onelog q_t(a)per token ID inoutput_token_sampling_mask[t]as a list. The token-ID and logprob rows have identical lengths and elementwise alignment.0.0, while support mode returns[0.0].sampling_logprobs_moderequiresreturn_sampling_mask=true; when masks are enabled, omission resolves to selected mode at the internal request boundary.The support row order is not an API guarantee; elementwise alignment is. Overflow and invalid captured support continue to fail closed, so no partial distribution is returned.
Implementation
Performance boundary
When sampling-mask output is disabled, this adds no sampler tensor work or payload. With masks enabled:
4RC + 12Rbytes forRmask rows and packed capacityC.4R_sCbytes, whereR_sis only the number of support-mode rows.SGLANG_ENABLE_DISAGG_SAMPLING_MASK; support mode necessarily makes the aligned float row capacity-sized, matching the token-ID row.A packed/base64 ragged response format is intentionally not part of this change. It is an independent transport optimization and can be added without changing these selected/support semantics.
Validation
CI States
Latest PR Test (Base): ⏳ Run #35951430674
Latest PR Test (Extra): ❌ Run #35951430010
Latest PR Test (AMD ROCm 10): ❌ Run #35951430457