Prhub

#27964 [Spec] Retire Spec V1

原始 PR 作者 hnyls2002 合并时间 2026-06-12 07:15 文件变更 46 提交数 5 评论 4 代码增减 +111 / -252

执行摘要

移除 SGLANG_ENABLE_SPEC_V2 环境变量

SGLANG_ENABLE_SPEC_V2 曾是用于选择 Spec V2 worker 的开关,但所有推测解码算法现已默认使用 V2,该标志的唯一剩余效果是作为 --disable-overlap-schedule 的别名,造成混淆。这是退役 Spec V1 的最后一步用户可见操作。

该 PR 是 Spec V1 退役的收尾工作,对于理解 SGLang 推测解码的演进和配置清理策略有参考价值。建议关注 speculative_hook.py 中弃用警告的添加方式,以及测试 fixture 中配置属性的重命名模式。

讨论亮点

PR 无实质技术讨论。作者手动 rerun 了 test_deepep_large.pytest_moriep_small.py,其中 deepep 测试通过,moriep 因未注册 CI 被跳过。

实现拆解

  1. 移除环境变量定义:在 python/sglang/srt/environ.py 中删除 SGLANG_ENABLE_SPEC_V2 的 Envs 条目。
  2. 核心运行时清理:在 python/sglang/srt/arg_groups/speculative_hook.pyhandle_speculative_decoding 函数中,删除所有依赖该标志设置 disable_overlap_schedule 的代码(_handle_dflash_handle_frozen_kv_mtp_handle_eagle_family 各有一份),改为由用户通过 --disable-overlap-schedule 直接控制;同时添加 os.getenv 弃用警告。
  3. DeepSeek V4 钩子清理:在 python/sglang/srt/arg_groups/deepseek_v4_hook.pyapply_deepseek_v4_defaults 中,移除强制启用 Spec V2 的逻辑(V2 已是默认)。
  4. 测试框架迁移:所有原通过 envs.SGLANG_ENABLE_SPEC_V2.override(...) 选择同步路径的测试(如 test_deepep_large.pytest_step3p5_flash_chain_mtp.pytest_eagle_constrained_decoding.pystandalone_fixture.pyspec_eagle_fixture.pytest_dflash.pytest_qwen35_fp4_mtp.py 等),改为直接传入 --disable-overlap-schedule 参数;对应的类属性从 enable_spec_v2 / spec_v2 重命名为 disable_overlap
  5. 文档更新:更新 docs_new/ 下的相关文档,将推荐设置改为 --disable-overlap-schedule,并删除 Ascend 页面中 75 行过时配置 export。
文件 模块 状态 重要度
python/sglang/srt/arg_groups/speculative_hook.py 推测配置 modified 6.79
python/sglang/srt/arg_groups/deepseek_v4_hook.py V4 配置 modified 5.7
python/sglang/srt/environ.py 环境变量 modified 4.75
test/registered/ep/test_deepep_large.py EP 测试 modified 5.56
test/registered/models_e2e/test_step3p5_flash_chain_mtp.py 链式 MTP modified 5.12
test/registered/spec/eagle/test_eagle_constrained_decoding.py Eagle 约束 modified 5.08

关键符号

handle_speculative_decoding apply_deepseek_v4_defaults _handle_dflash _handle_frozen_kv_mtp _handle_eagle_family

关键源码片段

python/sglang/srt/arg_groups/speculative_hook.py dependency-wiring

核心运行时变更:删除基于环境变量的 overlap 调度选择逻辑,添加弃用警告,并移除 import。

# file: python/sglang/srt/arg_groups/speculative_hook.py
# 在 _handle_dflash、_handle_frozen_kv_mtp、_handle_eagle_family 中
# 删除以下重复代码块(每个算法 handler 各有一份):
# if (
# not envs.SGLANG_ENABLE_SPEC_V2.get()
# and not server_args.disable_overlap_schedule
# ):
# server_args.disable_overlap_schedule = True
# 现在 disable_overlap_schedule 仅由用户通过 --disable-overlap-schedule 控制。# 新增的弃用警告(位于 handle_speculative_decoding 函数开头):
if os.getenv("SGLANG_ENABLE_SPEC_V2") is not None:
    logger.warning(
        "SGLANG_ENABLE_SPEC_V2 has been removed: speculative decoding "
        "always runs the V2 worker. Use --disable-overlap-schedule to "
        "select the non-overlap (synchronous) path."
    )

评论区精华

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

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

风险与影响

主要风险是用户升级后若设置 SGLANG_ENABLE_SPEC_V2=0,原先的同步路径不再自动生效,需改用 --disable-overlap-schedule。PR 已添加一次性日志告警以缓解迁移冲突。测试中的 disable_overlap 属性重命名可能影响外部 fork/自定义测试,但官方测试已全部适配。DeepSeek V4 钩子移除了 force-set,但 V2 已是默认,无功能变化。

用户影响:之前显式设置该环境变量的用户需移除设置,或改用 --disable-overlap-schedule系统影响:无性能或稳定性变化。团队影响:减少一个废弃配置点的维护负担。

废弃标志删除 用户脚本兼容性 默认行为变更 测试属性重命名

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论