Skip to content

Commit d1fb65b

Browse files
authored
Enable v1 metrics tests (#20953)
Signed-off-by: Seiji Eicher <[email protected]>
1 parent 3a1d894 commit d1fb65b

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

.buildkite/test-pipeline.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ steps:
264264
- pytest -v -s v1/structured_output
265265
- pytest -v -s v1/spec_decode
266266
- pytest -v -s v1/kv_connector/unit
267+
- pytest -v -s v1/metrics
267268
- pytest -v -s v1/test_serial_utils.py
268269
- pytest -v -s v1/test_utils.py
269270
- pytest -v -s v1/test_oracle.py

tests/v1/metrics/test_ray_metrics.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
import os
4+
35
import pytest
46
import ray
57

8+
from vllm.config import ModelDType
69
from vllm.sampling_params import SamplingParams
710
from vllm.v1.engine.async_llm import AsyncEngineArgs, AsyncLLM
811
from vllm.v1.metrics.ray_wrappers import RayPrometheusStatLogger
@@ -27,7 +30,7 @@ def use_v1_only(monkeypatch):
2730
def test_engine_log_metrics_ray(
2831
example_prompts,
2932
model: str,
30-
dtype: str,
33+
dtype: ModelDType,
3134
max_tokens: int,
3235
) -> None:
3336
""" Simple smoke test, verifying this can be used without exceptions.
@@ -37,11 +40,14 @@ def test_engine_log_metrics_ray(
3740
class EngineTestActor:
3841

3942
async def run(self):
40-
engine_args = AsyncEngineArgs(
41-
model=model,
42-
dtype=dtype,
43-
disable_log_stats=False,
44-
)
43+
# Set environment variable inside the Ray actor since environment
44+
# variables from pytest fixtures don't propagate to Ray actors
45+
os.environ['VLLM_USE_V1'] = '1'
46+
47+
engine_args = AsyncEngineArgs(model=model,
48+
dtype=dtype,
49+
disable_log_stats=False,
50+
enforce_eager=True)
4551

4652
engine = AsyncLLM.from_engine_args(
4753
engine_args, stat_loggers=[RayPrometheusStatLogger])

vllm/v1/metrics/ray_wrappers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ class RayGaugeWrapper(RayPrometheusMetric):
5151
def __init__(self,
5252
name: str,
5353
documentation: Optional[str] = "",
54-
labelnames: Optional[list[str]] = None):
54+
labelnames: Optional[list[str]] = None,
55+
multiprocess_mode: Optional[str] = ""):
56+
57+
# All Ray metrics are keyed by WorkerId, so multiprocess modes like
58+
# "mostrecent", "all", "sum" do not apply. This logic can be manually
59+
# implemented at the observability layer (Prometheus/Grafana).
60+
del multiprocess_mode
5561
labelnames_tuple = tuple(labelnames) if labelnames else None
5662
self.metric = ray_metrics.Gauge(name=name,
5763
description=documentation,

0 commit comments

Comments
 (0)