Prhub

#23886 [PD+Pause] Remove redundant post processing

原始 PR 作者 ByronHsu 合并时间 2026-04-28 08:01 文件变更 1 提交数 1 评论 1 代码增减 +0 / -2

执行摘要

移除 PD Pause 中冗余的 inflight 处理调用

PR body 指出,在 disaggregation prefill 模式下,当调度器暂停时调用的 process_disagg_prefill_inflight_queue() 仅轮询传输状态而不执行刷新操作,因此是无用的。同时 main 分支(#20908)和 sglang-miles 分支(#23672)对该逻辑的处理存在分歧,本 PR 旨在合并两分支逻辑并移除冗余调用。

该 PR 改动简单、风险低,可直接合并。对于从事 disaggregation prefill 或调度器开发的团队成员有一定参考意义,可了解 process_disagg_prefill_inflight_queue 的当前语义和调用场景。

讨论亮点

该 PR 没有 review 评论或讨论记录。

实现拆解

python/sglang/srt/disaggregation/prefill.py 文件的 event_loop_normal_disagg_prefillevent_loop_overlap_disagg_prefill 两个方法中,分别删除了 if self._engine_paused: 分支内的 self.process_disagg_prefill_inflight_queue() 调用。该调用位于暂停后继续循环之前,移除后仅保留 continue 语句直接进入下一轮循环。其余逻辑不变。

文件 模块 状态 重要度
python/sglang/srt/disaggregation/prefill.py 调度器 modified 4.32

关键符号

event_loop_normal_disagg_prefill event_loop_overlap_disagg_prefill

关键源码片段

python/sglang/srt/disaggregation/prefill.py core-logic

唯一变更文件,在 disagg prefill 调度器的正常模式和重叠模式的事件循环中,各删除一次对 process_disagg_prefill_inflight_queue 的调用。

# python/sglang/srt/disaggregation/prefill.py ( 部分方法 )@torch.no_grad()
def event_loop_normal_disagg_prefill(self: Scheduler) -> None:
    """A normal scheduler loop for prefill worker in disaggregation mode."""
    self.enable_staging = envs.SGLANG_DISAGG_STAGING_BUFFER.get()
​
    while True:
        recv_reqs = self.recv_requests()
        self.process_input_requests(recv_reqs)
        self.waiting_queue.extend(
            self.disagg_prefill_bootstrap_queue.pop_bootstrapped()
        )
        if self._engine_paused:
            # Before: self.process_disagg_prefill_inflight_queue() was called here
            # but it only polls transfer status, not flush; removed as redundant.
            continue
​
        batch = self.get_next_disagg_prefill_batch_to_run()
        self.cur_batch = batch
        ...
        self.process_disagg_prefill_inflight_queue()
        self.last_batch = batch@torch.no_grad()
def event_loop_overlap_disagg_prefill(self: Scheduler) -> None:
    self.result_queue = deque()
    self.enable_staging = envs.SGLANG_DISAGG_STAGING_BUFFER.get()
    while True:
        recv_reqs = self.recv_requests()
        self.process_input_requests(recv_reqs)
        self.waiting_queue.extend(
            self.disagg_prefill_bootstrap_queue.pop_bootstrapped()
        )
        if self._engine_paused:
            # Same removal as above
            continue
        ...
        self.process_disagg_prefill_inflight_queue()
        self.last_batch = batch

评论区精华

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

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

风险与影响

移除的调用是 process_disagg_prefill_inflight_queue(),其语义被描述为“轮询传输状态而非刷新”,在 paused 状态下调用可能浪费 CPU 但不会影响正确性。移除后可减少不必要的操作,但由于测试覆盖不足(无相关测试变更),存在因其他未预料依赖引入回归的极低风险。

影响范围极小,仅涉及两个 disagg prefill 事件循环中引擎暂停时的路径。对正常执行路径无影响。用户无感知,系统行为无变化。

低风险

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论