vllm.v1.metrics.buckets ¶
Default bucket boundaries for the Prometheus histograms emitted by vLLM.
Every core engine histogram created by the Prometheus stat logger draws its bucket boundaries from exactly one of the families defined here, so each default list has a single source of truth. Histograms owned by other subsystems, such as the KV connector and offloading metrics, keep their own boundaries.
Functions:
-
build_1_2_5_buckets–Build a 1-2-5 series of buckets capped at
max_value. -
build_buckets–Build buckets from mantissas scaled by increasing powers of 10.
-
histogram_buckets–Return the default bucket boundaries for a histogram family.
Attributes:
-
BUCKET_FAMILY_KEYS(frozenset[str]) –All bucket family keys, for membership checks.
-
BucketFamilyKey–Canonical keys for the histogram bucket families.
-
INTER_TOKEN_LATENCY_BUCKETS(tuple[float, ...]) –Per-decode-step latencies: 10 ms fast decode up to multi-second stalls.
-
ITERATION_TOKENS_BUCKETS(tuple[float, ...]) –Tokens processed per engine step: powers of two up to a typical
-
KV_CACHE_RESIDENCY_BUCKETS(tuple[float, ...]) –KV cache block residency times: millisecond-scale reuse gaps up to
-
REQUEST_LATENCY_BUCKETS(tuple[float, ...]) –Sub-second scheduling delays through multi-hour batch requests; shared by
-
REQUEST_NUM_PREEMPTIONS_BUCKETS(tuple[float, ...]) –Per-request preemption counts, recorded for every finished request: the
-
REQUEST_PARAMS_N_BUCKETS(tuple[float, ...]) –Small integer counts for the
nsampling parameter. -
TIME_TO_FIRST_TOKEN_BUCKETS(tuple[float, ...]) –Millisecond-scale prefill for tiny prompts up to ~40-minute worst cases,
BUCKET_FAMILY_KEYS = frozenset(get_args(BucketFamilyKey)) module-attribute ¶
All bucket family keys, for membership checks.
BucketFamilyKey = Literal['request_latency', 'time_to_first_token', 'inter_token_latency', 'iteration_tokens', 'request_params_n', 'request_num_preemptions', 'request_tokens', 'kv_cache_residency'] module-attribute ¶
Canonical keys for the histogram bucket families.
INTER_TOKEN_LATENCY_BUCKETS = (0.01, 0.025, 0.05, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 20.0, 40.0, 80.0) module-attribute ¶
Per-decode-step latencies: 10 ms fast decode up to multi-second stalls.
ITERATION_TOKENS_BUCKETS = (1, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384) module-attribute ¶
Tokens processed per engine step: powers of two up to a typical max-num-batched-tokens budget.
KV_CACHE_RESIDENCY_BUCKETS = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 30, 60, 120, 300, 600, 1200, 1800) module-attribute ¶
KV cache block residency times: millisecond-scale reuse gaps up to 30-minute block lifetimes.
REQUEST_LATENCY_BUCKETS = (0.3, 0.5, 0.8, 1.0, 1.5, 2.0, 2.5, 5.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 60.0, 120.0, 240.0, 480.0, 960.0, 1920.0, 7680.0) module-attribute ¶
Sub-second scheduling delays through multi-hour batch requests; shared by the accumulated request phase-timing histograms (e2e, queue, inference, prefill, decode).
REQUEST_NUM_PREEMPTIONS_BUCKETS = (1, 2, 3, 4, 5, 10, 20) module-attribute ¶
Per-request preemption counts, recorded for every finished request: the first bucket therefore holds never-preempted requests together with singly-preempted ones, 2 through 5 are separated individually, and the tail coarsens to 20. Distinct from REQUEST_PARAMS_N_BUCKETS because these are the boundaries the metric shipped with, not a harmonized choice.
REQUEST_PARAMS_N_BUCKETS = (1, 2, 5, 10, 20) module-attribute ¶
Small integer counts for the n sampling parameter.
TIME_TO_FIRST_TOKEN_BUCKETS = (0.001, 0.005, 0.01, 0.02, 0.04, 0.06, 0.08, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 20.0, 40.0, 80.0, 160.0, 640.0, 2560.0) module-attribute ¶
Millisecond-scale prefill for tiny prompts up to ~40-minute worst cases, with the densest resolution around interactive (sub-second) latencies.
build_1_2_5_buckets(max_value) ¶
Build a 1-2-5 series of buckets capped at max_value.
Example
build_1_2_5_buckets(100) [1, 2, 5, 10, 20, 50, 100]
build_buckets(mantissa_lst, max_value) ¶
Build buckets from mantissas scaled by increasing powers of 10.
Parameters:
-
(mantissa_lst¶list[int]) –Mantissa values multiplied by each power of 10.
-
(max_value¶int) –Largest bucket value to include.
Returns:
Source code in vllm/v1/metrics/buckets.py
histogram_buckets(family, max_model_len=None) ¶
Return the default bucket boundaries for a histogram family.
Parameters:
-
(family¶BucketFamilyKey) –Canonical bucket family key.
-
(max_model_len¶int | None, default:None) –Cap for the token-count series of the
request_tokensfamily; required for that family and ignored otherwise.
Returns:
Raises:
-
ValueError–If
familyisrequest_tokensandmax_model_lenis None.