-
Notifications
You must be signed in to change notification settings - Fork 31.3k
[Ernie 4.5 Moe] Fix routing, weights, and update expectations
#42653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| mapping["ernie4_5_moe"] += [ | ||
| WeightRenaming("mlp.moe_statics.e_score_correction_bias", "mlp.gate.moe_statics.e_score_correction_bias") | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This weight was missing
| router_logits = F.linear(hidden_states.float(), self.weight) | ||
| router_logits = F.softmax(router_logits, dim=1, dtype=torch.float) | ||
| router_top_value, router_indices = torch.topk(self.moe_statics(router_logits), self.top_k, dim=-1) | ||
| router_top_value = router_top_value / torch.clamp( | ||
| router_top_value.sum(dim=-1, keepdim=True), min=self.norm_min | ||
| routing_weights = F.softmax(router_logits, dim=1, dtype=torch.float) | ||
| _, selected_experts = torch.topk(self.moe_statics(routing_weights), self.top_k, dim=-1) | ||
| routing_weights = torch.gather(routing_weights, dim=-1, index=selected_experts) | ||
| routing_weights = routing_weights / torch.clamp( | ||
| routing_weights.sum(dim=-1, keepdim=True), min=self.norm_min | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core where I messed up previously. Now generations are similar again. I could also generate same outputs with VL using this change.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
ArthurZucker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 😢
| @slow | ||
| def test_model_21b_a3b_generation(self): | ||
| EXPECTED_TEXT_COMPLETION = "User: Hey, are you conscious? Can you talk to me?\nAssistant: I don't have consciousness in the way humans do. I'm a text-based AI created to process and generate responses based on patterns in data." # fmt: skip | ||
| EXPECTED_TEXT_COMPLETION = "User: Hey, are you conscious? Can you talk to me?\nAssistant: \nI don't have consciousness in the way humans do. I don't feel emotions, have thoughts, or experience awareness. However, I'm" # fmt: skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a fast test for this one as well as we seem to break it often
|
[For maintainers] Suggested jobs to run (before merge) run-slow: ernie4_5_moe |
As per title, discovered during ernie vl