Skip to content

Fix DSpark and DP/EP - #33098

Merged
Qiaolin-Yu merged 4 commits into
sgl-project:mainfrom
vladnosiv:fix-dspark-and-dp-ep
Aug 4, 2026
Merged

Qiaolin-Yu merged 4 commits into
sgl-project:mainfrom
vladnosiv:fix-dspark-and-dp-ep

Conversation

@vladnosiv

@vladnosiv vladnosiv commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

Fix DSpark with DP attention: its draft ForwardBatch missed metadata required by CUDA graph admission and EP token accounting, causing startup and first-request crashes.

Modifications

Populate original_global_num_tokens_cpu and non-padded token counts when DSpark constructs the draft batch, and add regression coverage.

Accuracy Tests

verified on 4xH200 with:

sglang serve \
  --trust-remote-code \
  --model-path deepseek-ai/DeepSeek-V4-Flash-0731 \
  --tp 4 \
  --dp 4 \
  --enable-dp-attention \
  --enable-dp-lm-head \
  --moe-runner-backend marlin \
  --ep 4 \
  --host 0.0.0.0 \
  --port 30000 \
  --max-running-requests 512 \
  --swa-full-tokens-ratio 0.01 \
  --cuda-graph-max-bs-decode 128 \
  --speculative-algorithm DSPARK
python3 -m sglang.test.few_shot_gsm8k --num-questions 200 --port 30000

Accuracy: 0.960
Invalid: 0.000
Latency: 11.855 s
Output throughput: 1455.725 token/s

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #30704262557
Latest PR Test (Extra): ❌ Run #30825602108

Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
@junliu-mde

Copy link
Copy Markdown

Same issue, this works for me.

Tested the cumulative diff at 9c37e64041aa501449dcd99f0c67ed22167a0795 with lmsysorg/sglang:v0.5.16 on 2x NVIDIA B300, DeepSeek-V4-Flash, --tp 2 --dp-size 2 --enable-dp-attention --enable-dp-lm-head --speculative-algorithm DSPARK. Both target and draft CUDA graph capture completed with backend=full. Concurrent generation requests returned HTTP 200, and both DP ranks reported cuda graph: True during decode. The pod remained Ready with zero restarts and no TypeError, traceback, or CUDA error.

@JustinTong0323

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci label Aug 1, 2026

@JustinTong0323 JustinTong0323 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated this fix end-to-end on 4x GB300 with DeepSeek-V4-Flash-0731. I cherry-picked the three fix commits onto the exact v0.5.16 base (fdebc938) where the first request previously crashed because original_global_num_tokens_cpu was missing, then launched TP4/DP4 with DP attention, DP LM head, FlashInfer MXFP4, and bundled DSpark.

Results:

  • The target and draft CUDA graphs both completed all 27/27 tiers; the warmup, streaming request, and 32-request concurrent smoke test all passed, with no scheduler exception or CUDA/OOM error.
  • The added DSpark DP-tier test passed: 5/5.
  • Full GSM8K: 96.66% (1275/1319), 99.92% stop rate, 0 request errors.
  • 8k input / 1k output serving benchmark, with 64 warmups and a separate cache flush before every case:
    • c64: 16,248.70 total tok/s (4,062.18 tok/s/GPU), 1,857.75 output tok/s, 5.52 acceptance length. This is +10.73% versus TP4 + DSpark and +51.69% versus target-only DPA.
    • c256: 26,868.24 total tok/s (6,717.06 tok/s/GPU), 3,015.63 output tok/s, 5.47 acceptance length. This is +54.67% versus TP4 + DSpark and +33.55% versus target-only DPA.

This confirms that the patch fixes the previously broken DSpark + DP-attention path and makes it the strongest measured throughput-oriented configuration. TP4 + DSpark still has better latency at c64, and this result does not cover DSpark with PD disaggregation.

@JustinTong0323

Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@junliu-mde

Copy link
Copy Markdown

Same issue here. This patch works for me with DeepSeek-V4-Flash, DSpark, and DPA2 on 2x B300. Target and draft CUDA Graph capture completed with decode backend=full, two concurrent generation requests returned HTTP 200, both DP ranks reported cuda graph: True, and the pod stayed Ready with 0 restarts.

@vladnosiv

Copy link
Copy Markdown
Contributor Author

@JustinTong0323 Hi !
Can we merge it?

@JustinTong0323

Copy link
Copy Markdown
Collaborator

@JustinTong0323 Hi ! Can we merge it?

Just pinged code owner to take a look

efschu added a commit to efschu/htsglang that referenced this pull request Aug 3, 2026
…utation, sgl-project#471/sgl-project#33407/sgl-project#33312/sgl-project#33098/sgl-project#33271 ports, sgl-project#481 PP fixes

Eight commits, largest bundle this session:

- sgl-project#479 (two commits): the GGUF-MoE offload coverage test and its refusal
  message named MXFP4/type 39 as THE example of a ggml type with no MoE
  kernel -- sgl-project#398 made that false (type 39 has a full native kernel set on
  a wheel that carries it). Traced the ACTIVE DSV4-Flash MXFP4 path end to
  end and confirmed it is native, not an untraced fallback; the refusal
  message now names the layer's own declared types instead of a stale
  hardcoded example, so it cannot go stale again the same way.
  docs/dev/NOTE_479_mxfp4_active_driver_path.md has the trace.
- sgl-project#471: ports upstream sglang#32320 -- mask the SM120 SWA page-split to
  touched pages only, instead of the full page range.
  docs/dev/TICKET_471_masked_page_split.md.
- sgl-project#33407 port: SM120 sparse-MLA buckets the topk width instead of using
  it unbucketed, falling back to Triton outside the bucketed range.
- sgl-project#33312 port: DSpark draft head resolves and loads fused shared experts.
- sgl-project#33098 port: DSpark draft fills the EP token-accounting fields.
- sgl-project#481: three pipeline-parallel defects from the sgl-project#445 window fixed in
  server_args.py/resident_fraction.py/expert_stats.py.
- sgl-project#33271 port: auto-round GPTQ MoE completes the MoeWNA16 delegation.

FEATURE_CATALOG.md §8 conflict-risk as flagged, but no actual conflict --
this branch's base (a5eff26) is now several merges behind (sgl-project#520, sgl-project#523,
design-453 landed since), yet none of those touched §8, so git's 3-way
merge combined everything automatically. All 17 sections and all 22
previously-preserved additive paragraphs verified present.

**Explicit verification requested and confirmed**: the two "ancient
pre-existing" failures in tests/moe_offload/test_gguf_moe_offload.py
(test_materialize_declines_uncovered_ggml_type,
test_guard_still_refuses_an_unstaged_gguf_layer) that this session
bisected back to before this session even began -- sgl-project#479's fix to
expert_offload.py and the type-39 assumption in gguf.py directly
addresses their root cause. Full file run: 20 passed, 0 failed, both
confirmed GREEN now.

One test-isolation quirk found and run to ground, not a code bug: the
three flash_mla test files this branch adds/touches
(test_flash_mla_backends.py, test_flash_mla_page_split_mask_471.py,
test_flash_mla_sm120_topk_buckets.py) interfere with each other when run
in the same pytest process -- a shared Triton-decorated function object
resolves to JITFunction instead of the expected InterpretedFunction once
another file in the same process has already imported flash_mla_sm120.py
under real (non-interpret) conditions. Verified this is NOT a merge
regression: reproduced identically on the unmerged branch tip in
isolation (fresh archive, no other code involved), and every one of the
30 tests across the three files passes cleanly when its file is run
alone. Branch-inherent test-ordering fragility, not in scope for this
merge to fix.

Tests (CUDA_VISIBLE_DEVICES=99, PYTHONPATH pinned to this worktree):
- tests/moe_offload/test_gguf_moe_offload.py alone: 20 passed (was 18
  passed/2 failed before this merge, per this session's own bisection).
- The eight new/touched test files, run individually where the isolation
  quirk above requires it: all pass in full (dspark 442: 18; auto_round:
  17; dspark shared-expert 33312: 21; gguf mxfp4 479: 18; pp defects 481:
  26; flash_mla backends/topk-buckets/page-split-mask: 10/25/10 each
  alone).
- test/registered/unit/quantization/ + unit/models/ + spec/dspark/: 28
  failed both before and after (diffed by test ID, not count -- the
  pre-merge archive showed 35 because 7 of its failures were an artifact
  of an incomplete git-archive extraction missing sgl-kernel/, confirmed
  by re-checking those 7 IDs against the working tree directly). The
  remaining 28 are dspark_kernel_parity's CUDA-only subtests plus
  test_gguf_dequant_scratch_budget.py, both pre-named as pre-existing.
- test/registered/unit/layers/ + tests/moe_offload/: 3 failed (the
  pre-named test_deterministic_fp8_gemm.py x2 +
  test_flashinfer_workspace_zeroing.py x1), 1168 passed -- confirms
  test_gguf_moe_offload.py's contribution to this count is now 0 failures.
- test/registered/unit/distributed/ (full, server_args.py touched): 24
  failed, byte-identical established baseline.
- ruff check --select=F401,F821,UP037: 15 findings, all in
  expert_offload.py, all confirmed pre-existing (same set already
  verified at cc5a92e in the earlier sgl-project#494 merge) and outside this
  branch's two diff hunks (2112-2138, 2616-2648) -- auto_round.py and
  every other touched file clean.
- codespell: clean on all 21 touched/added files.
@Qiaolin-Yu
Qiaolin-Yu merged commit 154f0ac into sgl-project:main Aug 4, 2026
289 of 343 checks passed
kfhfar pushed a commit to kfhfar/sglang that referenced this pull request Aug 7, 2026
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>

Copy link
Copy Markdown

Follow-up integration regression: #34410 now pins the DSpark PD-decode draft-input handoff on current main.

This complements #33098 rather than duplicating it: #33098 fixed DSpark DP-attention draft ForwardBatch metadata, while #34410 covers the separate disaggregation handoff invariant that SpecInput and overlap relay state exist before the first decode step.

xuxiuk added a commit to xuxiuk/sglang that referenced this pull request Aug 12, 2026
Backport the functional part of upstream PR sgl-project#33098 (154f0ac) to the pre-refactor DraftBlockProposer layout. Preserve original global token counts and populate non-padded token metadata for DP-attention draft forwards.
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
jakki-amd pushed a commit to jakki-amd/sglang that referenced this pull request Sep 9, 2026
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants