Skip to content

Update tutorial of device mesh to use fsdp2 #3472

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
Jul 18, 2025
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: 3 additions & 3 deletions recipes_source/distributed_device_mesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ users would not need to manually create and manage shard group and replicate gro
import torch.nn as nn
from torch.distributed.device_mesh import init_device_mesh
from torch.distributed.fsdp import FullyShardedDataParallel as FSDP, ShardingStrategy
from torch.distributed.fsdp import fully_shard as FSDP
class ToyModel(nn.Module):
Expand All @@ -136,9 +136,9 @@ users would not need to manually create and manage shard group and replicate gro
# HSDP: MeshShape(2, 4)
mesh_2d = init_device_mesh("cuda", (2, 4))
mesh_2d = init_device_mesh("cuda", (2, 4), mesh_dim_names=("dp_replicate", "dp_shard"))
model = FSDP(
ToyModel(), device_mesh=mesh_2d, sharding_strategy=ShardingStrategy.HYBRID_SHARD
ToyModel(), device_mesh=mesh_2d
)
Let's create a file named ``hsdp.py``.
Expand Down