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.
-
RequestSpecDecodeMetrics–Per-output-sequence speculative-decoding statistics accumulator.
-
RequestStateStats–Stats that need to be tracked across delta updates.
-
SchedulerIterationDetails–Scheduler-side details for one engine iteration.
-
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
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 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
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. num_cache_creation_tokens: Tokens computed and written to the prefix cache.
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
RequestSpecDecodeMetrics dataclass ¶
Per-output-sequence speculative-decoding statistics accumulator.
Accumulates, over one sequence's verify steps, a histogram of accepted draft-token counts (j, draft-only) and the total number of proposed draft tokens. When detailed is requested it also records the ordered per-step accepted/proposed sequences (summary omits them). Tracked per engine Request (one per sampled sequence, so n > 1 yields one per child), surfaced via EngineCoreOutput and the response metrics.speculative_decoding for single-sequence requests (see to_dict).
Fields
num_spec_tokens: Configured num_speculative_tokens (the max k); also the histogram's upper bound. histogram: Dense counts indexed by accepted draft tokens j (length num_spec_tokens + 1). num_draft_tokens: Total proposed draft tokens, after the grammar-invalidated (num_invalid_spec_tokens) adjustment. per_step_accepted: Ordered accepted-draft count per verify step (detailed only; empty otherwise). per_step_drafted: Ordered proposed-draft count per verify step (detailed only; empty otherwise).
Methods:
-
to_dict–Payload matching
SpeculativeDecodingMetricsfor the response.
Source code in vllm/v1/metrics/stats.py
to_dict() ¶
Payload matching SpeculativeDecodingMetrics for the response.
acceptance_histogram is a dense list indexed by accepted draft count j (length num_spec_tokens + 1). mean_acceptance_length includes the bonus token (j + 1); draft_acceptance_rate is draft-only, full precision. Per-step arrays are included only when populated (detailed level).
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
SchedulerIterationDetails dataclass ¶
Scheduler-side details for one engine iteration.
Source code in vllm/v1/metrics/stats.py
SchedulerStats dataclass ¶
Stats associated with the scheduler.