Repository navigation
[DSpark] Fold draft sampling for DeepSeek-V4.1 heads under AUTO - #42987
Merged
hnyls2002 merged 2 commits intoOct 9, 2026
Merged
Conversation
weireweire
requested review from
Qiaolin-Yu,
Ying1123,
hnyls2002 and
merrymercy
as code owners
October 7, 2026 15:40
Root cause: _resolve_folded_sampling returned False for any markov head with supports_sharded_greedy, so on DeepSeek-V4.1 the default AUTO mode never folded sampling into the draft CUDA graph. Every non-greedy batch then ran the draft proposal eagerly. The head also reports sharded greedy under DP attention with dp-lm-head, where the shard group has size 1 and the sharded argmax saves nothing. Fix: drop the V4.1 exception, so AUTO decides on free memory alone, as for every other DSpark head. Greedy batches on a folded graph use the general block sampler instead of the sharded argmax. Validation: GB300, DeepSeek-V4.1-Flash, random 2k in / 1k out, AUTO vs FORCE. Sampled (temperature 1.0) median TPOT: up to 36% lower at TP4 c1, 2-6% lower under DP attention (c16-c256). Greedy median TPOT: 1-4% higher at TP (worst at TP4 c64-c256), between 5% lower and 2% higher under DP attention. Unit test updated; pre-commit passes.
weireweire
force-pushed
the
dspark-v41-auto-fold-sampling
branch
from
October 7, 2026 15:43
44e55a9 to
f3d5c02
Compare
nvpohanh
reviewed
Oct 8, 2026
Collaborator
|
cc @Oasis-Git |
nvpohanh
reviewed
Oct 8, 2026
nvpohanh
left a comment
Collaborator
There was a problem hiding this comment.
[by Claude Code] Severity: style | Confidence: High
Issue
The speed and accuracy results do not have enough detail to rerun them:
- There is no server launch command for the TP4 and TP2 runs. The DP2 line lists only the parallel flags, not the DSpark flags or env vars.
- The description does not say how the 3.51 acceptance length was simulated (the
SGLANG_SIMULATE_ACC_*env vars, and theSGLANG_RAGGED_VERIFY_MODEthey require). - There is no
sglang.benchmark.servingcommand (number of prompts,--max-concurrency, and how temperature is set). - The GSM8K 0.975 result has no eval command, GPU count, parallel config, or temperature.
Fix
Add the full server launch commands (with env vars) and the benchmark and eval commands to the description.
Collaborator
|
We also noticed that enable SGLANG_DSPARK_FOLDED_SAMPLING=2 is important in low latency. This should be a good change. also cc @hnyls2002 I think we should enable it by default now |
Collaborator
Author
|
/tag-and-rerun-ci |
nvpohanh
approved these changes
Oct 8, 2026
Collaborator
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
Collaborator
|
[by Claude Code] All NV pipelines have passed. |
Collaborator
|
@Oasis-Git @hnyls2002 could we merge this? Thanks! |
hnyls2002
approved these changes
Oct 9, 2026
zozyo
added a commit
to Phala-Network/sglang
that referenced
this pull request
Oct 11, 2026
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.
Motivation
SGLANG_DSPARK_FOLDED_SAMPLING=AUTO(the default) folds the draft sampling step into the draft CUDA graph when its static buffers fit in memory. One head type is excluded: any markov head withsupports_sharded_greedy(DeepSeek-V4.1 under TP). For these heads AUTO always returns False, so every non-greedy batch runs the draft proposal eagerly.This costs a lot at low concurrency. At TP4 c1 with temperature 1.0, median TPOT is 2.35 ms with AUTO and 1.51 ms with FORCE. The exception was meant to keep the compact sharded argmax for greedy batches, but in our measurements that only saves a few percent.
The exception also applies under DP attention with
--enable-dp-lm-head. There the lm-head shard group has size 1, so the sharded argmax saves nothing, yet sampled batches still go eager.Modifications
_resolve_folded_sampling: remove thesupports_sharded_greedyexception. AUTO now decides on free memory alone for every DSpark head. When sampling is folded, greedy batches go through the general in-graph block sampler instead of the sharded argmax.Capturing both the sharded-greedy graph and the folded-sampling graph would recover the greedy-only cost (1-4%, see below). That adds a second draft graph per batch size, so it is left out of this PR.
Accuracy Tests
No change to the sampling math. FORCE mode already runs this exact path for V4.1. DeepSeek-V4.1-Flash on GB300 with
SGLANG_DSPARK_FOLDED_SAMPLING=2(FORCE) scores 0.975 GSM8K strict-match.Speed Tests and Profiling
Setup
sglang.benchmark.serving, random 2048 in / 1024 out, range ratio 1, simulated acceptance length 3.51.--tp 2 --dp 2 --enable-dp-attention --enable-dp-lm-head.Sampled traffic (temperature 1.0)
Greedy traffic (temperature 0)
Cells with two pairs come from two separate sessions.
Summary
Checklist
CI States
Latest PR Test (Base): ✅ Run #37744383637
Latest PR Test (Extra): ❌ Run #37744383359
Latest PR Test (AMD ROCm 10): ❌ Run #37744383595