[feature][kv_offload] Self-describing KV events for OffloadingConnector (#43468)

Signed-off-by: Change72 <changg@nvidia.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Change72
2026-06-22 07:27:46 +00:00
committed by GitHub
co-authored by Claude
parent d14e551a53
commit a9f7b2d41c
9 changed files with 720 additions and 62 deletions
+19
View File
@@ -147,6 +147,16 @@ class OffloadingHistogramMetadata(OffloadingMetricMetadata):
buckets: tuple[float, ...] | None = None
@dataclass(frozen=True)
class OffloadingKVEventsConfig:
# Global vLLM KV event publishing flag. When false, connector-specific
# event capture must stay inert because take_events() is not drained.
enable_kv_cache_events: bool
# OffloadingConnector opt-in for self-describing BlockStored payloads.
# Effective only when enable_kv_cache_events is true.
self_describing_kv_events: bool
class OffloadingManager(ABC):
@abstractmethod
def lookup(self, key: OffloadKey, req_context: ReqContext) -> bool | None:
@@ -443,6 +453,15 @@ class OffloadingSpec(ABC):
kv_transfer_config = vllm_config.kv_transfer_config
assert kv_transfer_config is not None
self.extra_config = kv_transfer_config.kv_connector_extra_config
kv_events_config = vllm_config.kv_events_config
self.kv_events_config = OffloadingKVEventsConfig(
enable_kv_cache_events=(
kv_events_config is not None and kv_events_config.enable_kv_cache_events
),
self_describing_kv_events=bool(
self.extra_config.get("self_describing_kv_events", False)
),
)
# When True, only prompt (prefill) blocks are offloaded; decode-phase
# blocks (KV generated after the prompt) are skipped. Useful when prior
+1 -6
View File
@@ -114,11 +114,6 @@ class CPUOffloadingSpec(OffloadingSpec):
@override
def get_manager(self) -> OffloadingManager:
if not self._manager:
kv_events_config = self.vllm_config.kv_events_config
enable_events = (
kv_events_config is not None and kv_events_config.enable_kv_cache_events
)
# store_threshold: how many times a block must appear in lookup()
# before it is eligible for CPU offloading. Values < 2 disable
# filtering (a threshold of 1 equals no filter; 0 is the default).
@@ -130,7 +125,7 @@ class CPUOffloadingSpec(OffloadingSpec):
self._manager = CPUOffloadingManager(
num_blocks=self.num_blocks,
cache_policy=self.eviction_policy, # type: ignore[arg-type]
enable_events=enable_events,
enable_events=self.kv_events_config.enable_kv_cache_events,
store_threshold=store_threshold,
max_tracker_size=max_tracker_size,
)
+10 -7
View File
@@ -69,6 +69,14 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
super().__init__(vllm_config, kv_cache_config)
# Redeclare for mypy: parent sets this but `--follow-imports skip` hides it
self._manager: OffloadingManager | None = None
if self.kv_events_config.self_describing_kv_events:
raise ValueError(
"self_describing_kv_events is not supported by "
"TieringOffloadingSpec. Tier promotions can emit primary-tier "
"store events that do not correspond to GPU store jobs, so the "
"current self-describing side table cannot describe them "
"correctly."
)
# Parse secondary tier configurations
self.secondary_tier_configs = self.extra_config.get("secondary_tiers", [])
@@ -91,11 +99,6 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
TieringOffloadingManager instance
"""
if not self._manager:
kv_events_config = self.vllm_config.kv_events_config
enable_events = (
kv_events_config is not None and kv_events_config.enable_kv_cache_events
)
# Create scheduler-side SharedOffloadRegion (rank=None) so the
# primary tier can eagerly create a memoryview over _base.
scheduler_mmap = SharedOffloadRegion(
@@ -111,7 +114,7 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
primary_tier = CPUPrimaryTierOffloadingManager(
num_blocks=self.num_blocks,
cache_policy=self.eviction_policy, # type: ignore[arg-type]
enable_events=enable_events,
enable_events=self.kv_events_config.enable_kv_cache_events,
mmap_region=scheduler_mmap,
)
@@ -143,7 +146,7 @@ class TieringOffloadingSpec(CPUOffloadingSpec):
tiering_manager = TieringOffloadingManager(
primary_tier=primary_tier,
secondary_tiers=secondary_tiers,
enable_events=enable_events,
enable_events=self.kv_events_config.enable_kv_cache_events,
)
if int(self.extra_config.get("store_threshold", 0)) >= 2:
raise ValueError(