Repository navigation
fix(checkpoint): preserve target weight shard args - #7028
Merged
dimapihtar merged 2 commits intoSep 22, 2026
Merged
dimapihtar merged 2 commits into
dimapihtar merged 2 commits into
Conversation
svcnvidia-nemo-ci
marked this pull request as draft
September 1, 2026 17:30
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:
See the contribution guide for more details. |
Signed-off-by: jbernloehr <jbernloehr@nvidia.com>
janbernloehr
force-pushed
the
jbernloehr/fix-checkpoint-converter-target-shard-args
branch
from
September 1, 2026 19:18
00e7b32 to
662913e
Compare
janbernloehr
marked this pull request as ready for review
September 2, 2026 12:22
dimapihtar
self-requested a review
September 8, 2026 08:10
dimapihtar
approved these changes
Sep 8, 2026
Contributor
|
/ok to test 2087449 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/35772172319 |
xuwchen
pushed a commit
to xuwchen/Megatron-LM
that referenced
this pull request
Oct 14, 2026
Signed-off-by: jbernloehr <jbernloehr@nvidia.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> (cherry picked from commit 07708e2) Signed-off-by: xuwenc <xuwenc@nvidia.com>
xuwchen
pushed a commit
to xuwchen/Megatron-LM
that referenced
this pull request
Oct 14, 2026
Signed-off-by: jbernloehr <jbernloehr@nvidia.com> Co-authored-by: Dmytro Pykhtar <37850217+dimapihtar@users.noreply.github.com> (cherry picked from commit 07708e2) Signed-off-by: xuwenc <xuwenc@nvidia.com>
This branch was previously deployed
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.
What does this PR do?
Prevents source checkpoint metadata from overwriting weight-shard and GTP-remat arguments derived from the converter's target parallelism.
Background
MegatronCheckpointSaverBase._load_checkpoint_argscopies arguments recorded inthe source checkpoint onto the target saver arguments unless their names appear
in
args_to_keep.This is appropriate for model properties such as layer counts, but not for
arguments derived from the requested target parallelism. The converter already
preserves values such as:
tensor_model_parallel_size;pipeline_model_parallel_size;expert_model_parallel_size.core_v0.19.0added four related arguments thatvalidate_argsderives throughresolve_tensor_parallel_weight_shards:tensor_parallel_num_weight_shards;gtp_weight_remat_size;expert_tensor_parallel_num_weight_shards;expert_gtp_weight_remat_size.These arguments were not added to
args_to_keep.For an HF source model represented with TP=1 and a requested conversion target
of TP=4, the saver therefore performs the following sequence:
_load_checkpoint_argsreplaces it with the source checkpoint's value of 1;validate_args;The forked saver then aborts with:
Changes
This PR adds the four target-derived arguments to
args_to_keep:The target values are consequently retained until
validate_argsderives theirfinal values from the requested target parallelism.
Other source checkpoint arguments continue to be inherited as before.
A focused unit test verifies both sides of this behavior:
num_layers) is still inherited from thesource metadata.
Reproduction
Reproduced with
core_v0.19.0and confirmed to remain present onmain.Use a source checkpoint whose recorded tensor parallelism is 1 and request a
target tensor parallel size greater than 1:
The converter runs the loader in its main process and forks a separate saver
process. Once the independent process-group initialization failure from #6989
is fixed, the saver reaches:
The significant values are:
The converter is explicitly re-sharding to
--target-tensor-parallel-size 4. It exposes no separate target GTP-remat flag,so the source checkpoint's derived value must not override the value derived
from the target configuration.
The preceding loader failure is addressed by the companion PR:
Validation
Focused regression coverage
Added:
The test constructs source and target argument namespaces with deliberately
different values:
After
_load_checkpoint_args:Local preparation checks completed successfully:
The complete pytest suite was not run in the local preparation environment
because that Python environment does not contain PyTorch. CI should execute the
new unit test in the normal project test environment.
End-to-end conversion
The end-to-end validation included the companion process-group fix because the
loader otherwise aborts before the saver reaches this code.
With both changes applied, the original TP=4/PP=2/EP=1 conversion completes:
The saver argument output shows the intended separation:
There is no longer an
Overwriting defaultmessage for any of the fourtarget-derived arguments.
The generated checkpoint subsequently loads at TP=4/PP=2 and evaluation
completes successfully:
No source model revision, target parallelism, or converter parameters were
changed to obtain the successful result.
Scope
This PR intentionally does not:
resolve_tensor_parallel_weight_shardsderives its values;Issue tracking
Related to #6989.
Contribution process
Pre-checks
Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate review.