[Core] Remove deprecated mamba_cache_mode "all" (#58997)

Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Thomas Parnell <tpa@zurich.ibm.com>
This commit is contained in:
Jiangyun Zhu
2026-10-01 02:59:37 -07:00
committed by GitHub
co-authored by Claude Opus 5.5 Thomas Parnell
parent 08d77cad7b
commit cb6458c5ce
45 changed files with 201 additions and 1476 deletions
+38 -38
View File
@@ -39,6 +39,7 @@ from vllm.sampling_params import SamplingParams, StructuredOutputsParams
from vllm.utils.hashing import sha256
from vllm.v1.core.encoder_cache_manager import EncoderCacheManager
from vllm.v1.core.kv_cache_coordinator import HybridKVCacheCoordinator
from vllm.v1.core.kv_cache_manager import KVCacheManager
from vllm.v1.core.kv_cache_utils import get_request_block_hasher, init_none_hash
from vllm.v1.core.sched.diffusion_scheduler import (
DiffusionAsyncScheduler,
@@ -6751,7 +6752,7 @@ def _create_hybrid_mamba_connector_scheduler(
num_blocks: int = 100,
supports_divergent_hits: bool = True,
) -> Scheduler:
"""FA + Mamba ("all" cache mode) scheduler with a MockKVConnector."""
"""FA + Mamba ("align" cache mode) scheduler with a MockKVConnector."""
model_config = ModelConfig(
model="facebook/opt-125m",
trust_remote_code=True,
@@ -6772,7 +6773,7 @@ def _create_hybrid_mamba_connector_scheduler(
cache_config=CacheConfig(
block_size=block_size,
enable_prefix_caching=True,
mamba_cache_mode="all",
mamba_cache_mode="align",
),
kv_transfer_config=KVTransferConfig(
kv_connector="MockKVConnector",
@@ -6804,7 +6805,7 @@ def _create_hybrid_mamba_connector_scheduler(
block_size=block_size,
shapes=((1, 1),),
dtypes=(torch.float32,),
mamba_cache_mode="all",
mamba_cache_mode="align",
),
),
],
@@ -6820,6 +6821,33 @@ def _create_hybrid_mamba_connector_scheduler(
)
def _seed_hybrid_prefix(
manager: KVCacheManager, num_blocks: int, block_size: int
) -> tuple[list[int], list[int]]:
"""Prefill a prefix one block per step so that align-mode Mamba caches
the state at every block boundary. Returns the FA and Mamba block ids."""
[fill] = create_requests(
num_requests=1,
num_tokens=num_blocks * block_size,
max_tokens=1,
same_prompt=True,
block_size=block_size,
req_ids=["fill"],
)
computed_blocks, num_computed, _ = manager.get_computed_blocks(fill)
assert num_computed == 0
mamba_ids = []
for i in range(num_blocks):
manager.allocate_slots(
fill, block_size, new_computed_blocks=computed_blocks if i == 0 else None
)
fill.num_computed_tokens += block_size
fa_ids, group_mamba_ids = manager.get_block_ids(fill.request_id)
mamba_ids.append(group_mamba_ids[i])
manager.free(fill)
return fa_ids, mamba_ids
@pytest.mark.parametrize(
"matched_tokens,expected_num_computed",
[
@@ -6845,23 +6873,8 @@ def test_hybrid_per_group_hit_divergence_with_connector(
manager = scheduler.kv_cache_manager
assert isinstance(manager.coordinator, HybridKVCacheCoordinator)
# Seed a 4-block prefix so both groups cache all four boundaries
# (mamba cache mode "all" caches every block's state densely).
[fill] = create_requests(
num_requests=1,
num_tokens=4 * block_size,
max_tokens=1,
same_prompt=True,
block_size=block_size,
req_ids=["fill"],
)
computed_blocks, num_computed, _ = manager.get_computed_blocks(fill)
blocks = manager.allocate_slots(
fill, fill.num_tokens, num_computed, computed_blocks
)
fa_ids = [b.block_id for b in blocks.blocks[0]]
mamba_ids = [b.block_id for b in blocks.blocks[1]]
manager.free(fill)
# Seed a 4-block prefix so both groups cache all four boundaries.
fa_ids, mamba_ids = _seed_hybrid_prefix(manager, 4, block_size)
# Evict the FA tail and the middle mamba states; block 0 (both groups)
# and the deep mamba state at block 3 survive.
@@ -6885,8 +6898,8 @@ def test_hybrid_per_group_hit_divergence_with_connector(
scheduler.add_request(replay)
output = scheduler.schedule()
num_scheduled = output.num_scheduled_tokens[replay.request_id]
assert replay.num_tokens - num_scheduled == expected_num_computed
[new_req] = output.scheduled_new_reqs
assert new_req.num_computed_tokens == expected_num_computed
@pytest.mark.parametrize(
@@ -6921,20 +6934,7 @@ def test_hybrid_fa_deeper_hit_respects_connector_lookup_policy(
assert isinstance(manager.coordinator, HybridKVCacheCoordinator)
# Seed a 4-block prefix in both groups.
[fill] = create_requests(
num_requests=1,
num_tokens=4 * block_size,
max_tokens=1,
same_prompt=True,
block_size=block_size,
req_ids=["fill"],
)
computed_blocks, num_computed, _ = manager.get_computed_blocks(fill)
blocks = manager.allocate_slots(
fill, fill.num_tokens, num_computed, computed_blocks
)
mamba_ids = [b.block_id for b in blocks.blocks[1]]
manager.free(fill)
_, mamba_ids = _seed_hybrid_prefix(manager, 4, block_size)
# Keep all FA blocks; evict every mamba state but block 0. FA reaches 4
# blocks, the mamba hit only reaches 1 -> diverged (FA > Mamba).
@@ -6955,8 +6955,8 @@ def test_hybrid_fa_deeper_hit_respects_connector_lookup_policy(
scheduler.add_request(replay)
output = scheduler.schedule()
num_scheduled = output.num_scheduled_tokens[replay.request_id]
assert replay.num_tokens - num_scheduled == expected_num_computed
[new_req] = output.scheduled_new_reqs
assert new_req.num_computed_tokens == expected_num_computed
def _make_encoder_instance_request(scheduler, text_prefix=8, image_tokens=16):