Bump FlashInfer to 0.6.15.post1 (#31927)

Co-authored-by: Brayden Zhong <b8zhong@uwaterloo.ca>
This commit is contained in:
Mohammad Miadh Angkad
2026-07-22 14:21:59 -07:00
committed by GitHub
co-authored by Brayden Zhong
parent c20c48b8fd
commit 0c29c8fece
11 changed files with 85 additions and 15 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ ARG PIP_DEFAULT_INDEX
ARG UBUNTU_MIRROR
ARG GITHUB_ARTIFACTORY=github.com
ARG INSTALL_FLASHINFER_JIT_CACHE=0
ARG FLASHINFER_VERSION=0.6.14
ARG FLASHINFER_VERSION=0.6.15.post1
ARG MOONCAKE_VERSION=0.3.11.post1
ARG MSCCLPP_VERSION=sglang-v0.9.1
#if need other arg please add in MOONCAKE_COMPILE_ARG
+1 -1
View File
@@ -31,7 +31,7 @@ dependencies = [
"einops",
"fastapi",
"flash-attn-4>=4.0.0b18",
"flashinfer_python[cu13]==0.6.14", # keep it aligned with jit-cache version in Dockerfile
"flashinfer_python[cu13]==0.6.15.post1", # keep it aligned with jit-cache version in Dockerfile
"gguf",
"helion==0.2.6",
"humming-kernels[cu13]==0.1.10",
+1 -1
View File
@@ -1304,7 +1304,7 @@ def _set_envs_and_config(server_args: ServerArgs):
if server_args.attention_backend == "flashinfer":
assert_pkg_version(
"flashinfer_python",
"0.6.14",
"0.6.15.post1",
"Please uninstall the old version and "
"reinstall the latest version by following the instructions "
"at https://docs.flashinfer.ai/installation.html.",
@@ -56,6 +56,10 @@ from sglang.srt.layers.attention.dsa.utils import (
pad_dsa_cache_seqlens,
should_use_dsa_fused_topk,
)
from sglang.srt.layers.attention.trtllm_mla_backend import (
grow_multi_ctas_kv_counter_buffer_if_needed,
make_persistent_multi_ctas_kv_counter_buffer,
)
from sglang.srt.layers.utils.cp_utils import (
cp_all_gather_rerange_output,
cp_split_and_rebuild_position,
@@ -496,8 +500,16 @@ class DeepseekSparseAttnBackend(
device=model_runner.device,
),
)
self._multi_ctas_kv_counter_buffer = (
make_persistent_multi_ctas_kv_counter_buffer(
torch.device(self.device),
self.num_q_heads,
max_batch_size=model_runner.max_running_requests,
)
)
else:
self.workspace_buffer = None
self._multi_ctas_kv_counter_buffer = None
def _make_aiter_dsa_decode_metadata_buffer(
self,
@@ -2917,6 +2929,15 @@ class DeepseekSparseAttnBackend(
batch_size = page_table_1.shape[0]
_, num_heads, head_dim = q_all.shape
self._multi_ctas_kv_counter_buffer = (
grow_multi_ctas_kv_counter_buffer_if_needed(
self._multi_ctas_kv_counter_buffer,
torch.device(self.device),
self.num_q_heads,
batch_size,
)
)
q = q_all.view(batch_size, 1, num_heads, head_dim)
kv = kv_cache.view(-1, 1, self.real_page_size, self.kv_cache_dim)
block_tables = page_table_1.unsqueeze(1)
@@ -2945,6 +2966,7 @@ class DeepseekSparseAttnBackend(
bmm1_scale=bmm1_scale,
backend="trtllm-gen",
skip_softmax_threshold_scale_factor=envs.SGLANG_SKIP_SOFTMAX_DECODE_THRESHOLD_SCALE_FACTOR.get(),
multi_ctas_kv_counter_buffer=self._multi_ctas_kv_counter_buffer,
)
return out
@@ -61,6 +61,35 @@ DEFAULT_WORKSPACE_SIZE_MB = 150 # Memory workspace size in MB
# compute the LCM with other padding constraints.
TRTLLM_BLOCK_CONSTRAINT = 128
TRTLLM_MLA_MAX_BATCH_SIZE = 8192
def _multi_ctas_kv_counter_bytes(
device: torch.device, num_q_heads: int, batch_size: int
) -> int:
sm_count = flashinfer.utils.get_device_sm_count(device)
return flashinfer.utils.get_trtllm_gen_multi_ctas_kv_counter_bytes(
batch_size, num_q_heads, sm_count
)
def make_persistent_multi_ctas_kv_counter_buffer(
device: torch.device, num_q_heads: int, max_batch_size: int
) -> torch.Tensor:
num_bytes = _multi_ctas_kv_counter_bytes(
device, num_q_heads, max(TRTLLM_MLA_MAX_BATCH_SIZE, max_batch_size)
)
return torch.zeros(num_bytes, dtype=torch.uint8, device=device)
def grow_multi_ctas_kv_counter_buffer_if_needed(
buffer: torch.Tensor, device: torch.device, num_q_heads: int, batch_size: int
) -> torch.Tensor:
required_bytes = _multi_ctas_kv_counter_bytes(device, num_q_heads, batch_size)
if buffer.numel() >= required_bytes:
return buffer
return torch.zeros(required_bytes, dtype=torch.uint8, device=device)
def _quantize_fp8_qkv(q, k, v, layer):
q = q.to(torch.float8_e4m3fn)
@@ -189,6 +218,14 @@ class TRTLLMMLABackend(FlashInferMLAAttnBackend):
),
)
self._multi_ctas_kv_counter_buffer = (
make_persistent_multi_ctas_kv_counter_buffer(
torch.device(self.device),
self.num_q_heads,
max_batch_size=model_runner.max_running_requests,
)
)
# CUDA graph state
self.decode_cuda_graph_metadata = {}
self.decode_cuda_graph_kv_indices = None
@@ -642,6 +679,10 @@ class TRTLLMMLABackend(FlashInferMLAAttnBackend):
seq_lens if seq_lens.dtype == torch.int32 else seq_lens.to(torch.int32)
)
extra_kwargs = {"backend": self.backend} if self.backend != "trtllm-gen" else {}
if self.backend == "trtllm-gen":
extra_kwargs["multi_ctas_kv_counter_buffer"] = (
self._multi_ctas_kv_counter_buffer
)
return flashinfer.decode.trtllm_batch_decode_with_kv_cache_mla(
query=query,
kv_cache=kv_cache,
@@ -222,6 +222,17 @@ def resolve_cutedsl_standard_scales(
return w1_alpha, fc2_input_scale, w2_alpha, used_input_scale
def _cutedsl_wrapper_activation_type(activation: str, activation_type_cls: Any) -> Any:
if activation == "silu":
return activation_type_cls.Swiglu
if activation == "relu2":
return activation_type_cls.Relu2
raise ValueError(
f"CuteDSL MoE wrapper supports 'silu' (gated) or 'relu2' (non-gated) "
f"activation, got {activation!r}."
)
def ensure_cutedsl_wrapper(layer: torch.nn.Module) -> None:
"""Lazily create CuteDslMoEWrapper and resolve scales on first forward.
@@ -237,7 +248,7 @@ def ensure_cutedsl_wrapper(layer: torch.nn.Module) -> None:
return
try:
from flashinfer import CuteDslMoEWrapper
from flashinfer import ActivationType, CuteDslMoEWrapper
except ImportError as e:
raise ImportError(
"flashinfer_cutedsl backend requires FlashInfer with CuteDSL support. "
@@ -284,7 +295,9 @@ def ensure_cutedsl_wrapper(layer: torch.nn.Module) -> None:
local_expert_offset=layer.moe_ep_rank * layer.num_local_experts,
output_dtype=layer.moe_runner_config.params_dtype,
device=str(layer.w13_weight.device),
activation=layer.moe_runner_config.activation,
activation_type=_cutedsl_wrapper_activation_type(
layer.moe_runner_config.activation, ActivationType
),
)
w1_alpha, fc2_input_scale, w2_alpha, used_input_scale = (
-8
View File
@@ -461,14 +461,6 @@ class MoEGate(nn.Module):
"quark",
):
correction_bias_dtype = torch.bfloat16
# NOTE(kpham-sgl): flashinfer trtllm routing requires a bf16
# routing_bias; an fp32 bias yields NaN routing on exact ties.
# Mirror the fp8 path's cast.
if (
quant_config.get_name() == "modelopt_fp4"
and get_moe_runner_backend().is_flashinfer_trtllm()
):
correction_bias_dtype = torch.bfloat16
self.e_score_correction_bias = nn.Parameter(
torch.empty((config.n_routed_experts), dtype=correction_bias_dtype)
)
+1 -1
View File
@@ -1911,7 +1911,7 @@ def check_pkg_version_at_least(pkg: str, min_version: str) -> bool:
Args:
pkg: Package name (distribution name, e.g., "flashinfer-python")
min_version: Minimum version required (e.g., "0.6.14")
min_version: Minimum version required (e.g., "0.6.15.post1")
Returns:
True if package is installed and version >= min_version, False otherwise
@@ -354,6 +354,7 @@ class DSAMockModelRunner(ModelRunner):
triton_attention_split_tile_size=None,
)
self.server_args = self._server_args_override.install()
self.max_running_requests = pool_batch_size
self.req_to_token_pool = ReqToTokenPool(
size=pool_batch_size,
max_context_len=max_context_len,
@@ -282,6 +282,7 @@ class MockMLAModelRunner(ModelRunner):
triton_attention_split_tile_size=None,
)
self.server_args = self._server_args_override.install()
self.max_running_requests = pool_batch_size
self.req_to_token_pool = ReqToTokenPool(
size=pool_batch_size,
max_context_len=max_context_len,
@@ -21,7 +21,7 @@ class TestGLM52NVFP4TPMTP(
model = "nvidia/GLM-5.2-NVFP4"
tp_size = 4
mem_fraction_static = 0.8
bs_1_speed_thres = 250
bs_1_speed_thres = 280
extra_server_args = [
"--moe-runner-backend",
"flashinfer_trtllm",