Repository navigation
[KDA] Fused-accept state advance for FlashInfer KDA MTP verify - #33722
Merged
Merged
Conversation
yuan-luo
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
Ying1123,
hanming-lu,
hebiao064,
hnyls2002,
ispobock,
merrymercy and
yizhang2077
as code owners
August 5, 2026 14:33
yuan-luo
force-pushed
the
kda_fused_accept_state
branch
3 times, most recently
from
August 14, 2026 05:01
9ceebdf to
8cfa48b
Compare
kaixih
reviewed
Aug 17, 2026
kaixih
reviewed
Aug 17, 2026
yuan-luo
force-pushed
the
kda_fused_accept_state
branch
2 times, most recently
from
August 23, 2026 01:39
9bfa0e9 to
2b59cbf
Compare
yuan-luo
force-pushed
the
kda_fused_accept_state
branch
2 times, most recently
from
August 28, 2026 15:16
c2ceebd to
b8e78cf
Compare
Collaborator
Author
@kaixih I updated A/B perf results, which improved 44.5% - 62.5%. |
yuan-luo
force-pushed
the
kda_fused_accept_state
branch
from
August 29, 2026 02:14
b8e78cf to
73bc727
Compare
recurrent_kda's num_accepted_tokens lets the verify kernel seed itself from the accepted checkpoint slot of the previous round, so the per-round SSM commit scatter (intermediate -> temporal) can be skipped entirely. Capability-driven, via KDAAttnBackend._can_fuse_accept_state: - verify rows switch from batch positions to mamba slots (stable for the request lifetime, so last round's checkpoints stay addressable across batch churn); padded rows carry slot -1 and every derived index stays negative, which recurrent_kda treats as inactive - the committed-pool seed copy moves out of the per-verify path: extend stages slot 0 once per request (nat = 1), and each commit records this round's accept length into accept_lens_pool for the next verify's in-kernel seed selection - those verify indices are built once per forward, on the shared ForwardMetadata, rather than per layer: every KDA layer of a step sees the same slots and draft window, so a cuda-graph capture holds one build instead of twenty - the post-verify commit shrinks to the conv-window rollback plus that accept-length scatter, in HybridLinearAttnBackend's existing MTP hook beside the ReplaySSM-KDA branch; the all-layer SSM state scatter disappears and the generic spec_utils commit is untouched Seed value equals what the scatter used to commit and re-read (same tensor dtype, pure copy round-trip), so outputs are bit-identical by construction. It engages on the flashinfer KDA verify backend with speculative decoding on, radix cache off, replayssm-spec off and no PD disaggregation -- the readers of the committed pool that the skipped scatter would starve; anything short of the contract falls back to the scatter rather than raising. Measured on SM100 at Kimi-Linear-48B shapes (20 KDA layers, HV=32, K=V=128, T=4) with verify captured in a cuda graph: 393 -> 219 us per round at bs=1 (-44%), 721 -> 312 us at bs=4, 1968 -> 738 us at bs=16. Two-round legacy-vs-fused parity is bit-identical (torch.equal) at B=1/8/32 and T=4/6; unit tests pin the padding-negativity invariant of the slot arithmetic and the per-forward cache contract.
yuan-luo
force-pushed
the
kda_fused_accept_state
branch
from
August 29, 2026 10:28
73bc727 to
29bf571
Compare
kaixih
approved these changes
Aug 31, 2026
StevenChenSE
pushed a commit
to StevenChenSE/sglang
that referenced
this pull request
Sep 6, 2026
…roject#33722) Co-authored-by: luoyuan.luo <[email protected]>
5 tasks
lvj-repox
pushed a commit
to HYGON-AI/sglang-das
that referenced
this pull request
Sep 8, 2026
Attention: This Sync contains all updates of **v0.5.19** - https://github.com/sgl-project/sglang/releases/tag/v0.5.19 !! Main probable useful updates in HCU have been shown as below: 1. Kimi Model 1.1. KDA 融合 accept 路径:`SGLANG_OPT_KDA_FUSED_ACCEPT_STATE=1`,Kimi-Linear 形状下 MTP verify-and-commit 时间 −45%~−63%,输出 bit-identica 1.2 PD KV 传输打包:DCP1→DCP-N 打成目标连续 RDMA 块,Kimi-Linear-48B / 8×B300 传输时间 −28%~−39% 2. DeepSeek-V4 Model 2.1 Hopper W4A8 MoE:`--flashinfer-mxfp4-moe-precision fp8`,SM90 MXFP4 W4A8 CUTLASS, kernel 比 W4A16 快 1.63–2.08× 2.2 Q8KV8 sparse MLA prefill runtime backend:H20 上 3.5K–160K 输入 prefill 吞吐 +4.4%~+7.5% 2.3 新增 `--speculative-dsa-topk-backend` 3. Core Fatures 3.1 Attention - fmha_v2 后端(SM90/120):kernel 级 比 FA3 快约 15% - Triton SWA extend 收紧 KV 循环:SWA 层 −86.6%,prefill GPU −9.4%,bit-identical 3.2 MoE - DeepEP v2(ElasticBuffer)`--moe-a2a-backend deepep_v2`:buffer 固定大小 → 跨节点 decode 也能跑 CUDA graph,性能与经典 DeepEP 持平;支持 DSV3/V4 与 Qwen3-MoE 的 FP8 - W4AFP8 DeepEP 低延迟 requant launch geometry 调优:256 专家下 requant kernel 最高 10.6× 4. Other Features about Performance Improvement **Prefill** | 优化 | 收益 | | --- | --- | | breakable prefill CUDA graph 减少空转 DP 工作(#33871) | **median TTFT −18.9%,QPS +12.9%** | | DSV4 shared-experts fusion(sgl-project/sglang#35505) | **TTFT −13%~−21%** | | LayerNorm 序列并行 `--enable-layernorm-sp`(#30915) | Qwen3-8B prefill **H100 −3.5% / B200 −5.6%**,TP 越大收益越大(暂仅 dense Qwen3) | | **humming FP8 DeepEP dispatch**(#31429)/ W4AFP8 原生 schema(#32033) | **H20 TTFT −23% / −10%~−11%** | **Decode** 优化 | 收益 -- | -- KDA 融合 accept(sgl-project/sglang#33722) | verify-commit −45%~−63% humming FP8 dispatch / W4AFP8(#31429/#32033) | H20 TPOT −35% / −22%~−29% SM90 FP8 decode 路由回归修复(#37018) | decode 190 → 215 tok/s ROCm GLM-5.2 PD fused-TopK seed remap(#36714)/ shared-experts gate 修复(#36124) | TPOT 23.16ms→7.94ms / +16% ## Motivation <!-- Describe the purpose and goals of this pull request. --> ## Modifications <!-- Detail the changes made in this pull request. --> ## Accuracy Tests <!-- If this pull request affects model outputs (e.g., changes to the kernel or model forward code), provide accuracy test results. --> ## Speed Tests and Profiling <!-- If this pull request impacts inference speed, provide benchmarking and profiling results. --> ## Checklist - [ ] Format your code according to the [Format code with pre-commit](https://docs.sglang.io/developer_guide/contribution_guide.html#format-code-with-pre-commit). - [ ] Add unit tests according to the [Run and add unit tests](https://docs.sglang.io/developer_guide/contribution_guide.html#run-and-add-unit-tests). - [ ] Update documentation according to [Write documentations](https://docs.sglang.io/developer_guide/contribution_guide.html#write-documentations). - [ ] Provide accuracy and speed benchmark results according to [Test the accuracy](https://docs.sglang.io/developer_guide/contribution_guide.html#test-the-accuracy) and [Benchmark the speed](https://docs.sglang.io/developer_guide/contribution_guide.html#benchmark-the-speed). - [ ] Follow the SGLang code style [guidance](https://docs.sglang.io/developer_guide/contribution_guide.html#code-style-guidance). ## Review and Merge Process 1. Ping Merge Oncalls to start the process. See the [PR Merge Process](https://github.com/sgl-project/sglang/blob/main/.github/MAINTAINER.md#pull-request-merge-process). 6. Get approvals from [CODEOWNERS](https://github.com/sgl-project/sglang/blob/main/.github/CODEOWNERS) and other reviewers. 7. Trigger CI tests with [comments](https://docs.sglang.io/developer_guide/contribution_guide.html#how-to-trigger-ci-tests) or contact authorized users to do so. - Common commands include `/tag-and-rerun-ci`, `/tag-run-ci-label`, `/rerun-failed-ci` 8. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR. <!-- pr-states:start --> --- ### CI States Latest PR Test (Base): <!-- slot:pr-test:start -->:x: **Missing `run-ci` label** -- add it to run CI tests.<!-- slot:pr-test:end --> Latest PR Test (Extra): <!-- slot:pr-test-extra:start -->:x: **Blocked** -- `run-ci` is required first.<!-- slot:pr-test-extra:end --> <!-- pr-states:end --> --------- Signed-off-by: Shiyan Deng <[email protected]> Signed-off-by: P V R K Jyothendra Varma <[email protected]> Signed-off-by: Martin Hickey <[email protected]> Signed-off-by: Shijin Zhang <[email protected]> Signed-off-by: Hemanth Acharya <[email protected]> Signed-off-by: joeltg <[email protected]> Signed-off-by: Joe Rowell <[email protected]> Signed-off-by: Vincent Gao <[email protected]> Signed-off-by: syd520zy <[email protected]> Co-authored-by: Liangsheng Yin <[email protected]> Co-authored-by: Joe <[email protected]> Co-authored-by: BBuf <[email protected]> Co-authored-by: cctry <[email protected]> Co-authored-by: Faradawn Yang <[email protected]> Co-authored-by: YAMY <[email protected]> Co-authored-by: eeecho <[email protected]> Co-authored-by: Baizhou Zhang <[email protected]> Co-authored-by: paulzhang-tm <[email protected]> Co-authored-by: Qiaolin-Yu <[email protected]> Co-authored-by: Mohammad Miadh Angkad <[email protected]> Co-authored-by: Alison Shao <[email protected]> Co-authored-by: wangwenmingaa <[email protected]> Co-authored-by: wangwenming.41 <[email protected]> Co-authored-by: hnyls2002 <[email protected]> Co-authored-by: Cheng Wan <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Byron Hsu <[email protected]> Co-authored-by: ByronHsu <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: Oguz Ulgen <[email protected]> Co-authored-by: Lianmin Zheng <[email protected]> Co-authored-by: Shiyan Deng <[email protected]> Co-authored-by: Yinghai Lu <[email protected]> Co-authored-by: jiayisuse <[email protected]> Co-authored-by: Hao Zhang <[email protected]> Co-authored-by: Yichao Fu <[email protected]> Co-authored-by: Lee Nau <[email protected]> Co-authored-by: Yangmin Li <[email protected]> Co-authored-by: Khoa Pham <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: Mick <[email protected]> Co-authored-by: Meng, Hengyu <[email protected]> Co-authored-by: dayanandav <[email protected]> Co-authored-by: Girijala, Pavan Sivaram <[email protected]> Co-authored-by: Cui, Lily <[email protected]> Co-authored-by: Juan Muneton <[email protected]> Co-authored-by: Gao, Pengfei <[email protected]> Co-authored-by: Alex Nails <[email protected]> Co-authored-by: Alison Shao <[email protected]> Co-authored-by: James Liu <[email protected]> Co-authored-by: hhhh1252023 <[email protected]> Co-authored-by: Yash Akhauri <[email protected]> Co-authored-by: Zaili Wang <[email protected]> Co-authored-by: xiaobochen-amd <[email protected]> Co-authored-by: Zhang, Jiejing <[email protected]> Co-authored-by: YC Yen-Ching Tseng <[email protected]> Co-authored-by: Phil Li <[email protected]> Co-authored-by: Polisetty V R K Jyothendra Varma <[email protected]> Co-authored-by: Xinyi Song <[email protected]> Co-authored-by: Thomas Wang <[email protected]> Co-authored-by: kk <[email protected]> Co-authored-by: wunhuang <[email protected]> Co-authored-by: yhyang201 <[email protected]> Co-authored-by: Yuhao Yang <[email protected]> Co-authored-by: Duyi-Wang <[email protected]> Co-authored-by: Chen <[email protected]> Co-authored-by: amote-i <[email protected]> Co-authored-by: drproduck <[email protected]> Co-authored-by: Yihao Wang <[email protected]> Co-authored-by: dujifeng <[email protected]> Co-authored-by: mickqian <[email protected]> Co-authored-by: pllimax <[email protected]> Co-authored-by: Quanli Li <[email protected]> Co-authored-by: 全力 <[email protected]> Co-authored-by: triple-mu <[email protected]> Co-authored-by: Vincent Gao <[email protected]> Co-authored-by: inkcherry <[email protected]> Co-authored-by: Yonghao Zhuang <[email protected]> Co-authored-by: yhzhuang <[email protected]> Co-authored-by: Zhangheng <[email protected]> Co-authored-by: 晟海 <[email protected]> Co-authored-by: Jimmy Shong <[email protected]> Co-authored-by: Zhiqiang Xie <[email protected]> Co-authored-by: Martin Hickey <[email protected]> Co-authored-by: Yueming Yuan <[email protected]> Co-authored-by: heziiop <[email protected]> Co-authored-by: eigen <[email protected]> Co-authored-by: Yingyi Huang <[email protected]> Co-authored-by: Kedi Wu <[email protected]> Co-authored-by: Kedi Wu <[email protected]> Co-authored-by: Li Jinliang <[email protected]> Co-authored-by: Aleksi Vesanto <[email protected]> Co-authored-by: Mohammad Angkad <[email protected]> Co-authored-by: jundu <[email protected]> Co-authored-by: Ma Mingfei <[email protected]> Co-authored-by: Ruiyan Ma <[email protected]> Co-authored-by: zhouhaizhu.zhz <[email protected]> Co-authored-by: LinSiyuan814 <[email protected]> Co-authored-by: ashwini rathi <[email protected]> Co-authored-by: Shijin Zhang <[email protected]> Co-authored-by: cctry <[email protected]> Co-authored-by: Thomas Wang <[email protected]> Co-authored-by: AMD-yanfeiwang <[email protected]> Co-authored-by: mqhc2020 <[email protected]> Co-authored-by: Po-Han Huang (NVIDIA) <[email protected]> Co-authored-by: Juan Muneton <[email protected]> Co-authored-by: Yu-Yun Chang <[email protected]> Co-authored-by: HAI <[email protected]> Co-authored-by: Hemanth Acharya <[email protected]> Co-authored-by: Ke Bao <[email protected]> Co-authored-by: adityakamat24 <[email protected]> Co-authored-by: karverma-amd <[email protected]> Co-authored-by: weireweire <[email protected]> Co-authored-by: Sam Shleifer <[email protected]> Co-authored-by: Ming Yang <[email protected]> Co-authored-by: Brian <[email protected]> Co-authored-by: CSWYF3634076 <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: Kan Wu <[email protected]> Co-authored-by: Rain Jiang <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Kevin Mi <[email protected]> Co-authored-by: Shuwen Wang <[email protected]> Co-authored-by: Zhylko Dima <[email protected]> Co-authored-by: Dawid Majchrowski <[email protected]> Co-authored-by: Joel Gustafson <[email protected]> Co-authored-by: Jialin Ouyang <[email protected]> Co-authored-by: pranjalssh <[email protected]> Co-authored-by: huangtingwei <[email protected]> Co-authored-by: Cherry_ming <[email protected]> Co-authored-by: Even Zhou <[email protected]> Co-authored-by: sglang-npu-bot <[email protected]> Co-authored-by: Pranjal Shankhdhar <[email protected]> Co-authored-by: Yongji Wu <[email protected]> Co-authored-by: alp <[email protected]> Co-authored-by: mottopanikeiku <[email protected]> Co-authored-by: Hanming Lu <[email protected]> Co-authored-by: PengYuan <[email protected]> Co-authored-by: Amy Chang <[email protected]> Co-authored-by: zijiexia <[email protected]> Co-authored-by: Clint <[email protected]> Co-authored-by: clintg6 <[email protected]> Co-authored-by: alphabetc1 <[email protected]> Co-authored-by: BBuf <[email protected]> Co-authored-by: Niko Ma <[email protected]> Co-authored-by: BBuf <[email protected]> Co-authored-by: Brayden Zhong <[email protected]> Co-authored-by: Brayden Zhong <[email protected]> Co-authored-by: Vincent Gao <[email protected]> Co-authored-by: Kangyan Zhou <[email protected]> Co-authored-by: Shangming Cai <[email protected]> Co-authored-by: Jincong Chen <[email protected]> Co-authored-by: Xin Du <[email protected]> Co-authored-by: duxin <[email protected]> Co-authored-by: jacky.cheng <[email protected]> Co-authored-by: Dayuxiaoshui <[email protected]> Co-authored-by: Sugar920 <[email protected]> Co-authored-by: Sugar920 <[email protected]> Co-authored-by: Beihao Zhou <[email protected]> Co-authored-by: Waterpine <[email protected]> Co-authored-by: zql <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: yuttian1 <[email protected]> Co-authored-by: Depend <[email protected]> Co-authored-by: zRzRzRzRzRzRzR <[email protected]> Co-authored-by: zanes-ops <[email protected]> Co-authored-by: Jian Chen <[email protected]> Co-authored-by: andyluo7 <[email protected]> Co-authored-by: Ehsan Akhgari <[email protected]> Co-authored-by: Raiden Makoto <[email protected]> Co-authored-by: yangbodong22011 <[email protected]> Co-authored-by: s <[email protected]> Co-authored-by: JohnQinAMD <[email protected]> Co-authored-by: sglang-bot <[email protected]> Co-authored-by: sglang-bot <[email protected]> Co-authored-by: faceless void <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Yuxingwang-intel <[email protected]> Co-authored-by: ori <[email protected]> Co-authored-by: zhiguo.qin <[email protected]> Co-authored-by: Xia Weiwen <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Arathi Rajanra <[email protected]> Co-authored-by: kangwangamd <[email protected]> Co-authored-by: billishyahao <[email protected]> Co-authored-by: Samuel Nordmann <[email protected]> Co-authored-by: Chunyuan WU <[email protected]> Co-authored-by: Siju Samuel <[email protected]> Co-authored-by: xieminghe1 <[email protected]> Co-authored-by: undefined <[email protected]> Co-authored-by: xq25478 <[email protected]> Co-authored-by: xieminghe.simon <[email protected]> Co-authored-by: Rohit Kumar Singh <[email protected]> Co-authored-by: Singh <[email protected]> Co-authored-by: Singh <[email protected]> Co-authored-by: Pramod Kumar <[email protected]> Co-authored-by: Kotthagattu Meher Sai <[email protected]> Co-authored-by: lizhigong <[email protected]>
3 of 5 tasks
2 of 5 tasks
Crowder13
pushed a commit
to Crowder13/sglang-das
that referenced
this pull request
Sep 23, 2026
Attention: This Sync contains all updates of **v0.5.19** - https://github.com/sgl-project/sglang/releases/tag/v0.5.19 !! Main probable useful updates in HCU have been shown as below: 1. Kimi Model 1.1. KDA 融合 accept 路径:`SGLANG_OPT_KDA_FUSED_ACCEPT_STATE=1`,Kimi-Linear 形状下 MTP verify-and-commit 时间 −45%~−63%,输出 bit-identica 1.2 PD KV 传输打包:DCP1→DCP-N 打成目标连续 RDMA 块,Kimi-Linear-48B / 8×B300 传输时间 −28%~−39% 2. DeepSeek-V4 Model 2.1 Hopper W4A8 MoE:`--flashinfer-mxfp4-moe-precision fp8`,SM90 MXFP4 W4A8 CUTLASS, kernel 比 W4A16 快 1.63–2.08× 2.2 Q8KV8 sparse MLA prefill runtime backend:H20 上 3.5K–160K 输入 prefill 吞吐 +4.4%~+7.5% 2.3 新增 `--speculative-dsa-topk-backend` 3. Core Fatures 3.1 Attention - fmha_v2 后端(SM90/120):kernel 级 比 FA3 快约 15% - Triton SWA extend 收紧 KV 循环:SWA 层 −86.6%,prefill GPU −9.4%,bit-identical 3.2 MoE - DeepEP v2(ElasticBuffer)`--moe-a2a-backend deepep_v2`:buffer 固定大小 → 跨节点 decode 也能跑 CUDA graph,性能与经典 DeepEP 持平;支持 DSV3/V4 与 Qwen3-MoE 的 FP8 - W4AFP8 DeepEP 低延迟 requant launch geometry 调优:256 专家下 requant kernel 最高 10.6× 4. Other Features about Performance Improvement **Prefill** | 优化 | 收益 | | --- | --- | | breakable prefill CUDA graph 减少空转 DP 工作(#33871) | **median TTFT −18.9%,QPS +12.9%** | | DSV4 shared-experts fusion(sgl-project/sglang#35505) | **TTFT −13%~−21%** | | LayerNorm 序列并行 `--enable-layernorm-sp`(#30915) | Qwen3-8B prefill **H100 −3.5% / B200 −5.6%**,TP 越大收益越大(暂仅 dense Qwen3) | | **humming FP8 DeepEP dispatch**(#31429)/ W4AFP8 原生 schema(#32033) | **H20 TTFT −23% / −10%~−11%** | **Decode** 优化 | 收益 -- | -- KDA 融合 accept(sgl-project/sglang#33722) | verify-commit −45%~−63% humming FP8 dispatch / W4AFP8(#31429/#32033) | H20 TPOT −35% / −22%~−29% SM90 FP8 decode 路由回归修复(#37018) | decode 190 → 215 tok/s ROCm GLM-5.2 PD fused-TopK seed remap(#36714)/ shared-experts gate 修复(#36124) | TPOT 23.16ms→7.94ms / +16% ## Motivation <!-- Describe the purpose and goals of this pull request. --> ## Modifications <!-- Detail the changes made in this pull request. --> ## Accuracy Tests <!-- If this pull request affects model outputs (e.g., changes to the kernel or model forward code), provide accuracy test results. --> ## Speed Tests and Profiling <!-- If this pull request impacts inference speed, provide benchmarking and profiling results. --> ## Checklist - [ ] Format your code according to the [Format code with pre-commit](https://docs.sglang.io/developer_guide/contribution_guide.html#format-code-with-pre-commit). - [ ] Add unit tests according to the [Run and add unit tests](https://docs.sglang.io/developer_guide/contribution_guide.html#run-and-add-unit-tests). - [ ] Update documentation according to [Write documentations](https://docs.sglang.io/developer_guide/contribution_guide.html#write-documentations). - [ ] Provide accuracy and speed benchmark results according to [Test the accuracy](https://docs.sglang.io/developer_guide/contribution_guide.html#test-the-accuracy) and [Benchmark the speed](https://docs.sglang.io/developer_guide/contribution_guide.html#benchmark-the-speed). - [ ] Follow the SGLang code style [guidance](https://docs.sglang.io/developer_guide/contribution_guide.html#code-style-guidance). ## Review and Merge Process 1. Ping Merge Oncalls to start the process. See the [PR Merge Process](https://github.com/sgl-project/sglang/blob/main/.github/MAINTAINER.md#pull-request-merge-process). 6. Get approvals from [CODEOWNERS](https://github.com/sgl-project/sglang/blob/main/.github/CODEOWNERS) and other reviewers. 7. Trigger CI tests with [comments](https://docs.sglang.io/developer_guide/contribution_guide.html#how-to-trigger-ci-tests) or contact authorized users to do so. - Common commands include `/tag-and-rerun-ci`, `/tag-run-ci-label`, `/rerun-failed-ci` 8. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR. <!-- pr-states:start --> --- ### CI States Latest PR Test (Base): <!-- slot:pr-test:start -->:x: **Missing `run-ci` label** -- add it to run CI tests.<!-- slot:pr-test:end --> Latest PR Test (Extra): <!-- slot:pr-test-extra:start -->:x: **Blocked** -- `run-ci` is required first.<!-- slot:pr-test-extra:end --> <!-- pr-states:end --> --------- Signed-off-by: Shiyan Deng <[email protected]> Signed-off-by: P V R K Jyothendra Varma <[email protected]> Signed-off-by: Martin Hickey <[email protected]> Signed-off-by: Shijin Zhang <[email protected]> Signed-off-by: Hemanth Acharya <[email protected]> Signed-off-by: joeltg <[email protected]> Signed-off-by: Joe Rowell <[email protected]> Signed-off-by: Vincent Gao <[email protected]> Signed-off-by: syd520zy <[email protected]> Co-authored-by: Liangsheng Yin <[email protected]> Co-authored-by: Joe <[email protected]> Co-authored-by: BBuf <[email protected]> Co-authored-by: cctry <[email protected]> Co-authored-by: Faradawn Yang <[email protected]> Co-authored-by: YAMY <[email protected]> Co-authored-by: eeecho <[email protected]> Co-authored-by: Baizhou Zhang <[email protected]> Co-authored-by: paulzhang-tm <[email protected]> Co-authored-by: Qiaolin-Yu <[email protected]> Co-authored-by: Mohammad Miadh Angkad <[email protected]> Co-authored-by: Alison Shao <[email protected]> Co-authored-by: wangwenmingaa <[email protected]> Co-authored-by: wangwenming.41 <[email protected]> Co-authored-by: hnyls2002 <[email protected]> Co-authored-by: Cheng Wan <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Byron Hsu <[email protected]> Co-authored-by: ByronHsu <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: Oguz Ulgen <[email protected]> Co-authored-by: Lianmin Zheng <[email protected]> Co-authored-by: Shiyan Deng <[email protected]> Co-authored-by: Yinghai Lu <[email protected]> Co-authored-by: jiayisuse <[email protected]> Co-authored-by: Hao Zhang <[email protected]> Co-authored-by: Yichao Fu <[email protected]> Co-authored-by: Lee Nau <[email protected]> Co-authored-by: Yangmin Li <[email protected]> Co-authored-by: Khoa Pham <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: Mick <[email protected]> Co-authored-by: Meng, Hengyu <[email protected]> Co-authored-by: dayanandav <[email protected]> Co-authored-by: Girijala, Pavan Sivaram <[email protected]> Co-authored-by: Cui, Lily <[email protected]> Co-authored-by: Juan Muneton <[email protected]> Co-authored-by: Gao, Pengfei <[email protected]> Co-authored-by: Alex Nails <[email protected]> Co-authored-by: Alison Shao <[email protected]> Co-authored-by: James Liu <[email protected]> Co-authored-by: hhhh1252023 <[email protected]> Co-authored-by: Yash Akhauri <[email protected]> Co-authored-by: Zaili Wang <[email protected]> Co-authored-by: xiaobochen-amd <[email protected]> Co-authored-by: Zhang, Jiejing <[email protected]> Co-authored-by: YC Yen-Ching Tseng <[email protected]> Co-authored-by: Phil Li <[email protected]> Co-authored-by: Polisetty V R K Jyothendra Varma <[email protected]> Co-authored-by: Xinyi Song <[email protected]> Co-authored-by: Thomas Wang <[email protected]> Co-authored-by: kk <[email protected]> Co-authored-by: wunhuang <[email protected]> Co-authored-by: yhyang201 <[email protected]> Co-authored-by: Yuhao Yang <[email protected]> Co-authored-by: Duyi-Wang <[email protected]> Co-authored-by: Chen <[email protected]> Co-authored-by: amote-i <[email protected]> Co-authored-by: drproduck <[email protected]> Co-authored-by: Yihao Wang <[email protected]> Co-authored-by: dujifeng <[email protected]> Co-authored-by: mickqian <[email protected]> Co-authored-by: pllimax <[email protected]> Co-authored-by: Quanli Li <[email protected]> Co-authored-by: 全力 <[email protected]> Co-authored-by: triple-mu <[email protected]> Co-authored-by: Vincent Gao <[email protected]> Co-authored-by: inkcherry <[email protected]> Co-authored-by: Yonghao Zhuang <[email protected]> Co-authored-by: yhzhuang <[email protected]> Co-authored-by: Zhangheng <[email protected]> Co-authored-by: 晟海 <[email protected]> Co-authored-by: Jimmy Shong <[email protected]> Co-authored-by: Zhiqiang Xie <[email protected]> Co-authored-by: Martin Hickey <[email protected]> Co-authored-by: Yueming Yuan <[email protected]> Co-authored-by: heziiop <[email protected]> Co-authored-by: eigen <[email protected]> Co-authored-by: Yingyi Huang <[email protected]> Co-authored-by: Kedi Wu <[email protected]> Co-authored-by: Kedi Wu <[email protected]> Co-authored-by: Li Jinliang <[email protected]> Co-authored-by: Aleksi Vesanto <[email protected]> Co-authored-by: Mohammad Angkad <[email protected]> Co-authored-by: jundu <[email protected]> Co-authored-by: Ma Mingfei <[email protected]> Co-authored-by: Ruiyan Ma <[email protected]> Co-authored-by: zhouhaizhu.zhz <[email protected]> Co-authored-by: LinSiyuan814 <[email protected]> Co-authored-by: ashwini rathi <[email protected]> Co-authored-by: Shijin Zhang <[email protected]> Co-authored-by: cctry <[email protected]> Co-authored-by: Thomas Wang <[email protected]> Co-authored-by: AMD-yanfeiwang <[email protected]> Co-authored-by: mqhc2020 <[email protected]> Co-authored-by: Po-Han Huang (NVIDIA) <[email protected]> Co-authored-by: Juan Muneton <[email protected]> Co-authored-by: Yu-Yun Chang <[email protected]> Co-authored-by: HAI <[email protected]> Co-authored-by: Hemanth Acharya <[email protected]> Co-authored-by: Ke Bao <[email protected]> Co-authored-by: adityakamat24 <[email protected]> Co-authored-by: karverma-amd <[email protected]> Co-authored-by: weireweire <[email protected]> Co-authored-by: Sam Shleifer <[email protected]> Co-authored-by: Ming Yang <[email protected]> Co-authored-by: Brian <[email protected]> Co-authored-by: CSWYF3634076 <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: Kan Wu <[email protected]> Co-authored-by: Rain Jiang <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Kevin Mi <[email protected]> Co-authored-by: Shuwen Wang <[email protected]> Co-authored-by: Zhylko Dima <[email protected]> Co-authored-by: Dawid Majchrowski <[email protected]> Co-authored-by: Joel Gustafson <[email protected]> Co-authored-by: Jialin Ouyang <[email protected]> Co-authored-by: pranjalssh <[email protected]> Co-authored-by: huangtingwei <[email protected]> Co-authored-by: Cherry_ming <[email protected]> Co-authored-by: Even Zhou <[email protected]> Co-authored-by: sglang-npu-bot <[email protected]> Co-authored-by: Pranjal Shankhdhar <[email protected]> Co-authored-by: Yongji Wu <[email protected]> Co-authored-by: alp <[email protected]> Co-authored-by: mottopanikeiku <[email protected]> Co-authored-by: Hanming Lu <[email protected]> Co-authored-by: PengYuan <[email protected]> Co-authored-by: Amy Chang <[email protected]> Co-authored-by: zijiexia <[email protected]> Co-authored-by: Clint <[email protected]> Co-authored-by: clintg6 <[email protected]> Co-authored-by: alphabetc1 <[email protected]> Co-authored-by: BBuf <[email protected]> Co-authored-by: Niko Ma <[email protected]> Co-authored-by: BBuf <[email protected]> Co-authored-by: Brayden Zhong <[email protected]> Co-authored-by: Brayden Zhong <[email protected]> Co-authored-by: Vincent Gao <[email protected]> Co-authored-by: Kangyan Zhou <[email protected]> Co-authored-by: Shangming Cai <[email protected]> Co-authored-by: Jincong Chen <[email protected]> Co-authored-by: Xin Du <[email protected]> Co-authored-by: duxin <[email protected]> Co-authored-by: jacky.cheng <[email protected]> Co-authored-by: Dayuxiaoshui <[email protected]> Co-authored-by: Sugar920 <[email protected]> Co-authored-by: Sugar920 <[email protected]> Co-authored-by: Beihao Zhou <[email protected]> Co-authored-by: Waterpine <[email protected]> Co-authored-by: zql <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: yuttian1 <[email protected]> Co-authored-by: Depend <[email protected]> Co-authored-by: zRzRzRzRzRzRzR <[email protected]> Co-authored-by: zanes-ops <[email protected]> Co-authored-by: Jian Chen <[email protected]> Co-authored-by: andyluo7 <[email protected]> Co-authored-by: Ehsan Akhgari <[email protected]> Co-authored-by: Raiden Makoto <[email protected]> Co-authored-by: yangbodong22011 <[email protected]> Co-authored-by: s <[email protected]> Co-authored-by: JohnQinAMD <[email protected]> Co-authored-by: sglang-bot <[email protected]> Co-authored-by: sglang-bot <[email protected]> Co-authored-by: faceless void <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Yuxingwang-intel <[email protected]> Co-authored-by: ori <[email protected]> Co-authored-by: zhiguo.qin <[email protected]> Co-authored-by: Xia Weiwen <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Arathi Rajanra <[email protected]> Co-authored-by: kangwangamd <[email protected]> Co-authored-by: billishyahao <[email protected]> Co-authored-by: Samuel Nordmann <[email protected]> Co-authored-by: Chunyuan WU <[email protected]> Co-authored-by: Siju Samuel <[email protected]> Co-authored-by: xieminghe1 <[email protected]> Co-authored-by: undefined <[email protected]> Co-authored-by: xq25478 <[email protected]> Co-authored-by: xieminghe.simon <[email protected]> Co-authored-by: Rohit Kumar Singh <[email protected]> Co-authored-by: Singh <[email protected]> Co-authored-by: Singh <[email protected]> Co-authored-by: Pramod Kumar <[email protected]> Co-authored-by: Kotthagattu Meher Sai <[email protected]> Co-authored-by: lizhigong <[email protected]>
1 task done
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
KDA MTP verify on the FlashInfer path (
recurrent_kda, SM100) is two-phase today: the verify kernel writes every draft token's post-state into the speculativeintermediate_ssmscratch, thencommit_mamba_states_after_verifyscatters the accepted checkpoint back into the persistent pool (temporal) across all KDA layers, and the next verify re-reads the committed state as its seed. The scatter is a full recurrent-state write per request per round —num_kda_layers × HV × V × K × 4B(≈4 MB per layer per request at HV=16, K=V=128 fp32) — plus one kernel launch and its host dispatch, all sitting in the bs=1 MTP inter-phase seam.FlashInfer's
recurrent_kdaalready ships the missing half: anum_accepted_tokensparameter ("fused speculative decode") that makes the kernel seed itself fromssm_state_indices[n, nat - 1]— the checkpoint after the last accepted token of the previous round — instead of slot 0. sglang never passes it. With it, the SSM commit scatter can be skipped entirely: the accepted state is consumed where it already lives.Modifications
One commit, gated by
SGLANG_OPT_KDA_FUSED_ACCEPT_STATE(env, default off — zero change to any default path):[N, T]state indices are built from the requests' mamba slots (stable for the request lifetime) instead of batch positions, so last round's checkpoints stay addressable across batch membership changes. Padded CUDA-graph rows carry slot-1; every derived index stays negative, whichrecurrent_kdanatively treats as inactive — no extra padding plumbing.scratch[slot, 0], accept length 1); continuing requests seed in-kernel fromslot[nat - 1], withnatgathered from a persistent per-slotaccept_lens_pool— all device-side ops, CUDA-graph capture safe.commit_mamba_states_after_verifykeeps only the conv-window rollback (FlashInfer does not own the conv path) plus a tiny scatter recording this round's accept lengths for the next verify's seed selection. The all-layer SSM state scatter disappears.--disable-radix-cache(the committed SSM pool goes stale between verifies; nothing may read it mid-stream), and is mutually exclusive with--enable-linear-replayssm-spec(both mechanisms own the verify-round SSM state commitment).Bit-exactness by construction: the in-kernel seed value is byte-identical to what the scatter used to commit and the next round re-read (same tensor dtype, pure copy round-trip), so outputs cannot change.
Relationship to Kimi-K3: the K3 DSpark verify kernel follows the same read-only-persistent-state contract and still commits via the scatter; extending fused-accept to that path (separate seed-index tensor in the kernel) is planned follow-up and does not affect this PR.
Accuracy Tests
test/registered/attention/unittests/hybrid_linear/test_kda_fused_accept_indices.py(6 cases).TestBuildFusedAcceptIndicespins the padding-negativity invariant of the slot-index arithmetic (a padded slot must yield only negative indices for every step — an arithmetic reorder would silently activate padded rows) and theaccept_lens_poolgather semantics.TestFusedAcceptPerForwardCacheguards the per-forward build: what the layers share must equal what each would have built, a different batch must produce different rows, and a freshForwardMetadatamust arrive uncached — a cache outliving its forward would seed the next batch from the previous batch's mamba slots, which is a silent wrong-state bug with no shape or index error to catch it.recurrent_kda). Two-round legacy-vs-fused (legacy seed-copy + manual commit vs fused staging +natseeding, with deliberately offset slots so slot-indexed rows differ from batch positions):torch.equal— notallclose— on both rounds' outputs, on the final accepted states, and on the committed pool being untouched by fused. PASS at B=1/8/32 and T=4/6. The hoist has its own case: 20 layers sharing one index build vs 20 layers each building their own, bit-identical at B=1 and B=8, so an aliased or stale shared tensor surfaces as a value difference rather than an error.Speed Tests and Profiling
A/B of the changed path on SM100 (B200, FlashInfer 0.6.14), Kimi-Linear-48B shapes: 20 KDA layers, HV=32, K=V=128, draft window T=4, bf16 state. The 20 per-layer verify calls are captured in a CUDA graph and timed by replay — the mode the real verify path runs in — while the post-verify commit is timed eagerly because it runs after the forward. Min of 5 x 100 iterations.
Breakdown at B=1: the 20 verify kernels are ~212 us; the per-layer committed-pool seed copy fused-accept removes is ~8 us/layer; the per-layer index build the hoist removes is ~9.2 us/layer. The SSM commit scatter this replaces measures 18.3 / 30.9 / 110.8 us at B=1/4/16, against a flat ~5 us accept-length write.
Checklist
CI States
Latest PR Test (Base): ✅ Run #33247915582
Latest PR Test (Extra): ⏳ Run #33374614240
Latest PR Test (AMD ROCm 7.2): ❌ Run #33247915571