fix(moe): broadcast padding mask for expert bias counts - #6114
Conversation
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/32448314334 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/32448469206 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/32448485669 |
Signed-off-by: Chen Cui <chcui@nvidia.com> Co-authored-by: Jared Casper <155158+jaredcasper@users.noreply.github.com> Signed-off-by: Dmytro Pykhtar <dpykhtar@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com> Co-authored-by: Jared Casper <155158+jaredcasper@users.noreply.github.com> Signed-off-by: Kezhi Kong <kezhik@kezhik-mlt.client.nvidia.com>
What does this PR do?
Fixes the MoE expert-bias update so it broadcasts the flattened padding mask across the expert dimension, preventing a shape mismatch when
num_tokens != num_experts.Root cause
The expert-bias update combined a routing map shaped
[num_tokens, num_experts]with a flattened padding mask shaped[num_tokens]. PyTorch aligns that mask with the expert dimension, so the operation fails whenevernum_tokens != num_experts.Expanding the mask to
[num_tokens, 1]gives the intended per-token broadcast and excludes padded assignments fromlocal_tokens_per_expert.Changes
num_tokens != num_experts.Validation
TestTop2Routerclass: 23 passed, 2 skipped.git diff --check.Issue tracking
Linked issue: Fixes #6111
Related PRs
Contribution process
Pre-checks
Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.