[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
+1
View File
@@ -866,6 +866,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
kernel_block_sizes=self.kernel_block_sizes,
static_forward_context=self.compilation_config.static_forward_context,
num_blocks=self.kv_cache_config.num_blocks,
skip_kv_cache_group_ids=self.kv_cache_config.slot_packed_group_ids,
)
@torch.inference_mode()
+1
View File
@@ -1149,6 +1149,7 @@ class GPUModelRunner(
runner_only_attn_layers=self.runner_only_attn_layers,
static_forward_context=self.compilation_config.static_forward_context,
num_blocks=self.kv_cache_config.num_blocks,
skip_kv_cache_group_ids=self.kv_cache_config.slot_packed_group_ids,
)
def _zero_block_ids(self, block_ids: list[int]) -> None:
+11
View File
@@ -138,6 +138,7 @@ class KVBlockZeroer:
static_forward_context: dict[str, Any],
num_blocks: int,
runner_only_attn_layers: set[str] | None = None,
skip_kv_cache_group_ids: Iterable[int] = (),
) -> None:
"""Precompute the absolute-address table for the Triton zeroing kernel.
@@ -156,6 +157,13 @@ class KVBlockZeroer:
physical block stride and zeroed page span remain independent.
Only AttentionSpec layers are processed; Mamba layers are skipped.
``skip_kv_cache_group_ids`` (v2.5 side-cache layout): slot-packed ring
groups, whose views hold several slots per pool block. Their claims
never enter whole-block zeroing (the ring-tag path clears their tag words instead),
and with one view block per pool block their pages sat inside the
first attention page, so skipping them leaves the zeroed bytes of
every block unchanged.
"""
self.device = device
# Bounds-guard instrumentation: pool bound for the guard in _zero_kv_blocks_kernel.
@@ -174,12 +182,15 @@ class KVBlockZeroer:
seg_block_strides: list[int] = []
seg_page_sizes: list[int] = []
skip_group_ids = set(skip_kv_cache_group_ids)
for group in attn_groups_iter:
spec = group.kv_cache_spec
if not isinstance(spec, AttentionSpec):
continue
if group.kv_cache_group_id >= len(kernel_block_sizes):
continue
if group.kv_cache_group_id in skip_group_ids:
continue
kernel_bs = kernel_block_sizes[group.kv_cache_group_id]
assert spec.block_size % kernel_bs == 0
for layer_name in group.layer_names: