[Kimi-K3] Guard optimized paths by platform (#40269)
Co-authored-by: Alex Nails <alex.nails@radixark.ai>
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user