Skip to content

Conversation

@kmehant
Copy link
Contributor

@kmehant kmehant commented Nov 29, 2025

What does this PR do?

Extends dispatch mode dataloader for CP and CP + DP usecases.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@SunMarc

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks for updating this ! Left a comment. Just a quick question, are you always using DataLoaderDispatcher ? do DataLoaderShard requires some modifications also to work also ? Also, can you add some tests to check that DataLoaderDispatcher is behaving correctly when cp is used ?

Comment on lines +780 to +781
if "tp" in self.torch_device_mesh.mesh_dim_names:
raise ValueError("TP + CP combination is not yet supported in dispatch mode.")
Copy link
Member

Choose a reason for hiding this comment

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

we can't make fsdp + tp work also, so it's fine to not put that since we require cp to be used with fsdp

# multiplied by number of cp groups (dp degree).
if self.submesh_cp:
cp_degree = self.submesh_cp.size()
dp_degree = self.torch_device_mesh.size() // cp_degree
Copy link
Member

Choose a reason for hiding this comment

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

self.submesh_dp.size() * self.submesh_fsdp.size() would be better no ?

Comment on lines +821 to +828
for i in range(dp_degree):
portion = slice(
i * number_of_samples_per_dp_group, (i + 1) * number_of_samples_per_dp_group
)
dp_batch = self.slice_fn(batch, portion)
for _ in range(cp_degree):
batches.append(dp_batch)
batch = concatenate(batches, dim=0)
Copy link
Member

Choose a reason for hiding this comment

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

explain a bit mroe what's happening here

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.

2 participants