From 3e8abc71ca50c7e3e155ffafe7b5eeac30a28b8f Mon Sep 17 00:00:00 2001 From: ybyang <10629930+whybeyoung@users.noreply.github.com> Date: Tue, 10 Mar 2026 03:58:10 +0800 Subject: [PATCH] [Disagg] Skip health check enqueue when PD disagg queues have backlog (#20191) --- python/sglang/srt/managers/scheduler.py | 36 +++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.py index c6300c454..d78a08f4f 100644 --- a/python/sglang/srt/managers/scheduler.py +++ b/python/sglang/srt/managers/scheduler.py @@ -1490,14 +1490,34 @@ class Scheduler( self.session_controller.maybe_reap(now) for recv_req in recv_reqs: # If it is a health check generation request and there are running requests, ignore it. - if is_health_check_generate_req(recv_req) and ( - self.chunked_req is not None - or self.dllm_manager.any_staging_reqs() - or not self.running_batch.is_empty() - or len(self.offload_tags) > 0 - ): - self.return_health_check_ct += 1 - continue + if is_health_check_generate_req(recv_req): + # Check if there are requests being processed + has_running_requests = ( + self.chunked_req is not None + or self.dllm_manager.any_staging_reqs() + or not self.running_batch.is_empty() + or len(self.offload_tags) > 0 + ) + + # In PD disaggregation mode, also check if health check would be blocked + # in special queues (bootstrap/prealloc) due to external factors + will_block_in_pd_queue = False + if self.disaggregation_mode == DisaggregationMode.PREFILL: + # If bootstrap queue has backlog, health check will also be blocked there + will_block_in_pd_queue = ( + len(self.disagg_prefill_bootstrap_queue.queue) > 0 + or len(self.disagg_prefill_inflight_queue) > 0 + ) + elif self.disaggregation_mode == DisaggregationMode.DECODE: + # If prealloc/transfer queue has backlog, health check will also be blocked there + will_block_in_pd_queue = ( + len(self.disagg_decode_prealloc_queue.queue) > 0 + or len(self.disagg_decode_transfer_queue.queue) > 0 + ) + + if has_running_requests or will_block_in_pd_queue: + self.return_health_check_ct += 1 + continue output = self._request_dispatcher(recv_req) if output is not None: