fix(metrics): clear forward occupancy on idle (#33562)
Co-authored-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
This commit is contained in:
co-authored by
Jialin Ouyang
parent
dea2be5ae3
commit
5081c063c0
@@ -3904,9 +3904,6 @@ class Scheduler(
|
||||
# reset token ratio
|
||||
self.new_token_ratio_tracker.reset()
|
||||
|
||||
# reset device timer window so idle time isn't counted
|
||||
self.metrics_reporter.reset_device_timer_window()
|
||||
|
||||
# Publish the idle state so /get_loads and DP balancing do not see stale load.
|
||||
self.publish_load_snapshot(force=True)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import logging
|
||||
import math
|
||||
import tempfile
|
||||
import time
|
||||
from collections import defaultdict
|
||||
@@ -1080,7 +1081,7 @@ class SchedulerMetricsReporter:
|
||||
# the gauge. Readers sample it asynchronously, and the window
|
||||
# boundary can phase-lock with the decode-log cadence, turning a
|
||||
# one-tick NaN into NaN on every log line. NaN is published only
|
||||
# when truly stale (reset_device_timer_window after idle).
|
||||
# when truly stale (_reset_device_timer_window after idle).
|
||||
self._device_timer_window_start = now
|
||||
self._device_timer_window_gpu_time = 0.0
|
||||
else:
|
||||
@@ -1093,13 +1094,20 @@ class SchedulerMetricsReporter:
|
||||
if self._device_timer_window_batch_count >= self.decode_log_interval:
|
||||
self._device_timer_window_batch_count = 0
|
||||
|
||||
def reset_device_timer_window(self):
|
||||
def _reset_device_timer_window(self):
|
||||
"""Exclude idle time and invalidate the last forward-occupancy sample."""
|
||||
if ENABLE_METRICS_DEVICE_TIMER:
|
||||
self._device_timer_window_batch_count = 0
|
||||
self.fwd_occupancy = float("nan")
|
||||
self.stats.fwd_occupancy = float("nan")
|
||||
|
||||
def _maybe_log_idle_metrics(self):
|
||||
"""Collect and log metrics every 30 seconds during idle."""
|
||||
"""Reset forward timing and publish idle metrics when needed."""
|
||||
# Preserve the transition so the rate limit cannot leave a finite idle gauge.
|
||||
is_fwd_occupancy_stale = ENABLE_METRICS_DEVICE_TIMER and not math.isnan(
|
||||
self.stats.fwd_occupancy
|
||||
)
|
||||
self._reset_device_timer_window()
|
||||
if not self.current_scheduler_metrics_enabled:
|
||||
return
|
||||
# The running-reqs gauge holds the last batch report until the next
|
||||
@@ -1111,6 +1119,7 @@ class SchedulerMetricsReporter:
|
||||
)
|
||||
if (
|
||||
not gauge_stale
|
||||
and not is_fwd_occupancy_stale
|
||||
and time.perf_counter() <= self.metrics_collector.last_log_time + 30
|
||||
):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user