[Spec][DSA] Add --speculative-dsa-topk-backend - #36313
Merged
Merged
Conversation
zianglih
requested review from
1am9trash,
Fridge003,
HaiShaw,
JustinTong0323,
Qiaolin-Yu,
YAMY1234,
hebiao064,
hubertlu-tw,
ispobock,
kkHuang-amd,
merrymercy,
rainj-me,
sogalin,
wisclmy0611 and
zijiexia
as code owners
August 25, 2026 10:56
Contributor
Author
|
/tag-and-rerun-ci |
ziang-and
force-pushed
the
ziangli/mtp-sgl-kernel-topk
branch
from
August 25, 2026 18:41
5a86e03 to
49ac9d0
Compare
ziang-and
force-pushed
the
ziangli/mtp-sgl-kernel-topk
branch
from
August 25, 2026 18:55
49ac9d0 to
e06cd05
Compare
Contributor
Author
|
/tag-and-rerun-ci |
1 similar comment
Contributor
Author
|
/tag-and-rerun-ci |
Fridge003
approved these changes
Aug 26, 2026
This was referenced Aug 26, 2026
saturn-acc
pushed a commit
to saturn-acc/sglang
that referenced
this pull request
Aug 31, 2026
nzr-niu
pushed a commit
to nzr-niu/sglang
that referenced
this pull request
Sep 1, 2026
5 tasks
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 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
@HumansAnd
speculative draft workers.
--dsa-topk-backendcurrently reaches both roles because target and draftrunners share one
ServerArgs. A target override such asflashinfertherefore also changes repeated MTP draft top-k.
--speculative-dsa-topk-backend, defaulting tosgl-kernel, so thedraft stays on the usual fast path unless it is explicitly overridden.
roles, pass both selectors.
Modifications
--dsa-topk-backendas the target-model selector.--speculative-dsa-topk-backendfor speculative draft workers with thesame
sgl-kernel,torch, andflashinferchoices and asgl-kerneldefault.exec.kernel.dsa_topk_backend;spec.speculative_dsa_topk_backend.DeepseekSparseAttnBackend(DSA/GLM) andDeepseekV4AttnBackendwithout mutating the sharedServerArgs.satisfy the same role contract as production
ModelRunner.decoding references, including the DSA MTP path and FlashInfer environment
switches.
--dsa-topk-backend=<non-default>now apply that override only to thetarget. Pass the new flag as well to restore the previous target/draft
pairing.
SGLANG_DSA_FUSE_TOPK,SGLANG_OPT_USE_TOPK_V2, and the FlashInfer deterministic/tie-breaksettings remain process-wide. Selecting
torchfor either role stillrequires
SGLANG_DSA_FUSE_TOPK=false, which disables fused top-k for bothroles.
Accuracy Tests
Tested commits and environment:
e06cd057c3cb319970a283aafb3e23facbf7f55999c02d71b170673f97676f097fc928de38d847e0to GPU 0 with
CUDA_VISIBLE_DEVICES=0lmsysorg/sglang:nightly-dev-cu13-20260825-1ec20fd2(linux/amd64 digest
sha256:65376f9f5c317da614be2d6e2c683d8c4d7964cf8fa63f663a1cd058929598ca)590.48.01; CUDA13.0.3; Python3.12.3;PyTorch
2.13.0+cu130; Triton3.7.1the SHAs above and selected with
PYTHONPATH.Existing DSA and DeepSeek-V4 attention unit suites on the PR:
The skips are capability-gated on SM 10.3: FA3 is limited to SM 9.x, the image
does not contain a matching TileLang B300 template, TensorRT-LLM covers SM
10.0 rather than SM 10.3 here, AITER is AMD-only, and the remaining cases are
unsupported FP8/backend combinations.
Existing DSA metadata/transform and DeepSeek-V4 indexer unit suites on the PR:
Direct selector smoke against the resolved runtime namespaces:
Controlled PR/base comparison of the attention and B300 indexer suites, using
the same node, image, GPU, and command:
cd /sgl-workspace/sglang-pr36313 PYTHONPATH=/sgl-workspace/sglang-pr36313/python CUDA_VISIBLE_DEVICES=0 \ python3 -m pytest -q -ra \ test/registered/attention/unittests/dsa/test_dsa.py \ test/registered/attention/unittests/dsv4/test_deepseek_v4.py \ test/registered/kernels/ops/attention/test_dsa_indexer.pycd /sgl-workspace/sglang-pr36313-base PYTHONPATH=/sgl-workspace/sglang-pr36313-base/python CUDA_VISIBLE_DEVICES=0 \ python3 -m pytest -q -ra \ test/registered/attention/unittests/dsa/test_dsa.py \ test/registered/attention/unittests/dsv4/test_deepseek_v4.py \ test/registered/kernels/ops/attention/test_dsa_indexer.pyBoth commits fail the same two B300-only cases:
The failing workspace allocation reads
model_runner.max_running_requests; the unchanged upstream mock does notdefine that field. The identical base and PR outcomes bound this as a
pre-existing B300 test-mock limitation rather than a regression from this
change. The wall times are not a performance comparison because the second run
used warm JIT/caches.
No new standalone test cases are included; validation uses the existing DSA
suites plus the direct selector smoke above.
Static validation:
Speed Tests and Profiling
implementation, and makes no quantitative speedup claim.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ⏳ Run #32886603742
Latest PR Test (Extra): ❌ Run #32886603233
Latest PR Test (AMD ROCm 7.2): ⏳ Run #32886603588