Skip to content

fix: allow mtp_num_layers=0 with overlap_moe_expert_parallel_comm#5912

Queued
cuichenx wants to merge 2 commits into
NVIDIA:mainfrom
cuichenx:chcui/mtp-overlap-allow-zero-layers
Queued

fix: allow mtp_num_layers=0 with overlap_moe_expert_parallel_comm#5912
cuichenx wants to merge 2 commits into
NVIDIA:mainfrom
cuichenx:chcui/mtp-overlap-allow-zero-layers

Conversation

@cuichenx

Copy link
Copy Markdown
Contributor

What

Accept mtp_num_layers == 0 in the overlap_moe_expert_parallel_comm validation inside TransformerConfig.__post_init__, alongside the existing None and 1:

assert self.mtp_num_layers in (None, 0, 1), (
    'MTP supports at most one layer when enabling overlap_moe_expert_parallel_comm.'
)

Why

mtp_num_layers == 0 is semantically identical to None — both mean no multi-token-prediction layers — and is equally compatible with expert-parallel communication overlap. The previous check (is None or == 1) rejected 0, so any config that explicitly defaults mtp_num_layers to 0 (rather than None) fails configuration validation at finalize time when overlap_moe_expert_parallel_comm is enabled, even though the model has no MTP layers.

This surfaced with hybrid/MoE providers whose mtp_num_layers field defaults to 0: enabling MoE expert-parallel comm overlap raised AssertionError: MTP layernum only supports 1 ... during __post_init__, blocking otherwise-valid runs. The downstream Megatron-Bridge project already relaxed its equivalent guard; this brings the Megatron-Core check in line so 0 is handled at the source.

Change

  • Widen the allowed set from {None, 1} to {None, 0, 1}.
  • No behavior change for None/1; >= 2 still (correctly) fails.

🤖 Generated with Claude Code

The MoE expert-parallel communication overlap validation in
TransformerConfig.__post_init__ rejected mtp_num_layers=0, only accepting
None or 1. Zero MTP layers is semantically identical to None (no
multi-token-prediction) and is equally compatible with expert-parallel
comm overlap, so it should not fail configuration validation.

Providers that explicitly default mtp_num_layers to 0 (e.g. hybrid/GPT-OSS
style configs) currently fail at config finalize when
overlap_moe_expert_parallel_comm is enabled, even though the model has no
MTP layers. Accept 0 alongside None and 1.

Signed-off-by: Chen Cui <chcui@nvidia.com>
@cuichenx
cuichenx requested review from a team as code owners July 20, 2026 21:16
@svcnvidia-nemo-ci
svcnvidia-nemo-ci marked this pull request as draft July 20, 2026 21:17
@github-actions

Copy link
Copy Markdown
Contributor

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:

  1. Add the oncall reviewer (optional reviewer)
  2. Add required review teams based on your changes

See the contribution guide for more details.

@copy-pr-bot

copy-pr-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

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.

Signed-off-by: Chen Cui <chcui@nvidia.com>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Final Review PR is in the "final review" stage label Jul 20, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added Approved All necessary approvals have been made and removed Final Review PR is in the "final review" stage labels Jul 20, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29851153570

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 21, 2026
@Phlip79
Phlip79 added this pull request to the merge queue Jul 22, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29881500076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved All necessary approvals have been made complexity: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants