[KV] Side-cache layout -- fold the PLE state into a GDN group, pack QSA rings

The packed pool strides every block by the widest group, and every group draws whole blocks. The PLE short-conv
state now shares a GDN cache group, and the QSA raw-key rings are packed as equal slots inside shared blocks, so
neither holds a whole block per request. VLLM_E2_SIDE_CACHE_LAYOUT (default 1) selects the old layout with 0.
On its own the layout raises the Flash-Next pool from 806,792 to 853,994 tokens at the same budget.

Co-Authored-By: Hinata <hinata@idihore.id>
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2026-10-09 20:15:11 +07:00
co-authored by Hinata
parent 21fb7de7bf
commit 72485816d9
10 changed files with 3513 additions and 10 deletions
+22 -1
View File
@@ -1431,6 +1431,11 @@ class KVCacheTensor:
block_stride: int
offset: int = 0 # byte offset of layers[0]'s block 0
host_resident: bool = False
# v2.5 side-cache layout: a slot-packed ring tensor views every pool block
# as ``slots_per_block`` equal slots (``block_stride`` is then one slot), so
# its block ids are ``pool_block * slots_per_block + slot``. 1 = one view
# block per pool block, the ordinary case.
slots_per_block: int = 1
class KVCacheGroupRole(str, Enum):
@@ -1458,6 +1463,10 @@ class KVCacheGroupSpec:
# source group after a connector load.
enable_kv_transfer: bool = True
role: KVCacheGroupRole = KVCacheGroupRole.DEFAULT
# v2.5 side-cache layout: > 1 when this one-block-per-request ring group
# shares each pool block between that many requests (see
# ``CircularBufferManager.enable_slot_packing``); 1 = one pool block each.
slots_per_block: int = 1
@dataclass
@@ -1545,6 +1554,18 @@ class KVCacheConfig:
)
return tuple(block_ids[group_id] for group_id in self.transfer_group_ids)
@property
def slot_packed_group_ids(self) -> tuple[int, ...]:
"""Groups whose blocks are slots of shared pool blocks (v2.5 side-cache
layout). Their views are not one block per pool block, so whole-block
zeroing must skip them; their bytes lie inside pool blocks the ring
manager owns and that no other group writes."""
return tuple(
group_id
for group_id, group in enumerate(self.kv_cache_groups)
if group.slots_per_block > 1
)
@property
def host_group_ids(self) -> tuple[int, ...]:
return tuple(
@@ -1556,7 +1577,7 @@ class KVCacheConfig:
def num_blocks_of(self, tensor: KVCacheTensor) -> int:
"""Number of blocks addressable by the pool backing ``tensor``."""
if not tensor.host_resident:
return self.num_blocks
return self.num_blocks * tensor.slots_per_block
assert self.hisparse_host_num_blocks is not None
return self.hisparse_host_num_blocks