feat(kv-events): emit KV cache metadata (#40984)

Signed-off-by: PeaBrane <yanrpei@gmail.com>
This commit is contained in:
Yan Ru Pei
2026-05-12 15:58:48 +00:00
committed by GitHub
parent c8a6e272e0
commit bcb9c133ba
8 changed files with 381 additions and 21 deletions
+20 -1
View File
@@ -72,7 +72,7 @@ from vllm.v1.engine.utils import (
get_device_indices,
)
from vllm.v1.executor import Executor
from vllm.v1.kv_cache_interface import KVCacheConfig
from vllm.v1.kv_cache_interface import KVCacheConfig, get_kv_cache_spec_kind
from vllm.v1.metrics.stats import SchedulerStats
from vllm.v1.outputs import ModelRunnerOutput
from vllm.v1.request import Request, RequestStatus
@@ -312,6 +312,25 @@ class EngineCore:
def get_supported_tasks(self) -> tuple[SupportedTask, ...]:
return self.model_executor.supported_tasks
def get_kv_cache_group_metadata(self) -> list[dict[str, int | str | None]]:
"""Return msgspec-serializable metadata for scheduler KV cache groups."""
kv_cache_config = getattr(self.scheduler, "kv_cache_config", None)
if kv_cache_config is None:
return []
metadata: list[dict[str, int | str | None]] = []
for group_idx, group in enumerate(kv_cache_config.kv_cache_groups):
spec = group.kv_cache_spec
metadata.append(
{
"group_idx": group_idx,
"kind": get_kv_cache_spec_kind(spec).value,
"block_size": spec.block_size,
"sliding_window": getattr(spec, "sliding_window", None),
}
)
return metadata
def add_request(self, request: Request, request_wave: int = 0):
"""Add request to the scheduler.