Skip to content

[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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open

Conversation

CUHKSZzxy
Copy link
Collaborator

@CUHKSZzxy CUHKSZzxy commented May 9, 2025

Objective

Align with vLLM v1 metrics system and beyond. Here are several key alignments

  • Monotonic Timestamps:
    -- Uses time.perf_counter() for interval calculations (avoids clock drift issues).
  • Metric Types:
    -- 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
  • Metrics Publishing:
    -- CLI logging
    -- Prometheus

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

  • Use time.perf_counter()
  • Refactor to minimize the overhead of async engine generate() or engine _async_loop_main()
  • Expert information collections (maybe deferred in another PR)
  • Grafana visualization (WIP, maybe deferred in another PR)

Usage

Start the server with --enable-metrics

lmdeploy serve api_server models--Qwen--Qwen2.5-7B-Instruct --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_cli_log_update

  • Metrics Publishing - Prometheus & Grafana (WIP)
    Access metrics via http://localhost:23333/metrics/ , or curl the metrics endpoint as follows:

curl http:///localhost:23333/metrics/

Performance Impacts

Conclusion:

  • No obvious throughput degradation for Qwen-2.5-32B, minor degradation (1~2%) for Qwen-2.5-7B, and notable degradation (15% ~ 20%) for small models like Qwen-2.5-0.5B.

For details, you may check the following figures. Benchmark settings: 1000 prompts, input len 1000, output len 1000.

  • Qwen-2.5-7B (TP1), without the metrics.
    qwen2 5-7b_without_metrics

  • Qwen-2.5-7B (TP1), with the metrics.
    qwen2 5-7b_with_metrics

  • Qwen-2.5-0.5B (TP1), without the metrics.
    qwen2 5-0 5b_without_metrics

  • Qwen-2.5-0.5B (TP1), with the metrics.
    qwen2 5-0 5b_with_metrics

Related Issues & PR

Issue 2638, Issue 2673, PR1423

CUHKSZzxy added 2 commits May 9, 2025 20:38
Conflicts:
	lmdeploy/messages.py
	lmdeploy/pytorch/engine/engine.py
	lmdeploy/pytorch/engine/engine_instance.py
	lmdeploy/pytorch/messages.py
	lmdeploy/pytorch/paging/scheduler.py
@CUHKSZzxy CUHKSZzxy added the WIP label May 9, 2025
@CUHKSZzxy CUHKSZzxy removed the WIP label May 26, 2025
@CUHKSZzxy CUHKSZzxy marked this pull request as ready for review May 26, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant