[MoE Refactor] Separate Router into OO Classes (#30623)

Signed-off-by: Bill Nell <bnell@redhat.com>
This commit is contained in:
bnellnm
2026-01-18 11:40:49 -05:00
committed by GitHub
parent 2f03035a61
commit 327a02d8db
45 changed files with 1750 additions and 684 deletions
@@ -201,6 +201,7 @@ class Ernie4_5_MoeMoE(nn.Module):
e_score_correction_bias=self.gate.e_score_correction_bias,
enable_eplb=self.enable_eplb,
num_redundant_experts=self.n_redundant_experts,
router_logits_dtype=torch.float32,
)
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
@@ -269,6 +269,7 @@ class Ernie4_5_VLMoeMoE(nn.Module):
quant_config=quant_config,
e_score_correction_bias=self.e_score_correction_bias[0],
prefix=f"{prefix}.text_experts",
router_logits_dtype=torch.float32,
)
else:
self.text_experts = Ernie4_5_VLMoeMLP(
@@ -306,6 +307,7 @@ class Ernie4_5_VLMoeMoE(nn.Module):
quant_config=quant_config,
e_score_correction_bias=self.e_score_correction_bias[1],
prefix=f"{prefix}.vision_experts",
router_logits_dtype=torch.float32,
)
else:
self.vision_experts = Ernie4_5_VLMoeMLP(