Prhub

#31622 Revert "Fix mamba track-boundary seqlen under overlap scheduler (#31369)"

原始 PR 作者 alisonshao 合并时间 2026-07-18 08:03 文件变更 1 提交数 1 评论 6 代码增减 +9 / -17

执行摘要

回退错误修复,恢复 Qwen3-Next 确定性回归

PR #31369 变更了 mamba track boundary 的 seqlen 计算方式,导致 nightly 测试 test_qwen3_next_models.py::test_input_output_logprobs_match_decode_cache_hit_helper 确定性失败(avg_kl_div=0.006489 > 0.002)。二分法定位到该提交为唯一回归源。

建议合并,以恢复 nightly 测试通过性;但需追踪 #29792 以最终修复 mamba track-boundary 的 overlap scheduler 问题。

讨论亮点

无 review 讨论。

实现拆解

  1. 完全回退提交:执行 git revert 0675d3033f2abd955950c095addaf31eb0fe5811,精确撤销 #31369 的变更。
  2. 文件级别变更:仅修改 python/sglang/srt/managers/scheduler_components/batch_result_processor.py 中的 _mamba_check_track_boundary 方法,将其从 kv_committed_len 换回 len(origin_input_ids) + len(output_ids) - 1
  3. 无额外配套修改:不含测试、配置或部署改动;仅恢复基线代码。
文件 模块 状态 重要度
python/sglang/srt/managers/scheduler_components/batch_result_processor.py 调度器 modified 6.43

关键符号

_mamba_check_track_boundary

关键源码片段

python/sglang/srt/managers/scheduler_components/batch_result_processor.py core-logic

核心方法 _mamba_check_track_boundary 的 seqlen 计算逻辑从 kv_committed_len 回退到 len(origin_input_ids) + len(output_ids) - 1,消除了回归。

def _mamba_check_track_boundary(self, req, batch, result, i):
    """Check if this decode step crosses a mamba track interval boundary.    Returns (at_boundary, track_seqlen).  ``track_seqlen`` must equal the
    seq_len the forward's tracking mask used, so the tracked state and its
    recorded ``mamba_last_track_seqlen`` describe the same token position.
    That seq_len is a pure function of the tokens the request has produced:
    ``len(origin_input_ids) + len(output_ids) - 1`` (the just-decoded token
    is already appended to ``output_ids`` before this runs).    ``kv_committed_len`` must NOT be used here: under the overlap scheduler,
    ``prepare_for_decode`` for the *next* batch increments it before this
    result is processed, so it leads seq_len by a jittering lookahead
    (0 or 1 depending on prefill interleaving). Using it fires the boundary
    one decode step early on most steps, mislabeling the tracked mamba
    state; a later request that reuses/donates that tracked prefix then
    extends from a state a cold prefill recompute would not produce.    For spec decode, the boundary is detected by comparing the
    accepted seq_len range against interval boundaries.
    """
    interval = get_server_args().mamba_track_interval
​
    if batch.spec_algorithm.is_none():
        seq_len = len(req.origin_input_ids) + len(req.output_ids) - 1
        if seq_len % interval == 0:
            return True, seq_len
    elif result.num_correct_drafts_per_req_cpu is not None:
        cur = req.seqlen - 1
        prev = cur - result.num_correct_drafts_per_req_cpu[i] - 1
        if cur // interval != prev // interval:
            return True, cur // interval * interval
​
    return False, 0

评论区精华

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

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

风险与影响

低风险:回退操作完全恢复到 #31369 引入之前的已知正确行为。PR #31369 原本试图修复 overlap scheduler 下的边界问题,但引入回归;本回退恢复稳定性,但 overlap scheduler 边界问题仍待解决。

  1. 用户影响:Qwen3-Next 模型的 decode-cache-hit logprobs 恢复正常,KL 散度重新满足阈值。
  2. 系统影响:无性能影响。
  3. 团队影响:阻塞了 #31369 的修复,需等 #29792 重新实现正确方案。
回归修复

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论