[Core][KV Connector] Resolve connector block tables for every scheduled request (#54853)

Signed-off-by: Zhewen Li <zhewenli@inferact.ai>
Co-authored-by: Zhewen Li <zhewenli@inferact.ai>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Zhewen Li
2026-09-09 02:15:53 +00:00
committed by GitHub
co-authored by Zhewen Li Claude Fable 5.1 Codex
parent a97dacb710
commit 0b066293f3
6 changed files with 105 additions and 31 deletions
@@ -434,7 +434,7 @@ class MooncakeStoreScheduler:
"Current block tables are required for Mooncake store jobs"
)
for req_meta in save_metas:
block_ids = block_state.block_ids.get(req_meta.req_id)
block_ids = block_state.get_block_ids(req_meta.req_id)
assert block_ids is not None, (
f"Missing current block table for store request {req_meta.req_id}"
)
+10 -2
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Callable
from dataclasses import dataclass
from functools import cached_property
from typing import TYPE_CHECKING
@@ -209,11 +210,18 @@ class ScheduledEncoderInputStats:
class KVConnectorBlockState:
"""Scheduler-local block state offered to a producer-side KV connector."""
# Authoritative current block-table snapshots.
block_ids: dict[str, tuple[list[int], ...]]
# Requests scheduled this step and requests with a boundary-state hand-off.
req_ids: set[str]
# Resolve on access to avoid copying tables the connector never reads.
resolve_block_ids: Callable[[str], tuple[list[int], ...]]
# Exact Mamba "align" boundary-state hand-offs.
boundary_state_offloads: dict[str, list[tuple[int, int, int]]]
def get_block_ids(self, req_id: str) -> tuple[list[int], ...] | None:
if req_id not in self.req_ids:
return None
return self.resolve_block_ids(req_id)
@dataclass
class SchedulerOutput:
+7 -15
View File
@@ -1359,24 +1359,16 @@ class Scheduler(SchedulerInterface):
kv_connector_block_state = None
if self.connector is not None:
snapshot_req_ids = {req.req_id for req in new_reqs_data}
snapshot_req_ids.update(
req_id
for req_id, block_ids in zip(
cached_reqs_data.req_ids,
cached_reqs_data.new_block_ids,
strict=True,
)
if block_ids
)
snapshot_req_ids.update(
# Any request scheduled this step can become a connector job now,
# not only the ones that were allocated blocks: a store save lands
# on the step that fills a block, which allocated none.
block_state_req_ids = set(num_scheduled_tokens)
block_state_req_ids.update(
req_id for req_id in boundary_state_offloads if req_id in self.requests
)
kv_connector_block_state = KVConnectorBlockState(
block_ids={
req_id: self.kv_cache_manager.get_block_ids(req_id)
for req_id in snapshot_req_ids
},
req_ids=block_state_req_ids,
resolve_block_ids=self.kv_cache_manager.get_block_ids,
boundary_state_offloads=boundary_state_offloads,
)