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

Split tensors as part of split_between_processes #1477

Merged
merged 11 commits into from
May 26, 2023
Merged

Conversation

muellerzr
Copy link
Collaborator

@muellerzr muellerzr commented May 26, 2023

Solves #1400 by also letting the tensors be split if added. Note that similar to the list version, the tensors padded will have the value of the last item in the tensor being used. Such that on four processes:

t = torch.tensor([[0,1,2,3], [4,5,6,7]])
with PartialState().split_between_processes(t, with_padding=True) as t:
    print(t)
# Process 1:
tensor([[0,1,2,3]])
# Process 2:
tensor([[4,5,6,7]])
# Process 3:
tensor([[4,5,6,7]])
# Process 4:
tensor([[4,5,6,7]])

@muellerzr muellerzr added the enhancement New feature or request label May 26, 2023
@muellerzr muellerzr requested a review from sgugger May 26, 2023 17:20
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 26, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

LGTM, can you add a test of this use case as well?

@muellerzr muellerzr merged commit bb29634 into main May 26, 2023
@muellerzr muellerzr deleted the split-tensors branch May 26, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants