@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 2cb8c1540e
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 22:15 UTC

[Metrics] Add `--show-hidden-metrics-for-version` CLI arg (#13295)

Mark McLoughlin committed Feb 22, 2025 at 08:20 UTC 2cb8c1540e27ffebdb668a8f10ec7b8b7703aab3
7 files changed +95 -1
docs/source/serving/metrics.md
+8
@@ -36,3 +36,11 @@ The following metrics are exposed:
36 :language: python
37 :start-after: begin-metrics-definitions
38 :::
39 +
40 +The following metrics are deprecated and due to be removed in a future version:
41 +
42 +- *(No metrics are currently deprecated)*
43 +
44 +Note: when metrics are deprecated in version `X.Y`, they are hidden in version `X.Y+1`
45 +but can be re-enabled using the `--show-hidden-metrics-for-version=X.Y` escape hatch,
46 +and are then removed in version `X.Y+2`.
tests/test_version.py new
+36
@@ -0,0 +1,36 @@
1 +# SPDX-License-Identifier: Apache-2.0
2 +
3 +from unittest.mock import patch
4 +
5 +import pytest
6 +
7 +from vllm import version
8 +
9 +
10 +def test_version_is_defined():
11 + assert version.__version__ is not None
12 +
13 +
14 +def test_version_tuple():
15 + assert len(version.__version_tuple__) in (3, 4, 5)
16 +
17 +
18 +@pytest.mark.parametrize(
19 + "version_tuple, version_str, expected",
20 + [
21 + ((0, 0, "dev"), "0.0", True),
22 + ((0, 0, "dev"), "foobar", True),
23 + ((0, 7, 4), "0.6", True),
24 + ((0, 7, 4), "0.5", False),
25 + ((0, 7, 4), "0.7", False),
26 + ((1, 2, 3), "1.1", True),
27 + ((1, 2, 3), "1.0", False),
28 + ((1, 2, 3), "1.2", False),
29 + # This won't work as expected
30 + ((1, 0, 0), "1.-1", True),
31 + ((1, 0, 0), "0.9", False),
32 + ((1, 0, 0), "0.17", False),
33 + ])
34 +def test_prev_minor_version_was(version_tuple, version_str, expected):
35 + with patch("vllm.version.__version_tuple__", version_tuple):
36 + assert version._prev_minor_version_was(version_str) == expected
vllm/config.py
+3 -1
@@ -2653,7 +2653,9 @@ class DecodingConfig:
2653
2654 @dataclass
2655 class ObservabilityConfig:
2656 - """Configuration for observability."""
2656 + """Configuration for observability - metrics and tracing."""
2657 + show_hidden_metrics: bool = False
2658 +
2659 otlp_traces_endpoint: Optional[str] = None
2660
2661 # Collecting detailed timing information for each request can be expensive.
vllm/engine/arg_utils.py
+20
@@ -10,6 +10,7 @@ from typing import (TYPE_CHECKING, Any, Dict, List, Literal, Mapping, Optional,
10 import torch
11
12 import vllm.envs as envs
13 +from vllm import version
14 from vllm.config import (CacheConfig, CompilationConfig, ConfigFormat,
15 DecodingConfig, DeviceConfig, HfOverrides,
16 KVTransferConfig, LoadConfig, LoadFormat, LoRAConfig,
@@ -188,6 +189,7 @@ class EngineArgs:
189 qlora_adapter_name_or_path: Optional[str] = None
190 disable_logprobs_during_spec_decoding: Optional[bool] = None
191
192 + show_hidden_metrics_for_version: Optional[str] = None
193 otlp_traces_endpoint: Optional[str] = None
194 collect_detailed_traces: Optional[str] = None
195 disable_async_output_proc: bool = False
@@ -909,6 +911,18 @@ class EngineArgs:
911 default=None,
912 help='Name or path of the QLoRA adapter.')
913
914 + parser.add_argument('--show-hidden-metrics-for-version',
915 + type=str,
916 + default=None,
917 + help='Enable deprecated Prometheus metrics that '
918 + 'have been hidden since the specified version. '
919 + 'For example, if a previously deprecated metric '
920 + 'has been hidden since the v0.7.0 release, you '
921 + 'use --show-hidden-metrics-for-version=0.7 as a '
922 + 'temporary escape hatch while you migrate to new '
923 + 'metrics. The metric is likely to be removed '
924 + 'completely in an upcoming release.')
925 +
926 parser.add_argument(
927 '--otlp-traces-endpoint',
928 type=str,
@@ -1317,6 +1331,11 @@ class EngineArgs:
1331 decoding_config = DecodingConfig(
1332 guided_decoding_backend=self.guided_decoding_backend)
1333
1334 + show_hidden_metrics = False
1335 + if self.show_hidden_metrics_for_version is not None:
1336 + show_hidden_metrics = version._prev_minor_version_was(
1337 + self.show_hidden_metrics_for_version)
1338 +
1339 detailed_trace_modules = []
1340 if self.collect_detailed_traces is not None:
1341 detailed_trace_modules = self.collect_detailed_traces.split(",")
@@ -1326,6 +1345,7 @@ class EngineArgs:
1345 f"Invalid module {m} in collect_detailed_traces. "
1346 f"Valid modules are {ALLOWED_DETAILED_TRACE_MODULES}")
1347 observability_config = ObservabilityConfig(
1348 + show_hidden_metrics=show_hidden_metrics,
1349 otlp_traces_endpoint=self.otlp_traces_endpoint,
1350 collect_model_forward_time="model" in detailed_trace_modules
1351 or "all" in detailed_trace_modules,
vllm/engine/metrics.py
+5
@@ -516,6 +516,11 @@ class PrometheusStatLogger(StatLoggerBase):
516 self.metrics = self._metrics_cls(labelnames=list(labels.keys()),
517 vllm_config=vllm_config)
518
519 + # Use this flag to hide metrics that were deprecated in
520 + # a previous release and which will be removed future
521 + self.show_hidden_metrics = \
522 + vllm_config.observability_config.show_hidden_metrics
523 +
524 def _log_gauge(self, gauge, data: Union[int, float]) -> None:
525 # Convenience function for logging to gauge.
526 gauge.labels(**self.labels).set(data)
vllm/v1/metrics/loggers.py
+5
@@ -95,6 +95,11 @@ class PrometheusStatLogger(StatLoggerBase):
95 def __init__(self, vllm_config: VllmConfig):
96 self._unregister_vllm_metrics()
97
98 + # Use this flag to hide metrics that were deprecated in
99 + # a previous release and which will be removed future
100 + self.show_hidden_metrics = \
101 + vllm_config.observability_config.show_hidden_metrics
102 +
103 labelnames = ["model_name"]
104 labelvalues = [vllm_config.model_config.served_model_name]
105
vllm/version.py
+18
@@ -11,3 +11,21 @@ except Exception as e:
11
12 __version__ = "dev"
13 __version_tuple__ = (0, 0, __version__)
14 +
15 +
16 +def _prev_minor_version_was(version_str):
17 + """Check whether a given version matches the previous minor version.
18 +
19 + Return True if version_str matches the previous minor version.
20 +
21 + For example - return True if the current version if 0.7.4 and the
22 + supplied version_str is '0.6'.
23 +
24 + Used for --show-hidden-metrics-for-version.
25 + """
26 + # Match anything if this is a dev tree
27 + if __version_tuple__[0:2] == (0, 0):
28 + return True
29 +
30 + # Note - this won't do the right thing when we release 1.0!
31 + return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"