Add fully_shard_optimizer for mixed-precision FSDP - #5411
Merged
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
wujingyue
force-pushed
the
fsdp/optimizer
branch
from
June 21, 2026 16:27
197e933 to
892c425
Compare
wujingyue
force-pushed
the
fsdp/optimizer
branch
from
June 21, 2026 16:28
892c425 to
cd74492
Compare
wujingyue
force-pushed
the
fsdp/optimizer
branch
3 times, most recently
from
June 21, 2026 22:56
7ff1865 to
de0e0cf
Compare
wujingyue
marked this pull request as ready for review
June 21, 2026 23:15
wujingyue
force-pushed
the
fsdp/optimizer
branch
from
June 21, 2026 23:19
3d22a5b to
fcef1cb
Compare
wujingyue
force-pushed
the
fsdp/optimizer
branch
from
June 21, 2026 23:21
fcef1cb to
0ce3e3a
Compare
wujingyue
force-pushed
the
fsdp/optimizer
branch
from
June 21, 2026 23:24
0ce3e3a to
a853630
Compare
wujingyue
force-pushed
the
fsdp/optimizer
branch
from
June 27, 2026 06:20
0135f4a to
5fe7996
Compare
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
deepakn94
approved these changes
Jul 16, 2026
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29785947399 |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29787467984 |
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
fully_shard_optimizer(optimizer)and export it for the experimentalfully_shardpath.torch.optim.Adamfails on the mismatch without adaptationFusedAdamaccepts mismatched grads and updates parametersfully_shard_optimizercovers Adam mixed-precision stepping through the adapterNotes
DistributedOptimizeris intentionally not used for the MFSDP v2 test. Withuse_megatron_fsdp=True, it delegates to the wrapped optimizer for this path; withFalse, it expects the older_ParamAndGradBuffersetup rather than v2FsdpParameterGroup/DBufferstate.main_weighttomodel_weightfrom a post-step hook. This PR keeps the current per-microbatch sync behavior.Testing
BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.shuv run --no-sync python -m torch.distributed.run --nproc-per-node 1 -m pytest -q tests/unit_tests/distributed/megatron_fsdp/test_optimizer.py --capture=fd --tb=short --disable-warnings -rN(2 passed)uv run --no-sync python -m torch.distributed.run --nproc-per-node 2 -m pytest -q tests/unit_tests/distributed/megatron_fsdp/test_optimizer.py --capture=fd --tb=short --disable-warnings -rN(2 passedon each rank)uv run --no-sync python -m torch.distributed.run --nproc-per-node 2 -m pytest -q tests/unit_tests/distributed/megatron_fsdp/test_experimental_fully_shard.py -k "adam or optimizer" --capture=fd --tb=short --disable-warnings -rN(2 passed, 8 deselectedon each rank)