[NPU] Acc fix for afmoe model introduced by topk refactor. (#31280)
This commit is contained in:
@@ -233,9 +233,7 @@ class AfmoeMoE(nn.Module):
|
|||||||
expert_bias=self.expert_bias,
|
expert_bias=self.expert_bias,
|
||||||
)
|
)
|
||||||
|
|
||||||
renormalize = (
|
renormalize = self.route_norm if self.score_func == "sigmoid" else False
|
||||||
self.route_norm if self.score_func == "sigmoid" and not _is_npu else False
|
|
||||||
)
|
|
||||||
self.topk = TopK(
|
self.topk = TopK(
|
||||||
top_k=self.top_k,
|
top_k=self.top_k,
|
||||||
renormalize=renormalize,
|
renormalize=renormalize,
|
||||||
@@ -245,7 +243,14 @@ class AfmoeMoE(nn.Module):
|
|||||||
custom_routing_function=custom_routing_fn,
|
custom_routing_function=custom_routing_fn,
|
||||||
correction_bias=correction_bias,
|
correction_bias=correction_bias,
|
||||||
routed_scaling_factor=self.route_scale,
|
routed_scaling_factor=self.route_scale,
|
||||||
**({"scoring_func": self.score_func} if _is_npu else {}),
|
**(
|
||||||
|
{
|
||||||
|
"scoring_func": self.score_func,
|
||||||
|
"apply_routed_scaling_factor_on_output": True,
|
||||||
|
}
|
||||||
|
if _is_npu
|
||||||
|
else {}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def pack_params(self) -> None:
|
def pack_params(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user