fix(mtp): rename MTP submodule transformer_layer -> mtp_model_layer#54
Open
Zhichenzzz wants to merge 1 commit into
Open
fix(mtp): rename MTP submodule transformer_layer -> mtp_model_layer#54Zhichenzzz wants to merge 1 commit into
Zhichenzzz wants to merge 1 commit into
Conversation
Align the MTP submodule attribute name with upstream Megatron-LM, which renamed MultiTokenPredictionLayer.transformer_layer to mtp_model_layer. Updates the submodule spec field and all consumers (schedules, cuda graphs, fine-grained callables, schedule plan, layer specs).
Zhichenzzz
force-pushed
the
fix/1289-mtp-naming
branch
from
June 18, 2026 21:39
5a01ba3 to
d4f926b
Compare
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
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.
Problem
This fork names the MTP inner module
self.transformer_layer, but megatron-bridge registers all MTP weight mappings undermtp_model_layer. Somegatron_to_hf_lookupreturnsNonefor every MTP param →'NoneType' object has no attribute 'megatron_module'on bridge checkpoint load, and... has no attribute 'param_weight'on export (Qwen3.6-27B GDN). Upstream NVIDIA renamedtransformer_layer→mtp_model_layer; this fork is the outlier.Fix
Rename the MTP instance attribute
self.transformer_layer→self.mtp_model_layerinMultiTokenPredictionLayer(the ModuleSpec field name is unchanged). This makes the live param names match the bridge.Renaming the live param names breaks miles' raw (non-bridge) converters that key on the old name. The paired miles PR updates them (qwen3_5.py / qwen3_next.py / update_weight/common.py). These two PRs must be merged together.
Validation
Real megatron-bridge Qwen3.5
mapping_registry.megatron_to_hf_lookup: all 8 MTP param types flip fromNone(oldtransformer_layer) to a resolved mapping (QKV/Auto/GatedMLPMapping) under the newmtp_model_layername.Fixes radixark/miles#1289
Update: full upstream alignment + e2e validation
Upstream Megatron-LM renamed the whole MTP naming chain, not just the module attribute. This PR now tracks all of it:
MultiTokenPredictionLayerSubmodules.transformer_layer→mtp_model_layer(dataclass field)get_mtp_layer_spec(transformer_layer_spec)/get_mtp_layer_spec_for_backend(...)→mtp_model_layer_spec(kwarg; only in-tree call siteget_gpt_mtp_block_specupdated)self.transformer_layer→self.mtp_model_layer(module attribute — checkpoint param names derive from this)pipeline_parallel/schedules.py(set_current_microbatchraised AttributeError with MTP enabled),cuda_graphs.py,fine_grained_callables.py,model_chunk_schedule_plan.pyImpact / compatibility notes for reviewers:
mtp.layers.N.mtp_model_layer.*.qwen35_vl_bridge,deepseek/common.py) are fixed by this PR — they were silently broken before (load_hf_weightscrashed withNoneType has no attribute megatron_moduleonmtp.layers.0.transformer_layer.*).e2e validated:
load_hf_weights0 missing / 0 "No mapping found", geo3k RL steptrain_rollout_logprob_abs_diff=0.0129, reward 0.46 (and a separate 200-step run with the attribute rename: reward 0.17→0.95+, abs_diff flat 0.013–0.020).set_current_microbatchpasses (crashed before the consumer fix).