Repository navigation
refactor(model): build Qwen2 and MiMo from builder-backed model configs #6379
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
kamran-nvidia
wants to merge
3
commits into
main
Choose a base branch
from
kjafarisadeg/qwen2-mimo-model-config
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.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
c08dcf4
refactor(model): build Qwen2 from a builder-backed model config
kamran-nvidia 098c1bf
refactor(model): build MiMo from a builder-backed model config
kamran-nvidia 96e9e4d
refactor(model): opt the migrated families into builder-backed model …
kamran-nvidia 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
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
Oops, something went wrong.
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.
Tied embeddings with PP > 1 lose the conversion tie flag
Enabling the builder path here changes where
share_embeddings_and_output_weightslives: it is on the outerBridgeGPTModelConfig, while the runtime model's.configis only the nestedTransformerConfig. However,build_conversion_tasks()reads that nested config, and_share_embeddings_and_output_weights()defaults the missing field toFalse.For a tied Qwen2/2.5 checkpoint at PP > 1, the last pipeline stage materializes
output_layer.weight. Conversion therefore keeps that parameter and requestslm_head.weight, which is absent from a deduplicated tied HF checkpoint. The post-import embedding broadcast reads the same missing flag and is also skipped. The provider path retained the flag in.config. PP=1 avoids the duplicate output parameter, so TP2-only checks do not cover this case.Could we make the shared conversion helpers resolve the tie flag from the runtime model or outer model config, and add a tied-checkpoint PP2 import/export regression that checks the output-stage weights and synchronization? This also affects HF initialization for training through
load_hf_weights().This finding is based on the pinned builder/conversion code and source-level probes; I have not run a distributed checkpoint reproduction.
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.
Thanks, confirmed. A tied tiny Qwen2 at PP=2 through the builder path fails on this branch with
ValueError: Hugging Face checkpoint is missing mapped parameter(s): output_layer.weight -> lm_head.weight. Tied Qwen3 fails the same way on currentmain, since #6365 moved Qwen3 conversion to the builder.The shared fix is in #6460:
_share_embeddings_and_output_weights()now takes the unwrapped model. It keeps readingmodel.configwhen the config declares the flag, so the provider path and VLM wrappers are unchanged, and otherwise falls back to the flag Megatron Core stores on the built language model. With it, tied Qwen2 at PP=2 has a last-stageoutput_layer.weightequal to the HFembed_tokens, and the export reproduces all 50 HF tensors exactly with nolm_head.weight. #6460 also adds a tied PP=2 builder-path functional test (Qwen3, L0). I'll rebase this PR onto it once it merges.