[Kernel] Add support for Flashinfer Mamba SSU algorithm selection (#50157)

Signed-off-by: amitz-nv <203509407+amitz-nv@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
amitz-nv
2026-08-04 09:40:23 -07:00
committed by GitHub
co-authored by OpenAI Codex
parent 7ac2ec7582
commit 52c0e3cb08
4 changed files with 88 additions and 5 deletions
+28 -1
View File
@@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from enum import Enum, EnumMeta
from typing import Any
from typing import Any, Literal, get_args
from pydantic import field_validator
@@ -30,6 +30,9 @@ class MambaBackendEnum(Enum, metaclass=_MambaBackendEnumMeta):
CPU = "cpu"
MambaSSUAlgorithm = Literal["auto", "simple", "vertical", "horizontal"]
@config
class MambaConfig:
"""Configuration for Mamba SSM backends."""
@@ -46,6 +49,12 @@ class MambaConfig:
generation. 0 uses the Triton default. Higher values improve randomness
quality at the cost of compute."""
ssu_algorithm: MambaSSUAlgorithm | None = None
"""Selective state update algorithm to use with the FlashInfer backend.
None defaults to FlashInfer's "auto" algorithm. Forced algorithms must
be supported by FlashInfer for the active GPU, state dtype, and decoding
mode."""
@field_validator("backend", mode="before")
@classmethod
def validate_backend_before(cls, value: Any) -> Any:
@@ -54,7 +63,25 @@ class MambaConfig:
return MambaBackendEnum[value.upper()]
return value
def validate_ssu_algorithm(self) -> None:
if self.ssu_algorithm is None:
return
valid_algorithms = get_args(MambaSSUAlgorithm)
if self.ssu_algorithm not in valid_algorithms:
valid = ", ".join(valid_algorithms)
raise ValueError(
f"Unknown Mamba SSU algorithm: '{self.ssu_algorithm}'. "
f"Valid options are: {valid}"
)
if self.backend != MambaBackendEnum.FLASHINFER:
raise ValueError(
"Mamba SSU algorithm selection is only supported with the "
"FlashInfer backend. Please set `--mamba-backend flashinfer`, "
"or omit `--mamba-ssu-algorithm`."
)
def __post_init__(self):
self.validate_ssu_algorithm()
if self.enable_stochastic_rounding:
from vllm.platforms import current_platform