Skip to content

Improve metrics log#4297

Open
CUHKSZzxy wants to merge 5 commits intoInternLM:mainfrom
CUHKSZzxy:improve-metrics-log
Open

Improve metrics log#4297
CUHKSZzxy wants to merge 5 commits intoInternLM:mainfrom
CUHKSZzxy:improve-metrics-log

Conversation

@CUHKSZzxy
Copy link
Collaborator

@CUHKSZzxy CUHKSZzxy commented Jan 27, 2026

Try to make the metrics log clearer. Now, it looks like:

[2026-02-05 17:05:17 DP0] Avg thr (in/out): 4618.5 / 2756.3 tokens/s, API server (completed/routed/waiting): 1 / 50 / 50, Engine (running/waiting): 45 / 5, KV cache: 21.6%, 

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the clarity of metrics logging by:

  1. Renaming metrics methods and fields for better clarity (increment→increase, finished→completed)
  2. Adding tracking for API-level request states (running/waiting at the API server level)
  3. Reorganizing the log output to clearly separate API server metrics from engine core metrics
  4. Making the prefix cache hit rate conditional in the output (only shown when non-zero)

Changes:

  • Renamed metrics methods from increment_* to increase_* and num_finished_reqs to num_completed_reqs
  • Added num_api_running_reqs and num_api_waiting_reqs tracking to distinguish API-level from engine-level request states
  • Improved log message format to show API server and Engine core metrics separately with clearer labels

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lmdeploy/serve/async_engine.py Updated to track API-level running requests in the model_inst context manager and use renamed metrics methods
lmdeploy/metrics/stats.py Added new fields for API-level request tracking and updated documentation to explain the metric relationships
lmdeploy/metrics/metrics_processor.py Renamed methods and added increase/decrease methods for API running requests tracking
lmdeploy/metrics/loggers.py Reorganized log output format, made prefix cache conditional, and updated Prometheus metric names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CUHKSZzxy CUHKSZzxy marked this pull request as ready for review January 28, 2026 03:57
num_total_reqs: API server, the number of all requests received since server start.
num_completed_reqs: API server, the number of successfully completed requests since server start.
num_api_running_reqs: API server, the number of requests being assigned to engine instances.
num_api_waiting_reqs: API server, the number of requests waiting for free engine instances.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_api_routed_reqs: API server, the number of requests routed to request handles.
num_api_waiting_reqs: API server, the number of requests waiting for free request handles.

num_total_reqs: int = 0
num_finished_reqs: int = 0
num_completed_reqs: int = 0
num_api_running_reqs: int = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_api_routed_reqs: int = 0

@lvhan028
Copy link
Collaborator

lvhan028 commented Feb 5, 2026

May merge latest main to resolve the conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants