[MoE Refactor] Separate Router into OO Classes (#30623)
Signed-off-by: Bill Nell <bnell@redhat.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user