[Fix] Infer hybrid FSDP replicas from world size - #309
Open
primorLee wants to merge 1 commit into
Open
Conversation
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
num_replicateis omittedProblem
The training CLI currently defaults to:
That creates a
(1, 8)DeviceMesh even when a two-node launch hasworld_size=16. Only ranks 0-7 belong to the mesh; ranks on the second node have no mesh process-group metadata and fail inside FSDP with:This matches the rank-15 failure reported in #295.
Fix
For HYBRID_SHARD, the replica dimension is determined by:
The CLI therefore uses
Noneas the default and resolves the value at FSDP setup time. Existing single-node 8-GPU behavior remains(1, 8); a 16-GPU launch now becomes(2, 8).If a user supplies an explicit incompatible replica count, or if
world_sizeis not divisible bynum_shard, the code now raises an actionableValueErrorbefore PyTorch reaches the internal_dim_group_infosfailure.Validation
python -B -m unittest discover -s tests -p test_fsdp_mesh.py -v— 5 passedmesh_shape=(2, 8)toinit_device_meshHfArgumentParseraccepts both the omittedOptional[int]value and--num_replicate 2train/fsdp_utils.pyexcludedgit diff --checkpassesI did not run a real two-node GPU training job; the regression covers the exact mesh-shape construction that fails before model execution.
Closes #295