[Metrics] Propagate idle gaps across all scheduler loops (#40004)

Co-authored-by: metamergebot <324680979+metamergebot@users.noreply.github.com>
Co-authored-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
This commit is contained in:
metamergebot
2026-09-18 22:42:00 -07:00
committed by GitHub
co-authored by metamergebot Jialin Ouyang
parent 8189e3896b
commit 677c1cbdc9
8 changed files with 420 additions and 11 deletions
@@ -2656,6 +2656,7 @@ class SchedulerDisaggregationDecodeMixin:
self.process_batch_result(batch, result)
else:
# When the server is idle, do self-check and re-init some states
self._sched_idled = True
self.on_idle()
# Update last_batch
@@ -2707,6 +2708,7 @@ class SchedulerDisaggregationDecodeMixin:
self.result_queue.append((batch.copy(), batch_result))
else:
batch_result = None
self._sched_idled = True
# Process the last batch
if self.last_batch:
@@ -659,6 +659,7 @@ class SchedulerDisaggregationPrefillMixin:
result = self.run_batch(batch)
self.process_batch_result(batch, result)
else:
self._sched_idled = True
self.on_idle()
self.process_disagg_prefill_inflight_queue()
@@ -700,6 +701,7 @@ class SchedulerDisaggregationPrefillMixin:
self.result_queue.append((batch.copy(), batch_result))
else:
batch_result = None
self._sched_idled = True
# Process the last batch
if self.last_batch:
@@ -98,6 +98,8 @@ class SchedulerMlxOverlapMixin:
self.forward_ct += 1
batch.forward_iter = self.forward_ct
batch.launch_ts = time.monotonic()
batch.after_idle_gap = self._sched_idled
self._sched_idled = False
self.profiler_manager._profile_batch_predicate(batch)
def _finalize_mlx_pending_job(self: Scheduler, pending: MlxPendingJob):
@@ -273,6 +275,7 @@ class SchedulerMlxOverlapMixin:
pending_curr = _launch_fresh(next_batch)
self.result_queue.append(pending_curr)
else:
self._sched_idled = True
self.on_idle()
self.last_batch = next_batch
@@ -184,6 +184,7 @@ class SchedulerPPMixin:
# When the server is idle, self-check and re-init some states
if server_is_idle:
self._sched_idled = True
self.on_idle()
@DynamicGradMode()
@@ -362,8 +363,10 @@ class SchedulerPPMixin:
self.running_batch.batch_is_full = False
# When the server is idle, self-check and re-init some states
if server_is_idle and len(self.disagg_prefill_inflight_queue) == 0:
self.on_idle()
if server_is_idle:
self._sched_idled = True
if len(self.disagg_prefill_inflight_queue) == 0:
self.on_idle()
@DynamicGradMode()
def event_loop_pp_disagg_decode(self: Scheduler):
@@ -552,8 +555,10 @@ class SchedulerPPMixin:
if get_disagg().disaggregation_decode_enable_offload_kvcache:
queue_size += len(self.decode_offload_manager.ongoing_offload)
if server_is_idle and queue_size == 0:
self.on_idle()
if server_is_idle:
self._sched_idled = True
if queue_size == 0:
self.on_idle()
def init_pp_loop_state(self: Scheduler):
self.pp_loop_size: int = self.ps.pp_size + get_parallel().pp_async_batch_depth
@@ -135,6 +135,7 @@ class SchedulerMultiplexMixin:
stream_idx > 0 and running_batch.is_empty()
)
if running_batch.is_empty() and self.split_prefill_batch is None:
self._sched_idled = True
self.on_idle()
if adjust_stream_group: