[ckpt] fix: support vocab padding with Megatron-FSDP TP - #5353
Merged
Conversation
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
yaoyu-33
marked this pull request as ready for review
August 5, 2026 21:54
Contributor
|
LGTM. The fix is correct. expect_dim0_size now accounts for DTensor.shape being the global shape across TP ranks in the Megatron-FSDP path, while a regular Megatron parameter stores only its local TP shard and still needs multiplication by tp_size. This matches the existing DTensor output_shape handling that uses orig_param.shape below it, and the global-size chunk along dim 0 produces per-rank shards matching each local shape. The new FSDP_TP2 parametrization gives the TP>1 path real coverage now that the Megatron-LM dependency is available. No logic concerns, no typos, and no perf configs are touched. Suggested test cases:
No perf tests impacted. |
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.
Summary
DTensorRoot cause
DTensor.shapealready describes the global tensor across TP ranks. The vocabulary-padding path multiplied that dimension bytp_sizeagain, so a TP=2 import padded a 151,936-token embedding to 303,872 rows and scattered 151,936 rows to a local 75,968-row buffer.This fixes the regression introduced by #1473 and tracked internally as NVBug 6565261.
Validation
expected (75968, 1024), got (151936, 1024).uv run --no-sync python -m pytest tests/functional_tests/test_groups/converter/test_hf_fsdp_conversion.py -k FSDP_TP2 -v -s— 1 passeduv run pre-commit run --all-files— passed