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

Raise error when minibatch is used in SPMD dataloading and per host b… #8205

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

JackCaoG
Copy link
Collaborator

@JackCaoG JackCaoG commented Oct 2, 2024

…atch size is not divisble by data mesh

When minibatch is used in sharding spec, each device is loading it own part of the data and reassemble it during the runtime.

Imagenine a case the mesh is (4,1) and the batch size we used is 3, each device will see a data like

(100,200,300,0)
(400,500,600,0)

and runtime will reassemble a incorrect final data.

If mini batch is not used it is OK, because each device will see

(100, 200, 300,400)
(500, 600, 0, 0)

and we will drop padding at the end.

@JackCaoG JackCaoG requested a review from jonb377 October 2, 2024 21:17
@JackCaoG JackCaoG added the tpuci label Oct 2, 2024
@JackCaoG
Copy link
Collaborator Author

JackCaoG commented Oct 3, 2024

ok let me resolve the merge conflicts

@JackCaoG
Copy link
Collaborator Author

JackCaoG commented Oct 3, 2024

@jonb377 can you take another look?

Copy link
Collaborator

@jonb377 jonb377 left a comment

Choose a reason for hiding this comment

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

Thanks Jack!

if sharding and tensor.dim() > 0 and (tensor.size()[0] %
local_runtime_device_count) != 0:
raise RuntimeError(
"When minibatch is configured, batch dimension of the tensor " +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe clarify the per-host batch size must be divisible...? These concepts are kind of confusing since we're mapping host-level sharding into device-level and representing it as a global tensor, so there's three different batch dimensions to consider.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, let me update in a follow up pr.

@JackCaoG JackCaoG merged commit e3cf356 into master Oct 7, 2024
23 checks passed
@JackCaoG JackCaoG deleted the JackCaoG/data_loader_warm_data_size branch October 7, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants