Skip to content

feat: add ReplaySSM state modes and optimize GDN MTP decoding - #1585

Open
sufubao wants to merge 20 commits into
ModelTC:mainfrom
sufubao:support-replayssm
Open

sufubao wants to merge 20 commits into
ModelTC:mainfrom
sufubao:support-replayssm

Conversation

@sufubao

@sufubao sufubao commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

为 GDN 和 GLM-5.3-FLASH KDA 增加可选的 compact / replay 状态存储,减少 MTP 的逐 token SSM 快照;默认保持 native。同时提供显式启用的 GDN MTP 并行求解路径,在相同 MTP 配置与资源容量下提升 Qwen3.5-27B 的端到端吞吐。

实现

  • compact 保存当前轮输入并合并接受前缀,要求启用 MTP;replay 保留一个 checkpoint 和有界历史,溢出前 fold。GDN/KDA 共用启动校验在 native、compact、replay 三种模式下统一要求 mtp_step <= 15,与接受提交算子的最大 verify 宽度 16 对齐;replay 的缓存容量另行校验,扩大 cache_len 不会放宽 MTP 宽度上限。接入 prefill、普通 decode、固定/动态 MTP、CPU checkpoint 和 PD 生命周期,保留 GLM indexer tail。
  • GDN/KDA 支持 FP32/BF16 状态及 inline/precompute。KDA 按 key 维衰减,使用正向衰减的低秩历史重建。调参仅执行独立 scratch,按 batch 与 recurrence/precision/history/stride 隔离布局;模型输出传递 verify 配置,保证 Graph、padding 和 microbatch acceptance 使用对应配置。
  • 启动入口为 --ssm_state_mode native|compact|replay 和 replay 专用的 --ssm_replay_config JSON 对象,字段为 cache_len、compute_mode、fold_method,默认分别为 16、inline、raw。拒绝未知字段、非法组合及非 replay 模式的非空配置。
  • --ssm_state_mode replay --ssm_replay_config '{"compute_mode":"parallel","fold_method":"derived"}' 启用 BF16 GDN MTP、128×128 heads 的 Tensor Core 三角求解,并复用 FP32 历史 keys/deltas 进行矩阵 fold。仅设置 "compute_mode":"parallel" 时仍使用默认 raw fold。
  • 对 Qwen3.5 dense / TP1 / fixed EAGLE-with-attention 的 parallel 路径扩展首轮 draft 图覆盖,仅对 accepted-tail hidden rows 做词表投影,保留完整 KV 写入和 hidden 收集。动态 MTP、decode overlap 和其他模型保留原 draft 布局。
  • 优化 LM head 输出布局、移除 gate 的冗余连续化拷贝,增加融合 greedy/logprob 与 draft argmax,默认 token 惩罚跳过无效计算,同时保留 EOS 和非法 token 处理。
  • 补齐两个 ViT FA3 入口在 sglang-kernel 0.4.5 中新增的默认参数,修复多模态 P 节点初始化失败;回归测试直接覆盖 FA3,避免自动回退到 Triton 掩盖接口错误。
  • 保留 GLM empty/HOLD DeepGEMM 调度修复及标准状态导出。未纳入收益可忽略的批量 checkpoint、普通 decode prepare/accept 融合及临时实验原型。

H200 端到端复测

对照提交 3af33c2f47f1738e17eb70a3c1e8f42e25ed65ed。同一 H200 GPU5、Qwen3.5-27B、TP1、MTP4、BF16 SSM、L16、264 请求容量和 65536 KV-token 容量。候选启用 parallel + derived,其余计算配置一致。两边均使用正常 API 入口,各预热 2 轮、正式测量 12 轮;并发 128、每请求固定输出 384 token、greedy、关闭 thinking、禁用 prompt-cache 查询。

指标 原 PR 本次代码
端到端吞吐,token/s 3663.12 4505.88
TTFT p50,ms 928.97 901.96
TPOT p50,ms 31.10 24.91

吞吐提升 23.01%,独立 bootstrap 95% 区间 [21.26%, 24.52%]。两臂各 1536 个正式请求,全部 1179648 个输出 token 的 logprob 有限,无 prompt-cache 命中,无 HW/SW 热降频。每 verify step 输出 token 数为 3.1833 / 3.1773。

这是同卡先基线、后候选的顺序独立运行,不是交替配对;区间不覆盖阶段间系统漂移。该提升仅对应本次主场景,不能外推至所有负载。扩展图会改变实际显存占用,相同容量不表示显存逐字节相同。此前原 PR 的 GLM TP8 实际服务实验收益接近噪声范围,不据此声明普遍加速。

精度与验证

Replay 与 native BF16 的舍入边界不同;parallel 投影和 derived fold 进一步改变求值顺序,不能保证生成 token 逐项一致。此前全量 GSM8K 1319 题,正常入口候选 1278/1319、历史原 PR 1279/1319(截断 8/6),准确率差 −0.0758 个百分点,配对 bootstrap 95% 区间 [−0.3791,+0.2274] 个百分点;不构成严格无损证明。本次清理后仅重测吞吐,未重跑 GSM8K。

  • 清理后 H200 回归覆盖 676 项:首轮 652 通过,24 个组合因旧测试桩缺少 logits_row_stride 失败;补齐后 autotune/采样 74 项复测全部通过,无遗留失败。计数有复测重叠,不相加。
  • 覆盖 GDN/KDA、普通及 MTP 状态生命周期、checkpoint、CUDA Graph、verify width 2/3/5/8/16、derived fold、padding、MTP 输出裁剪及采样边界(NaN、并列最大值、全屏蔽词表分块、非默认惩罚和随机采样)。
  • 原 PR 已有 H100 的生命周期/PD/配置隔离验证;本次新增 H100 ViT FA3 数值对照,FP16/BF16 的两个直接入口和统一入口共 6 项通过。未重跑完整 H100 生命周期测试。
  • 原吞吐快照的 24 个 Python 文件已通过检查;新增 FA3 兼容修复的 3 个文件也通过语法检查、仓库 flake8 规则及 git diff --check。

@sufubao sufubao changed the title Add ReplaySSM support for linear attention Add ReplaySSM state modes for GDN Oct 6, 2026
@sufubao sufubao changed the title Add ReplaySSM state modes for GDN Add ReplaySSM state modes for GDN and KDA Oct 6, 2026
@sufubao
sufubao marked this pull request as ready for review October 13, 2026 05:45
@sufubao
sufubao requested review from hiworldwzj and shihaobai and removed request for shihaobai October 13, 2026 05:45
@sufubao sufubao changed the title Add ReplaySSM state modes for GDN and KDA feat: add ReplaySSM state modes and optimize GDN MTP decoding Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant