[Core][Mamba] Remove leftovers of mamba_cache_mode="all" (#60043)

Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Signed-off-by: Jiangyun Zhu <zhujiangyun@inferact.ai>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Jiangyun Zhu
2026-10-13 00:58:59 -07:00
committed by GitHub
co-authored by Claude Opus 5.5 mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent bc3ddb198a
commit 2cc2e68d1c
33 changed files with 161 additions and 344 deletions
+58 -16
View File
@@ -49,6 +49,7 @@ from vllm.v1.kv_cache_interface import (
FullAttentionSpec,
KVCacheConfig,
KVCacheGroupSpec,
KVCacheSpec,
KVCacheTensor,
MambaSpec,
SlidingWindowSpec,
@@ -2355,8 +2356,6 @@ def _make_hybrid_attention_mamba_scheduler(
enable_kv_cache_events: bool = False,
) -> SchedulerFixture:
"""Build a scheduler for one attention group plus one Mamba group."""
scheduler_block_size = scheduler_block_size or block_size
hash_block_size = hash_block_size or block_size
attention_spec = FullAttentionSpec(
block_size=attention_block_size,
num_kv_heads=NUM_KV_HEADS,
@@ -2369,9 +2368,38 @@ def _make_hybrid_attention_mamba_scheduler(
dtypes=(torch.float32,),
mamba_cache_mode=mamba_cache_mode,
)
return _make_two_group_scheduler(
attention_spec,
("mamba", mamba_spec),
num_cpu_blocks=num_cpu_blocks,
num_gpu_blocks=num_gpu_blocks,
scheduler_block_size=scheduler_block_size or block_size,
hash_block_size=hash_block_size or block_size,
dcp_world_size=dcp_world_size,
lazy=lazy,
mamba_cache_mode=mamba_cache_mode,
enable_kv_cache_events=enable_kv_cache_events,
)
def _make_two_group_scheduler(
attention_spec: FullAttentionSpec,
second_group: tuple[str, KVCacheSpec],
*,
num_cpu_blocks: int,
num_gpu_blocks: int,
scheduler_block_size: int,
hash_block_size: int,
dcp_world_size: int,
lazy: bool = False,
mamba_cache_mode: MambaCacheMode = "align",
enable_kv_cache_events: bool = False,
) -> SchedulerFixture:
"""Build a scheduler for one attention group plus one named second group."""
second_name, second_spec = second_group
groups = [
KVCacheGroupSpec(["attention"], attention_spec),
KVCacheGroupSpec(["mamba"], mamba_spec),
KVCacheGroupSpec([second_name], second_spec),
]
tensors = [
KVCacheTensor(
@@ -2380,7 +2408,7 @@ def _make_hybrid_attention_mamba_scheduler(
layer_stride=spec.page_size_bytes * num_gpu_blocks,
block_stride=spec.page_size_bytes,
)
for group, spec in zip(groups, (attention_spec, mamba_spec))
for group, spec in zip(groups, (attention_spec, second_spec))
]
kv_cache_config = KVCacheConfig(
num_blocks=num_gpu_blocks,
@@ -2428,34 +2456,48 @@ def test_hybrid_store_uses_resolved_group_block_sizes() -> None:
silently offloads only a fraction of them.
"""
attention_block_size = BLOCK_SIZE
mamba_block_size = 4 * BLOCK_SIZE
replicated_block_size = 4 * BLOCK_SIZE
dcp_world_size = 2
fix = _make_hybrid_attention_mamba_scheduler(
fix = _make_two_group_scheduler(
FullAttentionSpec(
block_size=attention_block_size,
num_kv_heads=NUM_KV_HEADS,
head_size=HEAD_SIZE,
dtype=DTYPE,
),
(
"replicated_attention",
FullAttentionSpec(
block_size=replicated_block_size,
num_kv_heads=NUM_KV_HEADS,
head_size=HEAD_SIZE,
dtype=DTYPE,
dcp_sharded=False,
),
),
num_cpu_blocks=32,
num_gpu_blocks=32,
attention_block_size=attention_block_size,
block_size=mamba_block_size,
scheduler_block_size=replicated_block_size,
# Every prefix-cacheable group's resolved block size must be a multiple
# of the hash block, so it cannot exceed the smallest of them.
hash_block_size=BLOCK_SIZE,
dcp_world_size=dcp_world_size,
mamba_cache_mode="none",
)
sched = fix.scheduler
gpu_pool = fix.gpu_block_pool
attention_size, mamba_size = sched.group_block_sizes
attention_size, replicated_size = sched.group_block_sizes
assert attention_size == attention_block_size * dcp_world_size
assert mamba_size == mamba_block_size
assert replicated_size == replicated_block_size
confirmed = 2 * sched.block_size
req = _make_cp_request(num_blocks=8, virtual_block_size=BLOCK_SIZE)
attention_blocks = _allocate_cp_gpu_blocks(
gpu_pool, req, confirmed // attention_size, attention_size, group_id=0
)
mamba_blocks = _allocate_cp_gpu_blocks(
gpu_pool, req, confirmed // mamba_size, mamba_size, group_id=1
replicated_blocks = _allocate_cp_gpu_blocks(
gpu_pool, req, confirmed // replicated_size, replicated_size, group_id=1
)
kv_blocks = KVCacheBlocks(blocks=(attention_blocks, mamba_blocks))
kv_blocks = KVCacheBlocks(blocks=(attention_blocks, replicated_blocks))
sched.update_state_after_alloc(req, kv_blocks, num_external_tokens=0)
sched.build_connector_meta(
make_scheduler_output(
@@ -2476,11 +2518,11 @@ def test_hybrid_store_uses_resolved_group_block_sizes() -> None:
# count.
assert sched._reqs_to_store[req.request_id].num_stored_blocks == [
confirmed // attention_size,
confirmed // mamba_size,
confirmed // replicated_size,
]
assert set(meta.store_gpu_blocks) == {
*(b.block_id for b in attention_blocks),
*(b.block_id for b in mamba_blocks),
*(b.block_id for b in replicated_blocks),
}