[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:
co-authored by
Claude Opus 5.5
Thomas Parnell
parent
08d77cad7b
commit
cb6458c5ce
@@ -33,16 +33,14 @@ EngineId = str
|
||||
BlockIds = tuple[list[int], ...] | list[list[int]]
|
||||
|
||||
|
||||
def clip_ssm_state_blocks(
|
||||
blocks: list[int], num_spec_blocks: int, positional: bool
|
||||
) -> list[int]:
|
||||
"""Drop speculative scratch slots, retaining position-indexed or running state."""
|
||||
def clip_ssm_state_blocks(blocks: list[int], num_spec_blocks: int) -> list[int]:
|
||||
"""Drop speculative scratch slots and keep only the running-state slot."""
|
||||
if not blocks:
|
||||
return blocks
|
||||
# Keep at least the running-state slot, even before scratch allocation.
|
||||
if num_scratch := min(num_spec_blocks, len(blocks) - 1):
|
||||
blocks = blocks[:-num_scratch]
|
||||
return blocks if positional else blocks[-1:]
|
||||
return blocks[-1:]
|
||||
|
||||
|
||||
def get_kv_connector_cache_layout(vllm_config: VllmConfig | None = None):
|
||||
|
||||
@@ -450,13 +450,6 @@ def _validate_hybrid_speculation(vllm_config: VllmConfig) -> None:
|
||||
"MoRIIO hybrid READ supports DSpark speculative decoding only, got "
|
||||
f"method={speculative_config.method!r}"
|
||||
)
|
||||
if vllm_config.cache_config.mamba_cache_mode == "all":
|
||||
# Positional allocation counts lookahead, so its local tail can exceed
|
||||
# the single running-state block supported by hybrid READ.
|
||||
raise MoRIIOError(
|
||||
"MoRIIO hybrid READ does not support DSpark with "
|
||||
"mamba_cache_mode='all'; use 'align'"
|
||||
)
|
||||
|
||||
|
||||
def _validate_mamba_specs(specs: Collection[MambaSpec]) -> MambaSpec | None:
|
||||
@@ -521,11 +514,6 @@ class MoRIIOConnectorScheduler:
|
||||
"MoRIIO hybrid (mamba/KDA) transfer is implemented for READ "
|
||||
"mode only; set kv_connector_extra_config.read_mode=true"
|
||||
)
|
||||
# Only "all" mode keeps a state per block position; the other modes keep
|
||||
# a single running state in the last slot.
|
||||
self._ssm_state_slots_are_positional = (
|
||||
vllm_config.cache_config.mamba_cache_mode == "all"
|
||||
)
|
||||
self._num_ssm_scratch_blocks = (
|
||||
mamba_spec.num_speculative_blocks if mamba_spec is not None else 0
|
||||
)
|
||||
@@ -1288,8 +1276,8 @@ class MoRIIOConnectorScheduler:
|
||||
"""Select transferable attention and Mamba block groups.
|
||||
|
||||
The wire payload stores the attention group first, followed by every
|
||||
Mamba group in transfer-group order. Outside ``mamba_cache_mode="all"``,
|
||||
only each group's running-state slot is transferred.
|
||||
Mamba group in transfer-group order. Only each group's running-state
|
||||
slot is transferred.
|
||||
"""
|
||||
if not block_ids:
|
||||
return [], []
|
||||
@@ -1301,7 +1289,6 @@ class MoRIIOConnectorScheduler:
|
||||
clip_ssm_state_blocks(
|
||||
list(transfer_block_ids[group_id]),
|
||||
self._num_ssm_scratch_blocks,
|
||||
self._ssm_state_slots_are_positional,
|
||||
)
|
||||
for group_id in self._mamba_group_ids
|
||||
]
|
||||
|
||||
@@ -154,11 +154,6 @@ class NixlBaseConnectorScheduler:
|
||||
else None
|
||||
for g in kv_cache_config.transfer_groups
|
||||
]
|
||||
# Only "all" mode keeps a state per block position; the other modes
|
||||
# keep a single running state in the last non-speculative slot.
|
||||
self._ssm_state_slots_are_positional = (
|
||||
vllm_config.cache_config.mamba_cache_mode == "all"
|
||||
)
|
||||
|
||||
# Threshold to decide whether to compute kv cache locally
|
||||
# or pull from a remote node: minimum number of remote
|
||||
@@ -258,11 +253,9 @@ class NixlBaseConnectorScheduler:
|
||||
out-of-window blocks only prior to the `request_finished_all_groups`
|
||||
hook.
|
||||
|
||||
SSM groups keep only their state-bearing slots: the trailing
|
||||
speculative scratch slots always go, and in single-state cache modes
|
||||
so does everything before the running state (null placeholders and
|
||||
the previous step's superseded state). "all" mode keeps its remaining
|
||||
slots, which the worker pairs position-wise.
|
||||
SSM groups keep only their state-bearing slot: the trailing
|
||||
speculative scratch slots and everything before the running state
|
||||
(null placeholders and the previous step's superseded state) go.
|
||||
|
||||
Use this at every block-id exchange point. Pass ``clip_ssm=False``
|
||||
for per-step partial lists (host-buffer save), where the SSM strip
|
||||
@@ -289,9 +282,7 @@ class NixlBaseConnectorScheduler:
|
||||
and blocks
|
||||
and (n_spec_blocks := self._ssm_spec_blocks[i]) is not None
|
||||
):
|
||||
blocks = clip_ssm_state_blocks(
|
||||
blocks, n_spec_blocks, self._ssm_state_slots_are_positional
|
||||
)
|
||||
blocks = clip_ssm_state_blocks(blocks, n_spec_blocks)
|
||||
clipped.append(blocks)
|
||||
return tuple(clipped)
|
||||
|
||||
|
||||
@@ -3510,13 +3510,12 @@ class NixlBaseConnectorWorker:
|
||||
if _is_ssm_spec(self._group_spec_types[i]):
|
||||
if num_decode_blocks == num_prefill_blocks:
|
||||
continue
|
||||
# Only state-bearing slots reach here, single-state modes
|
||||
# just one (see get_exchange_clipped_blocks), so differing
|
||||
# counts mean position-indexed "all"-mode lists. A longer
|
||||
# prefill list carries earlier positions the decode side
|
||||
# already has (prefix hit) -> take its tail; a longer decode
|
||||
# list holds the position D recomputes itself, which gets
|
||||
# no prefill state.
|
||||
# Only state-bearing slots reach here, normally just one
|
||||
# (see get_exchange_clipped_blocks). A longer prefill list
|
||||
# carries earlier positions the decode side already has
|
||||
# (prefix hit) -> take its tail; a longer decode list holds
|
||||
# the position D recomputes itself, which gets no prefill
|
||||
# state.
|
||||
assert num_decode_blocks - num_prefill_blocks <= 1, (
|
||||
f"Group {i}: unpairable SSM state slots, "
|
||||
f"decode={num_decode_blocks} prefill={num_prefill_blocks}"
|
||||
|
||||
@@ -156,7 +156,7 @@ def resolve_mamba_align_size(
|
||||
"""Scan all KV cache groups in *spec* and return the single mamba alignment
|
||||
size, or None if no group requires mamba alignment.
|
||||
|
||||
For MambaSpec groups in "align" or "all" cache mode the hit window must be
|
||||
For MambaSpec groups in "align" cache mode the hit window must be
|
||||
rounded down to a multiple of the offloaded chunk size. Asserts that all
|
||||
such groups agree on the same value.
|
||||
"""
|
||||
@@ -164,10 +164,7 @@ def resolve_mamba_align_size(
|
||||
for group in spec.config.groups:
|
||||
tokens_per_block = group.tokens_per_block
|
||||
kv_spec = kv_cache_config.kv_cache_groups[group.group_id].kv_cache_spec
|
||||
if isinstance(kv_spec, MambaSpec) and kv_spec.mamba_cache_mode in (
|
||||
"align",
|
||||
"all",
|
||||
):
|
||||
if isinstance(kv_spec, MambaSpec) and kv_spec.mamba_cache_mode == "align":
|
||||
tokens_per_chunk = tokens_per_block * spec.blocks_per_chunk
|
||||
assert mamba_align_size is None or mamba_align_size == tokens_per_chunk
|
||||
mamba_align_size = tokens_per_chunk
|
||||
|
||||
Reference in New Issue
Block a user