add pad-aware swiglu limit kernel (#48287)

Signed-off-by: gnovack <novackgm@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
gnovack
2026-07-13 16:48:19 -07:00
committed by GitHub
co-authored by mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent fec64fea75
commit 21472f32ea
4 changed files with 140 additions and 4 deletions
@@ -73,6 +73,7 @@ def _fused_marlin_moe(
num_tokens_post_padded: torch.Tensor,
activation: MoEActivation = MoEActivation.SILU,
activation_func: Callable[..., None] = apply_moe_activation,
topk_ids: torch.Tensor | None = None,
input_global_scale1: torch.Tensor | None = None,
input_global_scale2: torch.Tensor | None = None,
global_scale1: torch.Tensor | None = None,
@@ -168,6 +169,8 @@ def _fused_marlin_moe(
clamp_limit=clamp_limit,
alpha=gemm1_alpha,
beta=gemm1_beta,
topk_ids=topk_ids,
expert_map=expert_map,
)
if output is None:
@@ -346,6 +349,7 @@ def fused_marlin_moe(
w1_scale=w1_scale,
w2_scale=w2_scale,
topk_weights=topk_weights,
topk_ids=topk_ids,
num_topk=topk,
quant_type=quant_type,
apply_router_weight_on_input=apply_router_weight_on_input,
@@ -827,6 +831,8 @@ class MarlinExperts(LoRAExpertsMixin, MarlinExpertsBase):
clamp_limit: float | None = None,
alpha: float = 1.0,
beta: float = 0.0,
topk_ids: torch.Tensor | None = None,
expert_map: torch.Tensor | None = None,
) -> None:
# act_input = intermediate_cache1 (M*topk, 2N for gated)
# act_output = intermediate_cache2 (M*topk, N)
@@ -863,6 +869,8 @@ class MarlinExperts(LoRAExpertsMixin, MarlinExpertsBase):
clamp_limit=clamp_limit,
alpha=alpha,
beta=beta,
topk_ids=topk_ids,
expert_map=expert_map,
)
lora_state["cache2"] = act_output