-
Notifications
You must be signed in to change notification settings - Fork 153
[LoRA] fix: shared_experts with moe_shared_expert_overlap #1800
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
Merged
Conversation
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
`shared_experts` are not actually sharded using ETP, so we should get it excluded from `is_expert_linear`. In some modules (notably MoE shared_experts when moe_shared_expert_overlap is enabled), Megatron disables TP-related communications on the base linear layer by setting `parallel_mode=None` (TE) or `explicit_expert_comm=True` (legacy). https://github.com/NVIDIA/Megatron-LM/blob/5b1ef0703184299fbf71f6131bf2f9a5331e7238/megatron/core/transformer/moe/shared_experts.py#L95-L104 This will need some special handling on lin_out_gather_output to keep shape matches. Signed-off-by: Hollow Man <[email protected]>
yaoyu-33
reviewed
Dec 26, 2025
| adapter_name = local_param_name.removeprefix(local_base_prefix + ".adapter.").split(".")[0] | ||
| adapter = adapter[adapter_name] | ||
| input_is_parallel, _, _, _, base_linear_is_parallel = get_adapter_attributes_from_linear(to_wrap) | ||
| input_is_parallel, _, _, _, _, base_linear_is_parallel = get_adapter_attributes_from_linear(to_wrap) |
Contributor
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.
feels like should return a dict or dataclass now, since there are many things and could potentially increase in the future.
I will let this in. if you can plz file another pr, otherwise i will change next week.
yaoyu-33
approved these changes
Dec 26, 2025
Contributor
|
/ok to test d05d42d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do ?
fix
shared_expertslayers whenmoe_shared_expert_overlapis enabledChangelog
shared_expertsare not actually sharded using ETP, so we should get it excluded fromis_expert_linear.parallel_mode=None(TE) orexplicit_expert_comm=True(legacy). https://github.com/NVIDIA/Megatron-LM/blob/5b1ef0703184299fbf71f6131bf2f9a5331e7238/megatron/core/transformer/moe/shared_experts.py#L95-L104 This will need some special handling on lin_out_gather_output to keep shape matches.GitHub Actions CI
See the CI sectionin the Contributing doc for how to trigger the CI. A Nvidia developer will need to approve and trigger the CI for external contributors.
Before your PR is "Ready for review"
Pre checks:
If you haven't finished some of the above items you can still open "Draft" PR.
Additional Information
✨ Presented to you with Mind Lab - A Lab for Experiential Intelligence.