[CPU][Llama4] Fix Llama4 MoE inputs with "apply_router_weight_on_input" (#7889)
This commit is contained in:
@@ -344,9 +344,12 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, CustomOp):
|
||||
) -> torch.Tensor:
|
||||
assert activation == "silu", f"activation = {activation} is not supported."
|
||||
|
||||
if use_intel_amx_backend(layer) and not apply_router_weight_on_input:
|
||||
if use_intel_amx_backend(layer):
|
||||
|
||||
from sglang.srt.layers.moe.topk import select_experts
|
||||
from sglang.srt.layers.moe.topk import (
|
||||
select_experts,
|
||||
apply_topk_weights_cpu,
|
||||
)
|
||||
|
||||
topk_weights, topk_ids = select_experts(
|
||||
hidden_states=x,
|
||||
@@ -361,8 +364,10 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, CustomOp):
|
||||
correction_bias=correction_bias,
|
||||
routed_scaling_factor=routed_scaling_factor,
|
||||
)
|
||||
x, topk_weights = apply_topk_weights_cpu(
|
||||
apply_router_weight_on_input, topk_weights, x
|
||||
)
|
||||
|
||||
# TODO: support apply_router_weight_on_input in the fused_experts_cpu kernel
|
||||
return torch.ops.sgl_kernel.fused_experts_cpu(
|
||||
x,
|
||||
layer.w13_weight,
|
||||
|
||||
Reference in New Issue
Block a user