fix(fsdp): preserve already-sharded embedding units - #3936
Open
yuhezhang-ai wants to merge 5 commits into
Open
yuhezhang-ai wants to merge 5 commits into
yuhezhang-ai wants to merge 5 commits into
Conversation
Signed-off-by: Yuhe Zhang <yuhez@nvidia.com>
Contributor
Author
|
/ok to test 1ef407a |
Signed-off-by: Yuhe Zhang <yuhez@nvidia.com>
Contributor
Author
|
/ok to test 2b748d0 |
Signed-off-by: Yuhe Zhang <yuhez@nvidia.com>
Contributor
Author
|
/ok to test 4202c82 |
This branch was successfully 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?
Fix LLaDA initialization failing with a duplicate
fully_shardassertion onFSDPEmbedding.Our LLaDA recipe uses
GSAI-ML/LLaDA-8B-Base, whose checkpoint configuration setsweight_tying: false. Its separate input embedding and output projection are stored in aModuleDict. Recursive FSDP sharding wraps them before the separate embedding pass introduced in #3708. Skip modules that are already FSDP units so the embedding pass does not wrap them again.Reject distinct tied input/output modules when either is inside a
ModuleListorModuleDict, including descendants. This check runs before recursive wrapping can replace their shared parameter and silently break the tie. Ordinary tied tables outside those containers remain allowed, as does a single module registered once and returned by both embedding getters.If LLaDA's optional
weight_tying=Truemode is explicitly enabled, itstie_weights()registers the same module under bothwteandff_out. That duplicate-registration layout still fails inside recursive sharding on both main and this PR and remains outside this fix. Our shipped LLaDA recipe does not enable that mode.Changelog
modelto the embedding helper. Leave both recursive sharding implementations unchanged; no additional ownership parameter is needed.reshard_after_forward=Truecan cause an extra head all-gather for a container-hosted head; the fused loss handles the sharded weight correctly.Validation
4202c825a999c43466e3cfeb018594b7da9d4d1b.git diff --checkpassed.2b748d032cdeccab8a95fc723a8942eef158679d: 10 training steps on 8 H100 GPUs, checkpoint save/consolidation, and single-GPU reload/generation. Scoped CI has not been rerun for this simplification; normal PR CI is being rerun.Before your PR is "Ready for review"
Additional Information
Fixes AMINT-329.