From 3031091c36982478fcb694c3215cb03e9874c551 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 1 Oct 2026 11:53:05 -0400 Subject: [PATCH] [Kimi-K3] Guard optimized paths by platform (#40269) Co-authored-by: Alex Nails --- python/sglang/srt/layers/attn_residual.py | 4 ++-- python/sglang/srt/models/kimi_k3.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/layers/attn_residual.py b/python/sglang/srt/layers/attn_residual.py index 50add4e7d6..e31114719d 100644 --- a/python/sglang/srt/layers/attn_residual.py +++ b/python/sglang/srt/layers/attn_residual.py @@ -24,7 +24,7 @@ import triton.language as tl from sglang.srt.layers.layernorm import RMSNorm from sglang.srt.layers.linear import ReplicatedLinear -from sglang.srt.utils import is_hip, is_npu +from sglang.srt.utils import is_cuda, is_hip, is_npu _BLOCK_H: int = 1024 # H = 7168 = 7 x 1024 _MAX_ROWS: int = 16 # next_pow2(8 + 1), K3 has <= 8 snapshots @@ -43,7 +43,7 @@ def _use_fast(hidden_size: int) -> bool: """The TMA kernel needs SM100+ except SM12x (tcgen05, cp.async.bulk) and its H=7168 template; everything else takes the triton pipeline.""" global _FAST_SUPPORTED - if is_npu(): + if not is_cuda(): return False if _FAST_SUPPORTED is None: _FAST_SUPPORTED = _supports_attn_res_tma(torch.cuda.get_device_capability()) diff --git a/python/sglang/srt/models/kimi_k3.py b/python/sglang/srt/models/kimi_k3.py index a858db8176..be3c49e418 100644 --- a/python/sglang/srt/models/kimi_k3.py +++ b/python/sglang/srt/models/kimi_k3.py @@ -704,11 +704,11 @@ class KimiK3MoE(nn.Module): """ if not self.use_latent_moe: return - # These merged layouts feed CUDA-only fused front kernels. Keeping the + # These merged layouts feed CUDA and ROCm fused front kernels. Keeping the # regular parameters on other devices avoids a large transient copy # during post-load processing and leaves their native kernels in # control of weight layout. - if _is_npu: + if not (get_platform().is_cuda or get_platform().is_hip): return if self.shared_experts is not None and get_moe_a2a_backend().is_none(): mods = [