Skip to content

Enable v1 metrics tests #20953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/test-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ steps:
- pytest -v -s v1/structured_output
- pytest -v -s v1/spec_decode
- pytest -v -s v1/kv_connector/unit
- pytest -v -s v1/metrics
- pytest -v -s v1/test_serial_utils.py
- pytest -v -s v1/test_utils.py
- pytest -v -s v1/test_oracle.py
Expand Down
18 changes: 12 additions & 6 deletions tests/v1/metrics/test_ray_metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import os

import pytest
import ray

from vllm.config import ModelDType
from vllm.sampling_params import SamplingParams
from vllm.v1.engine.async_llm import AsyncEngineArgs, AsyncLLM
from vllm.v1.metrics.ray_wrappers import RayPrometheusStatLogger
Expand All @@ -27,7 +30,7 @@ def use_v1_only(monkeypatch):
def test_engine_log_metrics_ray(
example_prompts,
model: str,
dtype: str,
dtype: ModelDType,
max_tokens: int,
) -> None:
""" Simple smoke test, verifying this can be used without exceptions.
Expand All @@ -37,11 +40,14 @@ def test_engine_log_metrics_ray(
class EngineTestActor:

async def run(self):
engine_args = AsyncEngineArgs(
model=model,
dtype=dtype,
disable_log_stats=False,
)
# Set environment variable inside the Ray actor since environment
# variables from pytest fixtures don't propagate to Ray actors
os.environ['VLLM_USE_V1'] = '1'

engine_args = AsyncEngineArgs(model=model,
dtype=dtype,
disable_log_stats=False,
enforce_eager=True)

engine = AsyncLLM.from_engine_args(
engine_args, stat_loggers=[RayPrometheusStatLogger])
Expand Down
8 changes: 7 additions & 1 deletion vllm/v1/metrics/ray_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ class RayGaugeWrapper(RayPrometheusMetric):
def __init__(self,
name: str,
documentation: Optional[str] = "",
labelnames: Optional[list[str]] = None):
labelnames: Optional[list[str]] = None,
multiprocess_mode: Optional[str] = ""):

# All Ray metrics are keyed by WorkerId, so multiprocess modes like
# "mostrecent", "all", "sum" do not apply. This logic can be manually
# implemented at the observability layer (Prometheus/Grafana).
del multiprocess_mode
labelnames_tuple = tuple(labelnames) if labelnames else None
self.metric = ray_metrics.Gauge(name=name,
description=documentation,
Expand Down