Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions python/sglang/srt/managers/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,11 @@ def clear_hicache_storage_wrapped(self, recv_req: ClearHiCacheReqInput):
return ClearHiCacheReqOutput(success=if_success)

def is_fully_idle(self, for_health_check=False) -> bool:
# Health check piggybacks on running requests in process_output.
# Only running_batch + waiting_queue guarantee active GPU processing;
# disagg queues (bootstrap/prealloc/transfer) may have items without
# any request actually running on GPU — e.g. stuck handshake, full
# KV cache, or stalled transfer — so they can't carry health info.
# Batch running status
idle = (
self.running_batch.is_empty()
Expand All @@ -2667,20 +2672,18 @@ def is_fully_idle(self, for_health_check=False) -> bool:

# Waiting queues: waiting + bootstrapping + preallocation + kv transfer (decode)
idle &= len(self.waiting_queue) == 0
if self.disaggregation_mode == DisaggregationMode.PREFILL:
idle &= len(self.disagg_prefill_bootstrap_queue.queue) == 0
if self.disaggregation_mode == DisaggregationMode.DECODE:
idle &= (
len(self.disagg_decode_prealloc_queue.queue) == 0
and len(self.disagg_decode_transfer_queue.queue) == 0
)

if not for_health_check:
# Grammar queue and prefill inflight queue may not produce batch results
# instantly, but they still indicate the server is not fully idle.
idle &= len(self.grammar_manager.grammar_queue) == 0
if self.disaggregation_mode == DisaggregationMode.PREFILL:
idle &= len(self.disagg_prefill_inflight_queue) == 0
idle &= len(self.disagg_prefill_bootstrap_queue.queue) == 0

if self.disaggregation_mode == DisaggregationMode.DECODE:
idle &= len(self.disagg_decode_prealloc_queue.queue) == 0
idle &= len(self.disagg_decode_transfer_queue.queue) == 0

return idle

Expand Down
Loading