Prhub

#32110 [Spec] Enable grammar overlap scheduling for STANDALONE speculative decoding

原始 PR 作者 hnyls2002 合并时间 2026-07-23 16:47 文件变更 2 提交数 3 评论 3 代码增减 +9 / -3

执行摘要

为 STANDALONE 推理添加语法重叠调度

PR body 说明:"Enable the spec-v2 grammar barrier for STANDALONE (StandaloneWorkerV2 inherits the EAGLE V2 verify path where the barrier is threaded). Constrained-decoding coverage reuses the existing standalone triton server (overlap on), so grammar decode exercises the barrier path with no extra server launch." 即由于 StandaloneWorkerV2 已继承 EAGLE V2 的 verify 路径,该路径已包含 grammar barrier,因此只需在调度策略层面开启支持,并补充测试覆盖。

PR 改动简单,值得快速合入。测试覆盖充分,逻辑清晰。建议阅读 spec_info.pysupports_grammar_overlap 的设计方式,了解 SGLang 如何通过枚举方法控制解码行为。

讨论亮点

该 PR 没有 review 评论讨论。仅有一条 author 触发的 /rerun-test 命令和 bot 的结果报告,测试通过。

实现拆解

  1. 启用 grammar overlap 标志:在 python/sglang/srt/speculative/spec_info.pySupportsGrammarOverlap 方法中,将 return self.is_eagle() 改为 return self.is_eagle() or self.is_standalone(),并添加注释说明 STANDALONE 继承 EAGLE V2 worker verify 路径,barrier 已包含。

  2. 补充约束解码测试:在 test/registered/spec/test_spec_standalone.pyTestStandaloneV2SpeculativeDecodingTriton 类中,混入 RegexConstrainedMixinJSONConstrainedMixin,并更新注释说明约束 Mixin 复用同一服务器且 overlap 开启,从而验证 grammar barrier 路径。同时将注册的预估时间从 406 调整为 450,反映新增测试用例的开销。

文件 模块 状态 重要度
python/sglang/srt/speculative/spec_info.py 推理调度 modified 4.82
test/registered/spec/test_spec_standalone.py 测试 modified 4.64

关键符号

SpeculativeAlgorithm.supports_grammar_overlap

分析完成后,这里会展示 LLM 生成的相对完整源码片段和详细注释。

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

风险极低。变更仅涉及两处,且核心逻辑只是新增一个条件分支。测试已覆盖 triton 后端的约束解码场景。但需注意:若未来 STANDALONE 的 verify 路径与 EAGLE 产生偏离,则此处的假设可能失效。

影响范围:仅影响使用 STANDALONE 算法且开启 grammar overlap 的推理场景,默认行为不变。影响程度:较小,但提升了功能性——用户现在可以在 STANDALONE speculative decoding 中同时使用约束解码(如 JSON 或正则约束),而无需额外配置。

假设依赖(STANDALONE 继承 EAGLE verify 路径)

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论