feat: add Qwen3.8 DFlash2 decoding support. - #2279
Draft
pjgao wants to merge 9 commits into
Draft
Conversation
Add DFlash2 checkpoint configuration, draft-model registration, and a dedicated worker for block proposal and path sampling. Implement dynamic grouped convolution, Top-K Markov candidate selection, context-KV transfer, and Qwen3.8 hybrid-target speculative verification while reusing the existing DFlash lifecycle. Preserve non-causal sliding-window attention semantics and add focused grouped-convolution tests.
ustcfy
reviewed
Aug 20, 2026
对齐官方 DFlash2 selector 的温度采样语义,避免在草稿候选分布上重复应用 target 侧 top-p、top-k 与惩罚。 为 FIA 增加非因果滑窗 band 参数,并要求 Qwen3.8 hybrid recurrent target 使用 ACL Graph,以保证投机校验后的 GDN 状态可无损回放;eager 路径改为启动时快速失败。 将主仓库内遗留的 LICENSE 链接统一更新到 xLLM-AI 组织地址。 验证:MAX_JOBS=16 python setup.py build 通过;DFlash2 grouped-conv 2/2 通过;greedy 205 token 与 target-only 完全一致。官方 GSM8K 128 请求口径接受长度为 5.408,接近模型卡 DFlash2 5.46,并高于模型卡 MTP 5.02。
修复 hybrid recurrent target 的线性状态元数据泄漏到 MTP draft prefill,恢复 Qwen3.8-27B MTP 的 ACL Graph warmup。\n\n修正 DFlash2 接受 token 的列语义,补充逐位置接受计数,并避免 N7 热路径上的标签与计数堆分配。
…t/qwen38-dflash2-npu
按主仓库 clang-format 规则调整接受计数表达式,修复 PR format-check。
恢复历史文件原有的 jd-opensource LICENSE 链接。 仅本次新增的 DFlash2 文件使用 xLLM-AI LICENSE 链接,避免无关的批量头部修改。
集中维护 DFlash2 算法名和 draft model type,统一替换 runtime、model 和 layer 中分散的判断点。 保留 MTP hybrid metadata 清理,并补充共享正确性说明,避免将其误认为仅用于性能对比的临时改动。
补齐 DFlash2 draft 各层 attention、MLP、norm 与卷积权重校验,缺失融合权重时报告具体 checkpoint 名称。 将显式滑窗 mask 对齐 FIA band 的逐 query 语义,并补充卷积行布局校验和 NPU-only 平台提示。
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.
说明
本 PR 为 xLLM 增加 Qwen3.8-27B 的 DFlash2 投机解码首版功能支持,并对齐 zLab 官方实现与模型卡的解码合同:
当前定位仍是功能支持、正确性与可观测性闭环。本轮补齐了 PR HEAD 上的典型长度、最优 MTP 多步和 P1/P8 性能矩阵;没有为追求数据引入额外 kernel 或大范围代码改动。
主要改动
DFlash2算法并解析 checkpoint 中的dflash_config。top_p、top_k、惩罚与 grammar 只在 target verify 侧生效。/vars接受统计列语义,增加 N 个 draft position 的接受计数;位置标签预生成,N7 使用 inline small vector,避免 decode 热路径堆分配。https://github.com/xLLM-AI/xllm/blob/main/LICENSE;不改动仓库既有历史 LICENSE 链接。官方模型卡复现与接受机制
官方 GSM8K 合同:128 prompts、concurrency=1、block size=8(7 drafts)、temperature=1、top_p=0.95、top_k=20、reasoning=xhigh、max_new_tokens=4096。
[5.252, 5.479],覆盖官方值。64cfd06e的精确二进制;后续 DFlash2 直接改动仅修正接受 telemetry,最终性能矩阵另用 PR HEAD 精确二进制,不把两者伪装成同一 binary。修正统计后,使用官方合同前 16 条做同机、同 TP、同 N7 机制对照:
16 条属于
SMOKE_ONLY,用于验证机制与统计语义,不作为 SLA。多步接受率
固定 N7 下以 proposal sequence 数为共同分母:
第 1 步基本持平;DFlash2 从第 2 步开始反超,第 4–7 步保持约 6.3–6.6 pp 优势,符合 DFlash2 的多步接受特征。
PR HEAD 典型场景性能
测试合同
935285a12a00b1a888173f1e2d67c617fcb99fe2;当前功能与检视修复 HEAD:a0c2641d8cc6b29650ece1e04e13528c4d43752e。2ac0b23678714b3f271ecc17dacb6f9002b2e9615531eefa4ed9c2ddee8c24ad。P1 低时延
主指标采用 E2E/TPOT;TTFT 单独报告。
TTFT 不隐藏:2K DFlash2 更好;4K 慢 4.90%;8K 慢 0.09%。三个场景的 decode TPOT、E2E 和 output TPS 均优于最优 MTP。
P8 高吞吐
P8 重复轮采用更保守的“DFlash2 最差轮 / MTP 最好轮”后,2K/4K/8K 仍分别领先 9.17% / 4.44% / 1.32%。这些结果用于工程门槛,不外推为生产 SLA。
EvalScope 与
/vars双口径以下是 P1 正式点;
/vars平均接受 draft 是跨不同深度比较的主要接受长度口径。/vars接受率/vars平均接受 draft/varstoken 接受率受 N3/N7 分母影响,不能脱离深度直接判断优劣;平均接受 draft 和 decoded/iter 更适合比较实际每轮产出。长度、数据集与适配归因
/vars3.5011→3.5505,未随长度下降当前证据支持:效果好坏主要由数据集与 workload 合同决定,未发现 DFlash2 在 xLLM 中随 2K/4K/8K 增长而系统性退化。若同一完整数据集、相同采样和固定 N7 下,逐位置接受率随长度单调大幅下降,才应优先检查 context KV、位置编码、sliding-window 或 recurrent state 适配。
构建与正确性边界
MAX_JOBS=16 python setup.py build:性能矩阵基线935285a12通过;检视修复未重新构建正式矩阵二进制。/vars、逐位置统计、启动命令和清理证据。INCONCLUSIVE,不伪装成 PASS,也不进入性能数据。git diff --check、Python 语法检查、7 个受影响 C++ 翻译单元-fsyntax-only:通过;未触发全量重建或 NPU workload。INCONCLUSIVE:xllm_ops是 HCCL struct 名称兼容性重命名,早于构建且不经过本次 Qwen3.8 dense DFlash2/MTP 路径。矩阵结论限定为同一精确二进制的公平 A/B,不冒充 clean-checkout PR gate。python_executor_test失败;最新 HEAD 已触发新一轮 CI,本描述不提前标记全量门禁通过。后续性能能力
典型 Multi-GSM8K 目标已超过最优 MTP,但高并发/更多数据集/更长上下文和更大裕量仍需要后续能力:
[batch, draft_steps, vocab]dense proposal probability 改为 sparse candidate/rejection-sampling 接口。当前 profile 不足以为每项单独承诺收益,因此不写未经验证的百分比目标。后续重点是扩大 8K P8 的保守裕量,并补齐 16K/32K、真实长文本/代码数据集、DP/CP、高并发与容量矩阵。
当前结论