Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def apply_tp(
gate_out = gate_out.cast("float32")
if fc1_latent_proj is not None:
x = fc1_latent_proj(x)
gate_out, topk_weights, topk_idx = get_moe_scores(
gate_out, _, __ = get_moe_scores(

This comment was marked as outdated.

gate_out,
layer.n_group,
layer.topk_group,
Expand All @@ -458,11 +458,6 @@ def apply_tp(
use_fused_cast=use_fused,
)

if layer.routed_scaling_factor_learnable:
safe_topk_indices = paddle.clip(topk_idx, min=0)
gathered_scales = F.embedding(safe_topk_indices, layer.per_expert_scale.unsqueeze(1)).squeeze(-1)
topk_weights = topk_weights * gathered_scales

(
permute_input,
token_nums_per_expert,
Expand All @@ -484,6 +479,12 @@ def apply_tp(
self.moe_quant_type,
topk_only_mode=True,
)

if layer.routed_scaling_factor_learnable:
safe_topk_indices = paddle.clip(topk_idx, min=0)
gathered_scales = F.embedding(safe_topk_indices, layer.per_expert_scale.unsqueeze(1)).squeeze(-1)
topk_weights = topk_weights * gathered_scales
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 MoE 多后端同步检查

当前修复只涉及 fused_moe_cutlass_backend.py,但 FastDeploy 存在多个 MoE backend 实现(fused_moe_deepgemm_backend.pyfused_moe_triton_backend.pyfused_moe_marlin_backend.py 等)。若这些 backend 中也存在类似的 routed_scaling_factor_learnable 逻辑,且同样放在 get_moe_scores 之后(而非 moe_expert_dispatch 之后),则可能存在相同 bug,建议排查并同步修复。


else:
gate_out = gate_out.cast("float32")
if fc1_latent_proj is not None:
Expand Down
Loading