Skip to content

Commit

Permalink
Remove best_of_requests stats if removed from vLLM
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui committed Nov 5, 2024
1 parent b71088a commit ab17e5e
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ def __init__(self, labels: List[str], max_model_len: int):
description="Number of generation tokens processed.",
kind=pb_utils.MetricFamily.HISTOGRAM,
)
self.histogram_best_of_request_family = pb_utils.MetricFamily(
name="vllm:request_params_best_of",
description="Histogram of the best_of request parameter.",
kind=pb_utils.MetricFamily.HISTOGRAM,
)
# TODO: Remove best_of_request when upgrading vLLM >= 0.6.3
self.histogram_best_of_request_family = None
if "best_of_requests" in getattr(VllmStats, "__dataclass_fields__", {}):
self.histogram_best_of_request_family = pb_utils.MetricFamily(
name="vllm:request_params_best_of",
description="Histogram of the best_of request parameter.",
kind=pb_utils.MetricFamily.HISTOGRAM,
)
self.histogram_n_request_family = pb_utils.MetricFamily(
name="vllm:request_params_n",
description="Histogram of the n request parameter.",
Expand Down Expand Up @@ -159,10 +162,14 @@ def __init__(self, labels: List[str], max_model_len: int):
buckets=build_1_2_5_buckets(max_model_len),
)
)
self.histogram_best_of_request = self.histogram_best_of_request_family.Metric(
labels=labels,
buckets=[1, 2, 5, 10, 20],
)
self.histogram_best_of_request = None
if self.histogram_best_of_request_family is not None:
self.histogram_best_of_request = (
self.histogram_best_of_request_family.Metric(
labels=labels,
buckets=[1, 2, 5, 10, 20],
)
)
self.histogram_n_request = self.histogram_n_request_family.Metric(
labels=labels,
buckets=[1, 2, 5, 10, 20],
Expand Down Expand Up @@ -247,9 +254,12 @@ def log(self, stats: VllmStats) -> None:
self.metrics.histogram_num_generation_tokens_request,
stats.num_generation_tokens_requests,
),
(self.metrics.histogram_best_of_request, stats.best_of_requests),
(self.metrics.histogram_n_request, stats.n_requests),
]
if self.metrics.histogram_best_of_request is not None:
histogram_metrics.append(
(self.metrics.histogram_best_of_request, stats.best_of_requests)
)

for metric, data in counter_metrics:
self._log_counter(metric, data)
Expand Down

0 comments on commit ab17e5e

Please sign in to comment.