Repository navigation
[Frontend][Metrics] Unregister only PrometheusStatLogger-owned collectors - #10
Ronald1995 wants to merge 1 commit into
Conversation
`PrometheusStatLogger.__init__` called `unregister_vllm_metrics()`, which removed *every* `vllm:*` collector from the default registry. That also wiped frontend-owned metrics, whose lifetime does not depend on the engine: the RL weight-operation metrics, the parser metrics and the WebSocket connection metrics all live in `REGISTRY` for the whole process. Track ownership per collector object instead, and release only what the previous logger registered. `PrometheusStatLoggerRegistry` is the registration hook that records ownership; `unregister_prometheus_stat_logger_metrics()` is still called before a new logger is constructed, because metric names are fixed and the previous instance has to release them first. Connector, speculative-decoding and perf metric factories already receive their metric classes from the logger, so they now inherit that ownership. Their signatures gain an optional injection point (`metric_types` / `counter_cls`) and keep the existing class-attribute defaults for direct use. `unregister_vllm_metrics()` stays for test and global cleanup, and the `RayPrometheusStatLogger._unregister_vllm_metrics` no-op hook, dead since the call site was removed, is dropped. Tests: tests/v1/metrics/test_prometheus_logger_ownership.py covers an independently owned metric surviving a logger rebuild, late `cache_config_info` registration, engine-index expansion and the real EC connector factory path. Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
Test evidence (H20 cluster)Environment: cd ~/pr55781/wt-weight
~/pr55781/.venv/bin/python -m pytest -q \
tests/entrypoints/unit_tests/test_rl_weight_operation_metrics.py \
tests/entrypoints/unit_tests/test_rl_weight_operation_routes.py \
tests/v1/metrics/test_prometheus_logger_ownership.py
Regression measurement for the bug this PR fixesSo the impact is specific to single-process deployments, which is the default. Rust sideThis PR does not touch Rust. As a side check on the same cluster, Not covered by this run
Logs: |
Heads-up: the base branch was reverted
This PR's diff is unchanged and still correct: 2 files / +12 / -14 It remains based on One thing worth flagging for review: this PR is the smaller half of the ownership fix. The rest of the ownership plumbing ( Where you want that split is your call. Two options:
If you prefer option 1 or 2, say which and I will push it — I did not want to expand this PR's scope without asking, since vllm-project#55781 was just narrowed on purpose. |
5f9d442 to
bc7991b
Compare
Why
PrometheusStatLogger.__init__callsunregister_vllm_metrics(), which removes everyvllm:*collector from the default registry. That also deletes frontend-owned metrics whose lifetime has nothing to do with the engine:vllm/parser/metrics.py),vllm/entrypoints/speech_to_text/realtime/metrics.py),prometheus-fastapi-instrumentator.When a logger is rebuilt (e.g. Elastic EP), those collectors are unregistered from
REGISTRY, so their series stop being exported from/metricsfor the rest of the process lifetime. Measured on this branch:What
Track ownership per collector object instead of by metric name, and release only what the previous logger registered:
PrometheusStatLoggerRegistryis the registration hook that records ownership.unregister_prometheus_stat_logger_metrics()unregisters just those collectors. It is still called before a new logger is constructed, because the logger's metric names are fixed and the previous instance must release them first.metric_types/counter_cls) and keep the existing class-attribute defaults for direct use.unregister_vllm_metrics()remains available for test and global cleanup.RayPrometheusStatLogger._unregister_vllm_metricswas a no-op hook that lost its only caller when the call site was removed, and is dropped.How this is different from vllm-project#55781
vllm-project#55781 both adds the weight-operation metrics and fixes this ownership problem, which mixes an RL feature with a logger-lifetime bugfix. This PR extracts only the bugfix so it can be reviewed on its own. It contains no RL/metrics-feature changes, and vllm-project#55781 rebases cleanly on top of it (the two changes touch disjoint files).
Test commands and results
Executed on the H20 cluster (
vllm-h20-head-> Slurmh20->vllm-h20-02, H20-3e), Python 3.12.14 venv with torch 2.14.0+cpu and the repo'srequirements/common.txtinstalled, against the realvllmimport chain (no stubs):That run covers this PR together with the two RL metric test files (13 tests total).
tests/v1/metrics/test_prometheus_logger_ownership.pyitself asserts:vllm:*metric survives a logger rebuild and keeps its accumulated value,cache_config_inforegistration is owned too,Rust is unaffected by this PR. As a side check,
cargo test -p vllm-metricswas run on the same cluster:AI assistance
This change was prepared with AI assistance (code analysis, patch drafting, and test execution). The submitting human has reviewed every changed line and ran the tests reported above.