[Core] Add MRV2 virtual-batch PCP for MLA (#46570)

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: Matthew Bonanni <mbonanni@redhat.com>
This commit is contained in:
Lucas Wilkinson
2026-07-19 02:53:15 +00:00
committed by GitHub
co-authored by Codex OpenAI Codex Matthew Bonanni
parent 9243e0124e
commit b6ff8a2f50
39 changed files with 1204 additions and 196 deletions
-2
View File
@@ -472,8 +472,6 @@ class UnitaryKVCacheCoordinator(KVCacheCoordinator):
self.pcp_world_size = pcp_world_size
if dcp_world_size > 1:
self.block_size *= dcp_world_size
if pcp_world_size > 1:
self.block_size *= pcp_world_size
# For models using only Mamba, block_size is set to max_model_len when
# prefix caching is disabled, and hash_block_size validation is skipped.
assert not enable_caching or (hash_block_size == self.block_size), (
+5 -6
View File
@@ -631,8 +631,8 @@ def resolve_kv_cache_block_sizes(
- ``scheduler_block_size`` is the token-alignment invariant used by the
scheduler (e.g. for ``num_computed_tokens`` rounding). Single group:
``cache_config.block_size * dcp * pcp``. Multiple groups: LCM of every
group's effective block size. Attention groups are scaled by DCP/PCP;
``cache_config.block_size * dcp``. Multiple groups: LCM of every
group's effective block size. Attention groups are scaled by DCP;
Mamba groups keep their full per-rank state and are not scaled.
- ``hash_block_size`` is the granularity at which ``Request.block_hashes``
is computed. Single group: equals scheduler block size. Multiple groups:
@@ -644,15 +644,14 @@ def resolve_kv_cache_block_sizes(
"""
cache_config = vllm_config.cache_config
dcp = vllm_config.parallel_config.decode_context_parallel_size
pcp = vllm_config.parallel_config.prefill_context_parallel_size
groups = kv_cache_config.kv_cache_groups
if len(groups) <= 1: # Single group: block_size * dcp * pcp
bs = cache_config.block_size * dcp * pcp
if len(groups) <= 1:
bs = cache_config.block_size * dcp
return bs, bs
group_block_sizes = [
g.kv_cache_spec.block_size * dcp * pcp
g.kv_cache_spec.block_size * dcp
if isinstance(g.kv_cache_spec, AttentionSpec)
else g.kv_cache_spec.block_size
for g in groups
+1 -1
View File
@@ -271,7 +271,7 @@ class Scheduler(SchedulerInterface):
log_stats=self.log_stats,
enable_kv_cache_events=self.enable_kv_cache_events,
dcp_world_size=self.dcp_world_size,
pcp_world_size=self.pcp_world_size,
pcp_world_size=1,
scheduler_block_size=self.block_size,
hash_block_size=hash_block_size,
metrics_collector=self.kv_metrics_collector,
+6 -6
View File
@@ -75,8 +75,8 @@ class SingleTypeKVCacheManager(ABC):
self.block_size = kv_cache_spec.block_size
self.dcp_world_size = dcp_world_size
self.pcp_world_size = pcp_world_size
if dcp_world_size * pcp_world_size > 1:
self.block_size *= dcp_world_size * pcp_world_size
if dcp_world_size > 1:
self.block_size *= dcp_world_size
self.kv_cache_spec = kv_cache_spec
self.block_pool = block_pool
self.enable_caching = enable_caching
@@ -674,10 +674,10 @@ class FullAttentionManager(SingleTypeKVCacheManager):
"and chunked local attention groups"
)
block_size = kv_cache_spec.block_size
if dcp_world_size * pcp_world_size > 1:
# DCP/PCP shard each block's KV across ranks; hashes must be
# viewed at the sharded (scaled) block size.
block_size *= dcp_world_size * pcp_world_size
if dcp_world_size > 1:
# DCP shards each block's KV across ranks; hashes must be viewed at
# the sharded block size.
block_size *= dcp_world_size
block_hashes = resolve_block_hashes(
block_hashes,
block_pool.hash_block_size,