Skip to content

Fix vec-inf metrics for the metric names current vLLM exports - #335

Open
sunilmehta-si wants to merge 1 commit into
VectorInstitute:mainfrom
sunilmehta-si:fix-metrics-vllm-v1-names
Open

sunilmehta-si wants to merge 1 commit into
VectorInstitute:mainfrom
sunilmehta-si:fix-metrics-vllm-v1-names

Conversation

@sunilmehta-si

Copy link
Copy Markdown

PR Type

Fix

Short Description

vec-inf metrics reads metric names that current vLLM no longer exports, so on the vLLM this project installs (vllm>=0.11.2, 0.22.0 in uv.lock) some rows are wrong or missing:

Row Name it read Current vLLM Before this PR
GPU Cache Usage vllm:gpu_cache_usage_perc (hidden by default in 0.11, removed in 0.12) vllm:kv_cache_usage_perc always 0.0%, even with a full cache
GPU Prefix Cache Hit Rate vllm:gpu_prefix_cache_hit_rate (V0 engine only) vllm:prefix_cache_hits_total / vllm:prefix_cache_queries_total never shown
Requests Swapped, CPU Cache Usage, CPU Prefix Cache Hit Rate V0 engine only, no V1 equivalent not exported always 0

Changes:

  • KEY_METRICS maps vllm:kv_cache_usage_perc to gpu_cache_usage. The old name is kept, so older servers still work.
  • _parse_metrics computes gpu_prefix_cache_hit_rate from the two prefix cache counters when the gauge is absent and there has been at least one lookup.
  • The Requests Swapped, CPU Cache Usage and CPU Prefix Cache Hit Rate rows only appear when the server exports those metrics.
  • _parse_metrics used to add the prefix cache names to the module-level KEY_METRICS dict (key_metrics = KEY_METRICS); it now works on a copy.
  • docs/user_guide.md: the sample output drops the two always-zero rows.

Names checked against vllm/v1/metrics/loggers.py at v0.11.0, v0.12.0 and v0.22.0.

Tests Added

  • test_parse_metrics_current_vllm_names: vLLM 0.22-style lines give the KV cache usage and a 25% hit rate, with no swapped or CPU cache values.
  • test_parse_metrics_no_prefix_hit_rate_before_lookups: no hit rate while the query counter is 0.
  • test_parse_metrics_does_not_change_key_metrics: KEY_METRICS is unchanged after parsing with prefix caching enabled.
  • test_format_metrics_v1_engine: the table shows 75.0% / 25.0% and leaves out the three V0 rows. test_format_metrics_with_prefix_caching now also checks that the V0 rows still show when the metrics are present.

Three of the new tests fail on main. pytest -m "not integration_test" tests: 238 passed. ruff check and ruff format --check (0.17.1, as in .pre-commit-config.yaml) and mypy vec_inf pass. Not run against a live server on a Slurm cluster.

`vec-inf metrics` read vllm:gpu_cache_usage_perc for GPU cache usage.
vLLM renamed it vllm:kv_cache_usage_perc in 0.10, hid the old name in
0.11 and removed it in 0.12, so with vllm>=0.11.2 the row always showed
0.0%, even with a full cache. The old name is kept for older servers.

The GPU prefix cache hit rate came from vllm:gpu_prefix_cache_hit_rate,
which only the V0 engine exported, so the row never appeared. It is now
computed from vllm:prefix_cache_hits_total / vllm:prefix_cache_queries_total
when the gauge is absent and there has been at least one lookup.

Requests Swapped, CPU Cache Usage and CPU Prefix Cache Hit Rate are V0
metrics with no V1 equivalent; their rows now only appear when the
server exports them instead of always showing 0.

_parse_metrics also added the prefix cache names to the module-level
KEY_METRICS dict; it now works on a copy.

This branch has not been deployed

No deployments
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