assertactivationinself.act_to_impl,f"{activation} is not supported."
assertnotapply_router_weight_on_input
topk_weights,topk_ids=select_experts(
hidden_states=x,
router_logits=router_logits,
use_grouped_topk=use_grouped_topk,
top_k=top_k,
renormalize=renormalize,
topk_group=topk_group,
num_expert_group=num_expert_group,
custom_routing_function=custom_routing_function,
scoring_func=scoring_func,
routed_scaling_factor=routed_scaling_factor,
e_score_correction_bias=e_score_correction_bias,
output=cpu_fused_moe(
input,
layer.w13_weight,
layer.w2_weight,
getattr(layer,"w13_bias",None),
getattr(layer,"w2_bias",None),
topk_weights,
topk_ids,
activation,
self.isa,
)
returnoutput
# Ref code from https://github.com/sgl-project/sglang/blob/716e682721397df103f347d22da8bd46c6016dab/python/sglang/srt/layers/moe/fused_moe_native.py#L53
# Ref code from https://github.com/sgl-project/sglang/blob/716e682721397df103f347d22da8bd46c6016dab/python/sglang/srt/layers/moe/fused_moe_native.py#L53