-
Notifications
You must be signed in to change notification settings - Fork 551
[Feature] metrics support #3534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Conflicts: lmdeploy/messages.py lmdeploy/pytorch/engine/engine.py lmdeploy/pytorch/engine/engine_instance.py lmdeploy/pytorch/messages.py lmdeploy/pytorch/paging/scheduler.py
Conflicts: lmdeploy/serve/openai/api_server.py
lmdeploy/serve/async_engine.py
Outdated
@@ -302,6 +303,21 @@ def __init__(self, | |||
self.internal_thread = _EventLoopThread(daemon=True) | |||
self.limiter: asyncio.Semaphore = None | |||
|
|||
# build status loggers | |||
# independent set for each DP rank, since monototic time differs for each process | |||
# each set contains one cli logger and one prometheus logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be cleaner to move the new code into a separate function
# actual running requests | ||
num_running_reqs = self.scheduler.num_locked() | ||
# waiting to be scheduled or have been scheduled but not yet started execution | ||
num_waiting_reqs = self.scheduler.num_waiting() + self.scheduler.num_running() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does self.sched
8000
uler.num_running()
refer to scheduled but not yet started
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, discussed and confirmed with yaoq.
@@ -997,6 +1062,16 @@ def __send_resps(step_outputs: List[InferOutput]): | |||
await self._await_forward_event(forward_event) | |||
__send_resps(resps) | |||
|
|||
async def _async_log_stats_task(self, log_que: asyncio.Queue): | |||
|
|||
while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this task be terminated normally?
@@ -1149,14 +1227,19 @@ async def async_loop(self): | |||
forward_event, has_runable_event 9E81 ), | |||
name='MainLoopPreprocessMessage') | |||
|
|||
# log task | |||
logger.info('Starting async task MainLoopLogStats.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not create this task if metrics is disabled.
May merge the main branch to resolve lint errors |
Objective
Align with vLLM v1 metrics system and beyond. Here are several key alignments
-- Uses
time.perf_counter()
for interval calculations (avoids clock drift issues).-- Gauges: Active requests, cache usage, etc
-- Counters: Token totals, request success / failure counts, etc
-- Histograms: TTFT (Time-To-First-Token), TPOT (Inter-Token Latency), end-to-end latency, etc
-- CLI logging
-- Prometheus & Grafana
We only record critical timestamps and events during the main loop and scheduling without further processing. Heavy-weight metrics calculations or metrics publishing are put inside separate coroutines to reduce the main engine loop overhead.
TODO
time.perf_counter()
generate()
or engine_async_loop_main()
Expert information collections (deferred in another PR)Usage
Start the server with
--enable-metrics
Metrics Publishing - Logging

With
--enable-metrics
, key metrics (e.g., running / waiting requests, cache usage, token throughput) are printed to the terminal every 5 seconds.Metrics Publishing - Prometheus & Grafana



-- Raw Metrics
Access the raw Prometheus metrics via http://localhost:23333/metrics/ .
You can also curl the metrics endpoint
curl http:///localhost:23333/metrics/
to view raw Prometheus results.-- Prometheus Panel (WIP, user guide to be added)
Access the Prometheus panel via http://localhost:9090 (
9090
is the current default port for Prometheus panel)-- Grafana Panel (WIP, user guide to be added)
Access the Grafana panel via http://localhost:3000 (
3000
is the current default port for the Grafana panel)Performance Impacts
Conclusion:
You may check the following figures for details. Benchmark settings: 1000 prompts, input len 1000, output len 1000.
Qwen-2.5-7B (TP1), without the metrics.

Qwen-2.5-7B (TP1), with the metrics.

Qwen-2.5-0.5B (TP1), without the metrics.

Qwen-2.5-0.5B (TP1), with the metrics.

Related Issues & PR
Issue 2638, Issue 2673, PR1423