vllm.model_executor.layers.mamba.ops.mamba_ssm
¶
Functions:
-
get_ssm_config_file_name–Return the JSON filename for the given kernel shape.
-
get_ssm_configs–Return tuned (BLOCK_SIZE_M, num_warps) configs for selective_state_update
-
override_ssm_config–Pin
try_get_optimal_ssm_configtoconfigfor the duration of -
selective_state_update–Argument:
-
try_get_optimal_ssm_config–Return (BLOCK_SIZE_M, num_warps) for the given kernel shape.
_canonical_cache_dtype(cache_dtype)
¶
Canonical key for config lookup. bf16 and fp16 share the same tuned configs because the kernel only sees bit width when accessing state.
_get_default_ssm_launch_config(dstate, is_blackwell)
¶
Hard-coded fallback heuristic used when no tuned config is available.
_try_get_optimal_ssm_config_cached(headdim, dstate, batch, nheads, cache_dtype, is_blackwell)
cached
¶
Cached resolution. See try_get_optimal_ssm_config.
get_ssm_config_file_name(headdim, dstate, cache_dtype, device_name)
¶
Return the JSON filename for the given kernel shape.
Layout: configs/selective_state_update/
headdim=<H>,dstate=<D>,device_name=<dev>,cache_dtype=<dt>.json.
get_ssm_configs(headdim, dstate, cache_dtype)
cached
¶
Return tuned (BLOCK_SIZE_M, num_warps) configs for selective_state_update
keyed by effective_batch = batch * nheads, or None if no config
file is found for the (headdim, dstate, cache_dtype, device) combination.
They can be generated with
benchmarks/kernels/benchmark_selective_state_update.py --save-configs
override_ssm_config(config)
¶
Pin try_get_optimal_ssm_config to config for the duration of
the context. Used by the tuning benchmark to time specific configs.
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, enable_stochastic_rounding=False, cache_philox_rounds=0)
¶
Argument: state: (batch, dim, dstate) or (batch, nheads, dim, dstate) x: (batch, dim) or (batch, nheads, dim) dt: (batch, dim) or (batch, nheads, dim) A: (dim, dstate) or (nheads, dim, dstate) B: (batch, dstate) or (batch, ngroups, dstate) C: (batch, dstate) or (batch, ngroups, dstate) D: (dim,) or (nheads, dim) z: (batch, dim) or (batch, nheads, dim) dt_bias: (dim,) or (nheads, dim) null_block_id: int if state_batch_indices is passed, lets the kernel identify padded entries that will not be processed, for example: state_batch_indices = [null_block_id, 1, 20, null_block_id] in this case, the kernel will not process entries at indices 0 and 3 out: Preallocated ssm output tensor. Assume same shape as x. In-place updated. num_accepted_tokens: (batch,) number of accepted tokens from previous verification step, tells the kernel which initial state to use cu_seqlens: (batch,) length per sequence, for variable length in speculative decoding cases
try_get_optimal_ssm_config(headdim, dstate, batch, nheads, cache_dtype, is_blackwell)
¶
Return (BLOCK_SIZE_M, num_warps) for the given kernel shape.
Tuning is keyed on effective_batch = batch * nheads (the kernel grid
scales with the product), so configs transfer across (model, TP) combos
sharing (headdim, dstate, cache_dtype).