Fix expert weight broadcasting (wt.item() for scalar multiply)
This commit is contained in:
@@ -572,7 +572,7 @@ def moe_forward(x, w, li, cfg, token_id, device):
|
||||
# Weighted combine + scaling
|
||||
routed_out = torch.zeros_like(x)
|
||||
for i, (out, wt) in enumerate(zip(expert_outputs, expert_weights)):
|
||||
routed_out = routed_out + (out.float() * wt).bfloat16()
|
||||
routed_out = routed_out + (out.float() * wt.item()).bfloat16()
|
||||
routed_out = (routed_out.float() * routed_scaling).bfloat16()
|
||||
|
||||
# ---- Shared expert ----
|
||||
|
||||
@@ -215,7 +215,7 @@ def main():
|
||||
|
||||
routed_out = torch.zeros_like(x_ffn_normed)
|
||||
for i, (out, wt) in enumerate(zip(expert_outputs, expert_weights)):
|
||||
routed_out = routed_out + (out.float() * wt).bfloat16()
|
||||
routed_out = routed_out + (out.float() * wt.item()).bfloat16()
|
||||
routed_out = (routed_out.float() * routed_scaling).bfloat16()
|
||||
|
||||
# Shared expert
|
||||
|
||||
Reference in New Issue
Block a user