[Kernel] Add swap AB optimization to fused_moe_kernel (#36559)

Signed-off-by: Xin Yang <xyangx@amazon.com>
This commit is contained in:
Xin Yang
2026-06-25 01:44:30 +00:00
committed by GitHub
parent 9e88e969c0
commit 1273a8f05a
2 changed files with 59 additions and 14 deletions
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import functools
from math import prod
import torch
@@ -446,3 +447,12 @@ def swiglu_limit_func(
up = torch.clamp(up, min=-swiglu_limit, max=swiglu_limit)
output.copy_(F.silu(gate) * up)
@functools.lru_cache
def enable_swap_ab(BLOCK_SIZE_M: int, BLOCK_SIZE_N: int) -> bool:
return (
current_platform.is_device_capability(90)
and BLOCK_SIZE_M < 64
and BLOCK_SIZE_N >= 64
)