[Metrics] Add --custom-histogram-buckets to override histogram bucket families (#48867)
The core engine histograms ship with default bucket boundaries tuned for typical serving workloads. The `--custom-histogram-buckets` option replaces the boundaries of one or more bucket families. Use it, for example, to track sub-300ms latency SLOs with the request-phase histograms, whose smallest default boundary is 0.3s. Signed-off-by: Guy Stone <guys@spotify.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
a47e4a5568
commit
37d6174096
@@ -9,6 +9,7 @@ subsystems, such as the KV connector and offloading metrics, keep their own
|
||||
boundaries.
|
||||
"""
|
||||
|
||||
from collections.abc import Mapping
|
||||
from typing import Literal, get_args
|
||||
|
||||
BucketFamilyKey = Literal[
|
||||
@@ -205,23 +206,31 @@ def build_1_2_5_buckets(max_value: int) -> list[float]:
|
||||
def histogram_buckets(
|
||||
family: BucketFamilyKey,
|
||||
max_model_len: int | None = None,
|
||||
overrides: Mapping[str, list[float]] | None = None,
|
||||
) -> list[float]:
|
||||
"""Return the default bucket boundaries for a histogram family.
|
||||
"""Return the bucket boundaries for a histogram family.
|
||||
|
||||
Args:
|
||||
family: Canonical bucket family key.
|
||||
max_model_len: Cap for the token-count series of the
|
||||
`request_tokens` family; required for that family and ignored
|
||||
otherwise.
|
||||
overrides: Mapping from family key to replacement bucket bounds.
|
||||
A present key replaces the family's defaults verbatim. Values
|
||||
must already be validated; the single validation point is
|
||||
`ObservabilityConfig.custom_histogram_buckets`.
|
||||
|
||||
Returns:
|
||||
A fresh list of bucket upper bounds; callers may mutate it freely.
|
||||
|
||||
Raises:
|
||||
ValueError: If `family` is `request_tokens` and `max_model_len`
|
||||
is None.
|
||||
ValueError: If `family` is `request_tokens`, no override is given,
|
||||
and `max_model_len` is None.
|
||||
|
||||
|
||||
"""
|
||||
if overrides is not None and (custom := overrides.get(family)) is not None:
|
||||
return list(custom)
|
||||
if family == "request_tokens":
|
||||
if max_model_len is None:
|
||||
raise ValueError(
|
||||
|
||||
@@ -739,15 +739,28 @@ class PrometheusStatLogger(AggregateStatLoggerBase):
|
||||
for idx in engine_indexes
|
||||
}
|
||||
|
||||
custom_buckets = vllm_config.observability_config.custom_histogram_buckets
|
||||
request_tokens_buckets = histogram_buckets(
|
||||
"request_tokens", max_model_len=max_model_len
|
||||
"request_tokens", max_model_len=max_model_len, overrides=custom_buckets
|
||||
)
|
||||
iteration_tokens_buckets = histogram_buckets(
|
||||
"iteration_tokens", overrides=custom_buckets
|
||||
)
|
||||
request_params_n_buckets = histogram_buckets(
|
||||
"request_params_n", overrides=custom_buckets
|
||||
)
|
||||
time_to_first_token_buckets = histogram_buckets(
|
||||
"time_to_first_token", overrides=custom_buckets
|
||||
)
|
||||
inter_token_latency_buckets = histogram_buckets(
|
||||
"inter_token_latency", overrides=custom_buckets
|
||||
)
|
||||
request_latency_buckets = histogram_buckets(
|
||||
"request_latency", overrides=custom_buckets
|
||||
)
|
||||
request_num_preemptions_buckets = histogram_buckets(
|
||||
"request_num_preemptions", overrides=custom_buckets
|
||||
)
|
||||
iteration_tokens_buckets = histogram_buckets("iteration_tokens")
|
||||
request_params_n_buckets = histogram_buckets("request_params_n")
|
||||
time_to_first_token_buckets = histogram_buckets("time_to_first_token")
|
||||
inter_token_latency_buckets = histogram_buckets("inter_token_latency")
|
||||
request_latency_buckets = histogram_buckets("request_latency")
|
||||
request_num_preemptions_buckets = histogram_buckets("request_num_preemptions")
|
||||
|
||||
#
|
||||
# Histograms of counts
|
||||
@@ -925,7 +938,9 @@ class PrometheusStatLogger(AggregateStatLoggerBase):
|
||||
# KV Cache residency metrics
|
||||
#
|
||||
if self.kv_cache_metrics_enabled:
|
||||
kv_cache_residency_buckets = histogram_buckets("kv_cache_residency")
|
||||
kv_cache_residency_buckets = histogram_buckets(
|
||||
"kv_cache_residency", overrides=custom_buckets
|
||||
)
|
||||
|
||||
histogram_kv_block_lifetime = self._histogram_cls(
|
||||
name="vllm:kv_block_lifetime_seconds",
|
||||
|
||||
Reference in New Issue
Block a user