Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SolitaryThinker committed Jun 28, 2024
1 parent 00c33e8 commit a44e8d9
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions vllm/engine/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from typing import Dict, List, Optional, Protocol, Union

import numpy as np
#from prometheus_client import (REGISTRY, Counter, Gauge, Histogram, Info,
# disable_created_metrics)
import prometheus_client

from vllm.executor.ray_utils import ray
Expand Down Expand Up @@ -39,7 +37,7 @@ def __init__(self, labelnames: List[str], max_model_len: int):
self._unregister_vllm_metrics()

# Config Information
self.info_cache_config = self._base_library.Info(
self.info_cache_config = prometheus_client.Info(
name='vllm:cache_config',
documentation='information of cache_config')

Expand Down Expand Up @@ -161,6 +159,11 @@ class RayMetrics(Metrics):
"""
_base_library = ray_metrics

def __init__(self, labelnames: List[str], max_model_len: int):
super().__init__(labelnames, max_model_len)
if ray_metrics is None:
raise ImportError("RayMetrics requires Ray to be installed.")

def _unregister_vllm_metrics(self) -> None:
pass

Expand Down Expand Up @@ -327,14 +330,15 @@ def _format_spec_decode_metrics_str(

class PrometheusStatLogger(StatLoggerBase):
"""PrometheusStatLogger is used LLMEngine to log to Promethus."""
_metrics_cls = Metrics

def __init__(self, local_interval: float, labels: Dict[str, str],
max_model_len: int) -> None:
super().__init__(local_interval)
# Prometheus metrics
self.labels = labels
self.metrics = Metrics(labelnames=list(labels.keys()),
max_model_len=max_model_len)
self.metrics = self._metrics_cls(labelnames=list(labels.keys()),
max_model_len=max_model_len)

def info(self, type: str, obj: SupportsMetricsInfo) -> None:
if type == "cache_config":
Expand Down Expand Up @@ -452,11 +456,4 @@ def log(self, stats: Stats):

class RayPrometheusStatLogger(PrometheusStatLogger):
"""RayPrometheusStatLogger uses Ray metrics instead."""

def __init__(self, local_interval: float, labels: Dict[str, str],
max_model_len: int) -> None:
super().__init__(local_interval, labels, max_model_len)

# replace the base library with ray's metrics
self.metrics = RayMetrics(labelnames=list(labels.keys()),
max_model_len=max_model_len)
_metrics_cls = RayMetrics

0 comments on commit a44e8d9

Please sign in to comment.