Skip to content

[DSpark] Fix draft MoE expert-location dispatch to restore speculative acceptance - #34846

Closed
zhanxxxxxxx wants to merge 2 commits into
sgl-project:mainfrom
zhanxxxxxxx:fix/dspark-eplb-expert-location
Closed

zhanxxxxxxx wants to merge 2 commits into
sgl-project:mainfrom
zhanxxxxxxx:fix/dspark-eplb-expert-location

Conversation

@zhanxxxxxxx

@zhanxxxxxxx zhanxxxxxxx commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

DSpark reuses DeepSeek NextN decoder layers for its draft model. Regular NextN/MTP layers intentionally skip expert-location dispatch, but DSpark draft expert weights are loaded according to the target model's global expert-location metadata.

With a non-identity initial expert placement, the draft gate emits logical expert IDs while the corresponding weights reside in remapped physical slots. Skipping logical-to-physical dispatch therefore executes the wrong draft experts and substantially degrades speculative acceptance.

Modifications

  • Add an explicit opt-in for expert-location dispatch on NextN MoE layers.
  • Keep the existing behavior unchanged for regular NextN/MTP users.
  • Enable the opt-in only when constructing a DSparkV4Stage.
  • Apply the same dispatch decision consistently to the regular, dual-stream, DeepEP, and op_select_experts paths.
  • Add CPU unit tests covering:
    • non-NextN layers continue to use expert-location dispatch;
    • NextN layers continue to skip it by default;
    • NextN layers can explicitly opt in;
    • DSpark stages enable the opt-in.

Accuracy Tests

GSM8K smoke test (20 questions) after the fix:

  • Accuracy: 0.950
  • Invalid: 0.000

The test confirms that the corrected draft expert routing restores valid model output. This is a small smoke test rather than a statistically strong accuracy evaluation.

Speed Tests and Profiling

Under the same DSpark + non-identity expert-placement configuration (10 random requests):

Metric Before After
Mean acceptance length 1.61 3.38
Output throughput (tok/s) 161.64 313.24
Mean TPOT (ms) 45.80 21.82

The workload is intentionally reported as a smoke/performance regression test; it is not a full throughput benchmark.

Regular NextN/MTP behavior is unaffected because the new dispatch behavior is opt-in and is enabled only by DSparkV4Stage.

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 #34451781659
Latest PR Test (Extra): ❌ Run #34451781346
Latest PR Test (AMD ROCm 10): ❌ Run #34451781568

@zhanxxxxxxx

Copy link
Copy Markdown
Contributor Author

@Fridge003 @ispobock Hi, could you please help review this PR and tag it with run-ci if appropriate?

This fixes incorrect expert dispatch for DSpark draft layers when EPLB uses a non-identity expert placement. The draft weights are loaded according to the remapped expert locations, but the NextN path previously skipped logical-to-physical dispatch, causing the draft model to execute the wrong experts.

The fix is opt-in for DSpark only and preserves the existing NextN/MTP behavior. I also added regression tests, and in my test the mean acceptance length recovered from 1.61 to 3.38.

Would appreciate your help getting this through review. Thanks!

unclezhou486 added a commit to unclezhou486/sglang that referenced this pull request Sep 18, 2026
…aft MoE

DSpark reuses DeepSeek nextn layers for its draft; regular nextn/MTP layers
skip expert-location dispatch, but the draft expert weights are loaded with the
target's global expert-location mapping. With a non-identity expert placement
(any large EP deployment) the draft gate then emits logical ids while the
weights live in remapped physical slots, so the wrong draft experts run and
acceptance collapses (upstream measured 1.61 -> 3.38).

- deepseek_v2: add the per-layer opt-in
  (enable_nextn_expert_location_dispatch / _should_use_expert_location_dispatch)
  and route the four dispatch_info sites through it
- deepseek_v4_dspark: opt in from DSparkV4Stage
unclezhou486 added a commit to unclezhou486/sglang that referenced this pull request Sep 18, 2026
Squash the debug branch back to its essential changes on top of main:

- KEEP: DSparkAttention reduces wo_b over the attn-TP group instead of the
  full DP x TP group (the accept-rate-0 root cause).
- KEEP: disable the folded proposal under attn_tp > 1 (eager markov path),
  since the in-graph markov vocab-shard gather is not verified there.
- KEEP: the upstream attn_tp == 1 guard, commented out with a NOTE explaining
  that its corruption is the wo_b group and is fixed.

Remove all DSPARK_DUMP instrumentation (dspark_numeric_dump.py and every call
site), plus the changes that are no-ops for this deepep + dp-attention + NPU
configuration: the _base_logits_context alignment, sgl-project#34846 expert-location
dispatch (eplb off), sgl-project#31868 speculative MoE contexts (a2a == target deepep),
the _dp_gather replicated path (only a2a=none), and SpecTpSync PyNCCL (no
PyNCCL on NPU).
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @zhanxxxxxxx. Closing this because you have 9 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs.

Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one.

Some directories moved recently, so an older branch may need retargeting:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

Copy link
Copy Markdown
Contributor Author

This issue has already been fixed upstream in #45299. This PR is superseded and will remain closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant