vllm.model_executor.layers.mamba.ops.ssu_dispatch
¶
Dispatch module for Mamba selective state update (SSU) backends.
Provides a unified selective_state_update function that dispatches to
the Triton, FlashInfer, or CPU backend based on the configured
MambaBackendEnum. On CPU-only platforms (PowerPC, x86 without CUDA)
the backend defaults to 'cpu'.
Classes:
-
CPUSSUBackend–CPU SSU backend using the compiled C++ VSX/scalar kernel.
-
FlashInferSSUBackend–FlashInfer-based SSU backend.
-
MambaSSUBackend–Abstract base class for Mamba SSU backends.
-
TritonSSUBackend–Triton-based SSU backend (vLLM's default).
Functions:
-
flashinfer_replayssm_autotune_supported–Return True when FlashInfer exposes ReplaySSM autotuning.
-
get_mamba_ssu_backend–Get the current Mamba SSU backend. Raises if not initialized.
-
get_replayssm_align_block_size–plan_replayssm_decodealignment for a Mamba group with prefix caching. -
initialize_mamba_ssu_backend–Initialize the Mamba SSU backend and optional FlashInfer ReplaySSM.
-
plan_replayssm_decode–Plan one Triton ReplaySSM standard-decode step on the GPU.
-
selective_state_update–Unified dispatch for Mamba selective state update.
-
selective_state_update_replayssm_flashinfer–Run FlashInfer checkpointing SSU with model-owned tracker metadata.
CPUSSUBackend
¶
Bases: MambaSSUBackend
CPU SSU backend using the compiled C++ VSX/scalar kernel.
On CPU-only platforms (PowerPC, x86 without CUDA) this dispatches to
the vectorized C++ kernel registered as torch.ops._C.selective_state_update_cpu.
That kernel uses vec_op SIMD intrinsics (VSX on ppc64le, AVX2 on x86,
scalar fallback elsewhere) and is parallelised with OpenMP across heads.
Falls back to the pure-PyTorch implementation only if the C++ op is unavailable (e.g. a CPU-less build).
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
FlashInferSSUBackend
¶
Bases: MambaSSUBackend
FlashInfer-based SSU backend.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
MambaSSUBackend
¶
Bases: ABC
Abstract base class for Mamba SSU backends.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
TritonSSUBackend
¶
Bases: MambaSSUBackend
Triton-based SSU backend (vLLM's default).
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
flashinfer_replayssm_autotune_supported()
cached
¶
Return True when FlashInfer exposes ReplaySSM autotuning.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
get_mamba_ssu_backend()
¶
Get the current Mamba SSU backend. Raises if not initialized.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
get_replayssm_align_block_size(cache_config, block_size)
¶
plan_replayssm_decode alignment for a Mamba group with prefix caching.
A prefix-cache hit may resume a request at any prefix match unit inside a Mamba block, as a one-token decode in a copied block whose ring counter belongs to another request. Restarting the ring on every unit makes that step start from the exact cached state; with a unit that is a multiple of the ring length this adds no flushes.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
initialize_mamba_ssu_backend(mamba_config, kv_cache_config, *, use_replayssm=False)
¶
Initialize the Mamba SSU backend and optional FlashInfer ReplaySSM.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
plan_replayssm_decode(ring_pos, state_batch_indices, write_pos, is_flush, buffer_len, seq_lens=None, align_block_size=0, pad_slot_id=NULL_BLOCK_ID)
¶
Plan one Triton ReplaySSM standard-decode step on the GPU.
ring_pos[slot] counts the tokens buffered since the slot's last
full-state write. For each decode row this writes the step's
write_pos/is_flush (read by every layer of the cache group) and
advances the slot's counter, so the runner supplies no ring metadata.
Prefill resets the counters in the same layer.
With align_block_size > 0 (prefix caching, see
get_replayssm_align_block_size), the ring restarts at the first step of
every align_block_size tokens and flushes on the step completing them;
seq_lens must then hold each row's sequence length.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
selective_state_update(state, x, dt, A, B, C, D, dt_bias, z=None, dt_softplus=False, state_batch_indices=None, dst_state_batch_indices=None, null_block_id=NULL_BLOCK_ID, out=None, num_accepted_tokens=None, cu_seqlens=None, is_blackwell=False)
¶
Unified dispatch for Mamba selective state update.
Delegates to the initialized backend (Triton or FlashInfer).
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
selective_state_update_replayssm_flashinfer(state, x, dt, A, B, C, out, x_cache, B_cache, dt_cache, ring_start, prev_num_accepted_tokens, D=None, dt_bias=None, dt_softplus=False, state_batch_indices=None, null_block_id=NULL_BLOCK_ID, scratch=None, enable_stochastic_rounding=False, stochastic_rounding_philox_rounds=0, rand_seed=None, cu_seqlens=None, max_seqlen=None, enable_pdl=False)
¶
Run FlashInfer checkpointing SSU with model-owned tracker metadata.
With stochastic rounding, rand_seed is a one-element int64 CUDA tensor
refreshed by the caller each step; without one, a seed is drawn here.
Source code in vllm/model_executor/layers/mamba/ops/ssu_dispatch.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |