fix(fsdp): recognize legacy GDN TP metadata - #4664
Conversation
966d3b8 to
26e76ec
Compare
GDN conv1d parameters use Megatron's legacy tensor_model_parallel and partition_dim attributes. The FSDP DTensor checkpoint splitter copies those attributes to meta tensors before calling make_fsdp_dtensor, but the FSDP TP detection path only handled _tensor_parallel_mode. Honor the legacy metadata so split GDN checkpoint tensors keep the TP placement and validate against the full FSDP plus TP mesh. Add regression coverage for copied legacy TP attributes and replicated attributes. Fixes NVIDIA#4553. Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com>
26e76ec to
5bd5fec
Compare
|
/ok to test e7c49ea |
|
/ok to test 118a63e |
|
@Glitchfix FYI don't rebase on |
gotcha, will be careful for upcoming PRs |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/25686839039 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/25693763037 |
Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com> Co-authored-by: Cory Ye <44509866+cspades@users.noreply.github.com> Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com> Co-authored-by: Cory Ye <44509866+cspades@users.noreply.github.com> Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com> Co-authored-by: Cory Ye <44509866+cspades@users.noreply.github.com>
Signed-off-by: Shivanjan Chakravorty <shivanjanc@nvidia.com> Co-authored-by: Cory Ye <44509866+cspades@users.noreply.github.com> Signed-off-by: Dmytro Pykhtar <dpykhtar@nvidia.com>
What does this PR do ?
Fix Megatron-FSDP DTensor checkpoint saving for GDN fused tensors whose copied meta tensors only carry legacy Megatron tensor-parallel metadata.
GDN conv1d parameters are annotated with
tensor_model_parallelandpartition_dim.handle_gdn_in_state_dict()copies those attributes to meta tensors before callingmake_fsdp_dtensor(), but the FSDP tensor-parallel detection path only recognized_tensor_parallel_mode. This could make split GDN checkpoint tensors lose their TP placement and validate against a DP-only mesh.This change makes Megatron-FSDP recognize the legacy TP attributes documented by
make_fsdp_dtensor().Issue tracking
Linked issue: Fixes #4553
Validation
tools/autoformat.shviauv run --with black --with isort --with pylint --with ruff --with mypy tools/autoformat.shblack,isort,pylint, andruffpassed; no files were modified.mypyreported environment missing-import/type issues in the checked files, and the script ignores mypy failures by design.pytest -q tests/unit_tests/transformer/test_fsdp_dtensor_checkpoint.py(58 passed)git diff --checkContribution process
Pre-checks