Skip to content
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

add DDP with SPMD example #7063

Merged
merged 2 commits into from
May 15, 2024
Merged

add DDP with SPMD example #7063

merged 2 commits into from
May 15, 2024

Conversation

JackCaoG
Copy link
Collaborator

No description provided.

@JackCaoG JackCaoG requested review from alanwaketan and jonb377 May 14, 2024 22:51
device_ids = np.arange(num_devices)
mesh_shape = (num_devices, 1, 1, 1)
# We know data is 4d and 0th dimension is the batch dimension
input_mesh = xs.Mesh(device_ids, mesh_shape, ('B', 'C', 'W', 'H'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should revisit the mesh shape for these examples - right now it's based on the input tensor shape, but in general we want to reuse the mesh across input and model parameters.

We could do something like MaxText or the shardings example, with data, fsdp, and tensor axes, and recombine them using the partition spec (in this case only with the data axis):

mesh_shape = (num_devices,)
mesh = xs.Mesh(device_ids, mesh_shape, ('data',))

# Shard the input's batch dimension along the `data` axis, no sharding along other dimensions
input_sharding=xs.ShardingSpec(mesh, ('data', None, None, None))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Let me update the example.

Copy link
Collaborator

@alanwaketan alanwaketan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@JackCaoG JackCaoG merged commit c6074ab into master May 15, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants