-
Notifications
You must be signed in to change notification settings - Fork 582
Fix muon moe dimension numbers #4843
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
Open
parsley9877
wants to merge
2
commits into
main
Choose a base branch
from
fix-muon-moe-dimension-numbers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27
−4
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,11 @@ def test_scale_is_excluded(self): | |
| def test_bias_is_excluded(self): | ||
| self.assertIsNone(muon_utils.transform_logic(("decoder", "dense", "bias"))) | ||
|
|
||
| def test_bias_variant_is_excluded(self): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you help explain a little bit why those bias to be excluded? or add a comment there? Also, for a model/config, are you consider all bias? for instance, wondering why GptOss only excludes wo_bias? |
||
| self.assertIsNone(muon_utils.transform_logic(("decoder", "moe_block", "wi_0_bias"))) | ||
| self.assertIsNone(muon_utils.transform_logic(("decoder", "GptOssMlp", "wo_bias"))) | ||
| self.assertIsNone(muon_utils.transform_logic(("decoder", "mlp", "mlp_bias"))) | ||
|
|
||
| def test_embedding_is_excluded(self): | ||
| self.assertIsNone(muon_utils.transform_logic(("token_embedder", "embedding"))) | ||
|
|
||
|
|
@@ -69,9 +74,27 @@ def test_moe_wi_1_uses_last_two_axes(self): | |
| def test_moe_wo_uses_last_two_axes(self): | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "MoeBlock_0", "wo")), mdn((-2,), (-1,))) | ||
|
|
||
| def test_moe_prefused_wi_uses_last_two_axes(self): | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "MoeBlock_0", "wi")), mdn((-2,), (-1,))) | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "routed_experts", "wi")), mdn((-2,), (-1,))) | ||
|
|
||
| def test_qwen3_next_moe_routed_experts(self): | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "mlp", "routed_experts", "wi_0")), mdn((-2,), (-1,))) | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "mlp", "routed_experts", "wi_1")), mdn((-2,), (-1,))) | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "mlp", "routed_experts", "wo")), mdn((-2,), (-1,))) | ||
|
|
||
| def test_qwen3_moe_block(self): | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "moe_block", "wi_0")), mdn((-2,), (-1,))) | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "moe_block", "wo")), mdn((-2,), (-1,))) | ||
|
|
||
| def test_gpt_oss_mlp_moe(self): | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "GptOssMlp", "wi_0")), mdn((-2,), (-1,))) | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "GptOssMlp", "wo")), mdn((-2,), (-1,))) | ||
|
|
||
| def test_moe_gate_falls_through_to_standard(self): | ||
| # 'gate' is inside MoeBlock_0 but not one of (wi_0, wi_1, wo) → standard. | ||
| # 'gate' is inside MoeBlock_0 but not one of (wi, wi_0, wi_1, wo) → standard. | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "MoeBlock_0", "gate", "kernel")), mdn((0,), (-1,))) | ||
| self.assertEqual(muon_utils.transform_logic(("decoder", "routed_experts", "gate", "kernel")), mdn((0,), (-1,))) | ||
|
|
||
| # --- 2.2 Self-attention --- | ||
| def test_self_attention_out_projection(self): | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🟢 Low: Extracting the MoE block names and expert kernel names into variables improves code readability and makes it easier to extend with other MoE architectures in the future.