Skip to content

vllm.model_executor.layers.mamba.abstract

Classes:

  • MambaBase –

    Base class for Mamba-like layers which support the v1 engine.

Functions:

MambaBase

Bases: AttentionLayerBase

Base class for Mamba-like layers which support the v1 engine. Inherit from this class if you implement a custom layer.

Methods:

bind_kv_cache(kv_cache)

Unpack a raw [B, 1, 1, C] int8 page view into per-state views.

Each block's C bytes hold the layer's states (e.g. conv, ssm) packed by dtype/shape with the layer's state alignment.

get_attn_backend()

Get the attention backend class for this Mamba layer.

get_cache_checkpoint_alignment()

Token alignment of the prefill checkpoint offsets this layer can export from inside a single forward pass, or None if it cannot.

Serves as the single source of truth for hybrid block alignment, MambaManager.Params, and MambaPrefillCheckpointBuilder.

get_state_shape() abstractmethod

Defines the shape of the state. For mamba layers this is usually a (conv_state, ssm_state) tuple. In this case, returns (conv_state_shape, ssm_state_shape).

get_kv_cache_checkpoint_alignment(vllm_config)

Model-wide prefill checkpoint alignment shared by every Mamba KV cache group and metadata builder, or None if prefix caching is disabled or any Mamba layer cannot export internal checkpoints.

get_mamba_num_speculative_blocks(vllm_config)

State blocks each request reserves for draft tokens.

get_mamba_prefill_checkpoint_alignment(vllm_config)

LCM of all Mamba layers' prefill checkpoint alignments.

Returns None when prefix caching is disabled, when no Mamba layers are registered, or when any Mamba layer cannot export internal prefill checkpoints: the scheduler takes internal checkpoints only when every Mamba group can export them.

get_mamba_prefill_checkpoint_grid(vllm_config, alignment=None)

Token grid every Mamba layer keeps its prefill checkpoint offsets on.

Prefix-cache boundaries, made multiples of the layers' checkpoint alignment (the platform already keeps blocks on it). The scheduler checks offsets against one alignment, so every Mamba spec must use this one.