Skip to content

[DSV4] Fix draft SWA transfer for disaggregated MTP - #30461

Merged
ShangmingCai merged 1 commit into
sgl-project:mainfrom
weireweire:fix/dsv4-disagg-draft-swa-transfer
Jul 9, 2026
Merged

ShangmingCai merged 1 commit into
sgl-project:mainfrom
weireweire:fix/dsv4-disagg-draft-swa-transfer

Conversation

@weireweire

@weireweire weireweire commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

When both prefill and decode enable EAGLE for DeepSeek V4, prefill builds prompt SWA state for the draft NextN layer. Disaggregation already registers the draft pool's contiguous KV buffers, but the DSV4 NextN layer has compression ratio 0 and stores its state in the paged SWA pool, or in the SWA-ring prefix of the unified KV pool. Those buffers were not registered, so decode started with missing or stale draft prompt state until newly generated tokens refilled the sliding window.

This is the DSV4/SWA counterpart of #23539. The draft worker shares the target request pool and SWA allocator mapping; unified mode also uses matching ring geometry. Therefore the draft buffers can reuse the existing SWA transport types. They are registered as a separate positional component so they do not become part of the target model's heterogeneous DSV4 state layout. This change is limited to the non-NPU DSV4 path.

Modifications

  • Register paged draft NextN state as an additional StateType.SWA component and unified draft ring buffers as an additional StateType.SWA_RING component.
  • Validate the existing DSV4 invariants used for shared indexing: SWA-only draft layers, matching pool mode and geometry, and a shared paged SWA mapping.
  • Reuse the existing state-component wire format and SWA transfer dispatch; no draft-specific state type or backend changes are added.
  • Add focused CPU coverage for paged and unified draft-state registration.

Accuracy Tests

  • A 20-sample GSM8K smoke test on a 1P1D DSV4 deployment with real bilateral EAGLE completed with non-empty responses and no KV registration or transfer failures.
  • Patched result: 90% strict match and 95% flexible match. This small smoke test is a functional check, not a statistical accuracy claim.

Speed Tests and Profiling

With EAGLE top-k 1, 3 speculative steps, and 4 draft tokens:

The strongest improvement appears in the early decode window, before locally generated tokens replace the transferred 128-token draft SWA prompt state. After aligning each DP rank at its first stable decode batch:

Stable decode window Main AL Patched AL Change
First 8 verify steps 2.4844 2.9219 +17.61%
First 16 verify steps 2.5625 2.9531 +15.24%
First 32 verify steps 2.6094 2.9531 +13.17%

This time-segmented result directly matches the failure mode: the missing prompt SWA state hurts draft proposals most at the beginning, and its impact decays as newly generated tokens fill the local SWA window.

Across the full requests, the improvement is diluted by later decode steps after the local SWA window has been refilled:

Metric Main Patched Change
Request-weighted acceptance length 2.8054 2.9139 +3.87%
Request-weighted acceptance rate 60.18% 63.80% +3.62 pp

The workload is intentionally small, so these numbers validate the expected direction rather than establish an end-to-end throughput claim.

Validation

  • python -m pytest -q test/registered/unit/disaggregation/test_disaggregation_wire.py test/registered/unit/disaggregation/test_minimax_sparse_disagg_state_kv_args.py (18 passed, 2 subtests passed)
  • pre-commit run --all-files --show-diff-on-failure

Checklist


CI States

Latest PR Test (Base): ✅ Run #28919874867
Latest PR Test (Extra): ❌ Run #28919874782

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@weireweire
weireweire force-pushed the fix/dsv4-disagg-draft-swa-transfer branch 2 times, most recently from 1fb7796 to fe4dbf4 Compare July 8, 2026 05:15
Root cause: the DSV4 draft NextN layer stores prompt state in its ratio-0 SWA pool, but that pool was omitted from disaggregated state registration. Decode therefore began with missing draft prompt state until generated tokens refilled the sliding window.

Register the draft pool as one trailing positional component using the existing SWA or SWA_RING transport type, after validating the shared target/draft indexing invariants. This reuses the existing state wire format and transfer backends without adding draft-specific backend handling.

Validation: 24 focused CPU tests and pre-commit pass. A parallel 1P1D GPU A/B improves request-weighted acceptance length from 2.8054 to 2.9139; the patched 20-sample GSM8K smoke test reaches 90% strict and 95% flexible match.
@weireweire
weireweire force-pushed the fix/dsv4-disagg-draft-swa-transfer branch from fe4dbf4 to 7ca94bb Compare July 8, 2026 05:29
@weireweire

Copy link
Copy Markdown
Contributor Author

@ShangmingCai Hi, could you help to review this disagg MTP bug fixing?

@weireweire

Copy link
Copy Markdown
Contributor Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Jul 8, 2026
# reusing the existing SWA transport dispatch. NPU has a different paged
# state layout and is intentionally left unchanged.
if (
not is_npu()

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.

NPU uses NPUMLATokenToKVPool, this could be redundant.

@ShangmingCai ShangmingCai 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.

Others LGTM

@ShangmingCai

Copy link
Copy Markdown
Collaborator

Since CI has passed, let me merge first; the redundant is_npu could be fixed when NPU also looks into this problem.

@ShangmingCai
ShangmingCai merged commit 1c9eb6b into sgl-project:main Jul 9, 2026
211 of 240 checks passed
@weireweire
weireweire deleted the fix/dsv4-disagg-draft-swa-transfer branch July 10, 2026 08:03
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Co-authored-by: weireweire <20922698+weireweire@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants