vllm.v1.metrics.stats ¶
Classes:
-
BaseCacheStats–Stores cache hit statistics.
-
CachingMetrics–Metrics for caching with a hit rate of the most recent N requests.
-
FinishedRequestStats–Stats associated with a finished request.
-
IterationStats–Stats associated with a single set of EngineCoreOutputs.
-
KVCacheEvictionEvent–Single KV cache block eviction sample.
-
LoRARequestStates–A per-LoRA count of running and waiting requests.
-
LoRAStats–Tracks waiting and running request IDs for a single LoRA.
-
MultiModalCacheStats–Stores multi-modal cache hit statistics.
-
PrefillStats–Breakdown of a scheduled prefill computation.
-
PrefixCacheStats–Stores prefix cache hit statistics.
-
PromptTokenStats–Breakdown of prompt tokens by source.
-
RequestStateStats–Stats that need to be tracked across delta updates.
-
SchedulerStats–Stats associated with the scheduler.
BaseCacheStats dataclass ¶
Stores cache hit statistics.
Attributes:
-
hits(int) –The number of hits in these requests.
-
queries(int) –The number of queries in these requests.
-
requests(int) –The number of requests in this update.
-
reset(bool) –Whether the cache was reset.
Source code in vllm/v1/metrics/stats.py
hits = 0 class-attribute instance-attribute ¶
The number of hits in these requests.
queries = 0 class-attribute instance-attribute ¶
The number of queries in these requests.
requests = 0 class-attribute instance-attribute ¶
The number of requests in this update.
reset = False class-attribute instance-attribute ¶
Whether the cache was reset.
CachingMetrics ¶
Metrics for caching with a hit rate of the most recent N requests. Args: interval: The number of the most recent requests to aggregate. Defaults to 1000.
Methods:
Attributes:
-
empty(bool) –Return true if no requests have been observed.
-
hit_rate(float) –Calculate the hit rate for the past N requests.
Source code in vllm/v1/metrics/stats.py
empty property ¶
Return true if no requests have been observed.
hit_rate property ¶
Calculate the hit rate for the past N requests.
observe(stats) ¶
Observe the prefix caching for a set of requests.
This function is called with information gathered when new requests are being scheduled and are looking for computed blocks.
When there are more than max_recent_requests requests, the oldest set of requests are removed from the metrics.
Parameters:
-
(stats¶BaseCacheStats) –The prefix cache stats.
Source code in vllm/v1/metrics/stats.py
FinishedRequestStats dataclass ¶
Stats associated with a finished request.
Source code in vllm/v1/metrics/stats.py
IterationStats ¶
Stats associated with a single set of EngineCoreOutputs.
Attributes:
-
num_prompt_tokens(int) –Total prompt tokens (for backward compatibility).
Source code in vllm/v1/metrics/stats.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
num_prompt_tokens property ¶
Total prompt tokens (for backward compatibility).
KVCacheEvictionEvent dataclass ¶
LoRARequestStates ¶
A per-LoRA count of running and waiting requests.
Source code in vllm/v1/metrics/stats.py
LoRAStats ¶
Tracks waiting and running request IDs for a single LoRA.
Source code in vllm/v1/metrics/stats.py
MultiModalCacheStats dataclass ¶
Bases: BaseCacheStats
Stores multi-modal cache hit statistics. - reset: Whether reset_mm_cache was invoked. - queries: Refers to the number of multi-modal data items that were queried.
Methods:
-
record–Aggregate request information into the stats.
Source code in vllm/v1/metrics/stats.py
record(num_queries, num_hits) ¶
PrefillStats dataclass ¶
Breakdown of a scheduled prefill computation.
Fields
num_prompt_tokens: Total number of tokens to be prefilled. num_computed_tokens: Tokens to be prefilled locally (actual compute work). num_cached_tokens: Tokens to be prefilled without actual compute work. num_local_cached_tokens: Tokens to be prefilled from local prefix cache. num_external_cached_tokens: Tokens to be prefilled from external KV transfer.
Source code in vllm/v1/metrics/stats.py
PrefixCacheStats dataclass ¶
Bases: BaseCacheStats
Stores prefix cache hit statistics. - reset: Whether reset_prefix_cache was invoked. - queries: Refers to the number of tokens that were queried.
Methods:
-
record–Aggregate request information into the stats.
Attributes:
-
preempted_hits(int) –The
hitsnumber for preempted requests. -
preempted_queries(int) –The
queriesnumber for preempted requests. -
preempted_requests(int) –The number of previously preempted requests in this update.
Source code in vllm/v1/metrics/stats.py
preempted_hits = 0 class-attribute instance-attribute ¶
The hits number for preempted requests.
preempted_queries = 0 class-attribute instance-attribute ¶
The queries number for preempted requests.
preempted_requests = 0 class-attribute instance-attribute ¶
The number of previously preempted requests in this update.
record(num_tokens, num_hits, preempted) ¶
Aggregate request information into the stats.
Source code in vllm/v1/metrics/stats.py
PromptTokenStats dataclass ¶
Breakdown of prompt tokens by source.
Fields
computed: Tokens prefilled locally (actual compute work). local_cache_hit: Tokens from local prefix cache. external_kv_transfer: Tokens from external KV transfer. cached_tokens: Tokens skipped during prefill (from scheduler). total: Total prompt tokens.
Invariants
computed + local_cache_hit + external_kv_transfer = total local_cache_hit + external_kv_transfer = cached_tokens
Methods:
-
get_by_source–Get token count by source label.
-
update_from_output–Update stats from a prefill output.
Source code in vllm/v1/metrics/stats.py
get_by_source(source) ¶
Get token count by source label.
Source code in vllm/v1/metrics/stats.py
update_from_output(prefill_stats) ¶
Update stats from a prefill output.
Source code in vllm/v1/metrics/stats.py
RequestStateStats dataclass ¶
Stats that need to be tracked across delta updates.
Source code in vllm/v1/metrics/stats.py
SchedulerStats dataclass ¶
Stats associated with the scheduler.