Repository navigation
[Sampling] Support sampling masks with overlap scheduling - #36631
Conversation
05b18a3 to
6ee0895
Compare
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci extra |
|
/tag-and-rerun-ci |
1 similar comment
|
/tag-and-rerun-ci |
Addresses review comment 3962601377. Copy once before slicing individual request rows in the non-overlap path.
Addresses review comment 3962601385. Build the row-selection partial only for requests that opt into mask capture.
275aa5a to
a723a1a
Compare
nanjiangwill
left a comment
There was a problem hiding this comment.
Thanks—the three earlier performance comments are addressed, and removing the spec/ tree helped. The remaining inline comments are lifecycle/configuration issues I think should be resolved before merge. Two cleanup and verification items: 4964140 is an unrelated MLX test repair and should be split out, and the new distributed paths still need one real TP2 sampling-mask run plus one live PP run. The Mooncake P/D run is useful, but TP1 and unit-level PP reconstruction do not exercise the status collective or actual PP send/recv.
This reverts commit 4964140.
nanjiangwill
left a comment
There was a problem hiding this comment.
The lifecycle and configuration fixes look good. I left two focused test-structure comments to keep the added coverage aligned with SGLang’s CI contract and remove an unused mock.
| ) | ||
|
|
||
| register_cuda_ci(est_time=139, stage="base-b", runner_config="1-gpu-small") | ||
| register_cuda_ci(est_time=250, stage="base-b", runner_config="2-gpu-large") |
There was a problem hiding this comment.
Could we keep this file on 1-gpu-small and move only TestDistributedSamplingMask into a focused two-GPU test file? These cases genuinely need a different CI contract, which is the explicit new-file exception in unit-test-admission.md. In this CI run the distributed cases took about 136 seconds, while the remaining roughly 119 seconds held a second large GPU unnecessarily. Splitting them preserves the existing suite’s cost and makes the two-GPU requirement explicit.
|
|
||
|
|
||
| def validate_sampling_mask_max_tokens(server_args: Any): | ||
| if envs.SGLANG_DISAGGREGATION_SAMPLING_MASK_MAX_TOKENS.is_set(): |
There was a problem hiding this comment.
maybe we have a follow up pr to deprecate SGLANG_DISAGGREGATION_SAMPLING_MASK_MAX_TOKENS entirely in sglang, but merge it later
Motivation
Sampling masks currently do not support overlap scheduling because materializing the masks inside the sampler synchronizes the GPU with the CPU.
Modifications
--sampling-mask-max-tokens(default:4096) to set the maximum number of tokens per sampling mask.top_kexceeds the configured mask capacity.top_keven thoughtop_kis within the limit.NaNor infinity). Abort the request before committing the failed step's sampled token.SGLANG_DISAGGREGATION_SAMPLING_MASK_MAX_TOKENSwith the server argument--sampling-mask-max-tokensfor both ordinary and disaggregated serving. PD metadata remains off by default: setSGLANG_ENABLE_DISAGG_SAMPLING_MASK=1on both prefill and decode servers. Without it, requests asking for masks receive HTTP 400 with the required setting; unused metadata buffers are neither allocated nor transferred. Startup rejects the retiredSGLANG_DISAGGREGATION_SAMPLING_MASK_MAX_TOKENSvariable with explicit migration instructions.Accuracy Tests
Current head
d73bc1bd7f; review fixes verified at1d542447e5on BJ job3439034(NVIDIA H200,lmsysorg/sglang:dev-cu13):Qwen/Qwen2.5-0.5B-Instruct: masks with and without ordinary logprobs, followed by ordinary generation; four tokens per request. Checks cover selected-token membership, support IDs, aligned lengths, capacity, and finite sampling logprobs.Qwen/Qwen2.5-0.5B-Instructoverride for the existing fixtures. The normal run passed both distributed tests and ten capture/packing tests; three existing fixtures could not access the gated Llama model (HTTP 401). The committed default model is unchanged.Run the distributed tests with:
Earlier verification also covered FlashInfer/PyTorch HTTP requests with overlap on/off, seeded parity, and two live Mooncake P/D cases (disabled/error and enabled metadata handoff).
Upstream main
5177a3ec08remains merged through92774ddb48; no history was rebased.spec/remains removed.Review follow-up commits:
90eab32d48: defer abort release until pending KV offload completes; preserve the optional backend hook and leave base classes unchanged.084b80efce: reuse prefill abort retirement and preserveerr_typedespite sender exceptions.520e7f7541: reject the retired environment variable at startup.f79c5a9466: revert the unrelated MLX test repair. That fix is split into Fix MLX shutdown test mock after request-ingestion refactor #38739; main still reproduces its two shutdown-fixture failures, so MLX CI may remain red here until the separate repair lands.1d542447e5: live TP2/PP2 coverage.d73bc1bd7f: merge distributed coverage into the existing sampling-mask test file; use the two-GPU CUDA runner and preserve the one-GPU AMD suite with only the distributed class skipped.The earlier three review fixes remain separate commits:
e511bfc998(opt-in PD metadata),6f53732040(bulk CPU copy), anda723a1a55a(capture-only helper allocation).Speed Tests and Profiling
Qwen3-8B BF16, TP1 on one NVIDIA H200, with FlashInfer sampling and attention and CUDA graphs enabled. Each request uses 128 input tokens, 512 output tokens,
temperature=1,top_k=4096,top_p=1, andreturn_sampling_mask=true. The PR uses--sampling-mask-max-tokens=8192to accommodate cutoff ties; observed masks contained 4096–4396 tokens.Before: upstream
756d0e0a85, overlap disabled. After: PRcb30f7c6a9, overlap enabled. This measures the combined implementation and scheduling change.Median steady decode throughput from three measured runs after one warmup per configuration; parentheses show the run range.
Throughput uses scheduler decode logs over full-batch intervals. Prefill, warmup, and final HTTP response serialization are excluded; sampling-mask capture, copying, and decode result processing are included. All 18 measured trials and six warmups completed with aligned masks/logprobs and no overflow or invalid-result failures.
Reproducer, exact commands, and full per-run evidence.
CI States
Latest PR Test (Base): 🚫 Run #34503593751
Latest PR Test (Extra): ✅ Run #35022699343
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.
Co-authored-by: Nan Jiang [email protected]