Skip to content

[2D] Update 2d example to use get_local_rank #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions distributed/tensor_parallelism/fsdp_tp_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,11 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
tp_mesh = device_mesh["tp"]
dp_mesh = device_mesh["dp"]

# To support identical inputs for TP groups, we need the dp process group
dp_pg = device_mesh.get_dim_groups()[0]

# For TP, input needs to be same across all TP ranks.
# while for SP, input can be different across all ranks.
# We will use dp_rank for setting the random seed
# to mimic the behavior of the dataloader.
dp_rank = dist.get_rank(dp_pg)

dp_rank = dp_mesh.get_local_rank()

# create model and move it to GPU with id rank
_mlp_dim = 1024
Expand Down