[Bugfix] Restore KV cache metadata GET method for external event consumer (#56925)

Signed-off-by: Wei Zhao <51183510+wzhao18@users.noreply.github.com>
This commit is contained in:
Wei Zhao
2026-09-17 23:01:35 +00:00
committed by GitHub
parent e0050f287a
commit ccde9c61e9
2 changed files with 101 additions and 1 deletions
+31 -1
View File
@@ -85,7 +85,11 @@ from vllm.v1.fault_tolerance.engine_core_sentinel import (
EngineCoreSentinel,
fault_tolerant_wrapper,
)
from vllm.v1.kv_cache_interface import KVCacheConfig, is_full_attention_spec
from vllm.v1.kv_cache_interface import (
KVCacheConfig,
get_kv_cache_spec_kind,
is_full_attention_spec,
)
from vllm.v1.metrics.stats import SchedulerIterationDetails, SchedulerStats
from vllm.v1.outputs import ModelRunnerOutput
from vllm.v1.request import Request, RequestStatus
@@ -457,6 +461,32 @@ class EngineCore:
supported_pooling_tasks,
)
def get_kv_cache_group_metadata(self) -> list[dict[str, int | str | None]]:
"""Return serializable KV cache metadata for external event consumers
(e.g., Dynamo). This function has no call sites within vLLM but needs to
be kept.
"""
kv_cache_config = getattr(self.scheduler, "kv_cache_config", None)
if kv_cache_config is None:
return []
kv_cache_manager = cast(Any, self.scheduler).kv_cache_manager
managers = kv_cache_manager.coordinator.single_type_managers
metadata: list[dict[str, int | str | None]] = []
for group_idx, (group, manager) in enumerate(
zip(kv_cache_config.kv_cache_groups, managers, strict=True)
):
spec = group.kv_cache_spec
metadata.append(
{
"group_idx": group_idx,
"kind": get_kv_cache_spec_kind(spec).value,
"block_size": manager.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.