-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[Ring Attention] fix the 2d ring attn when using multiple machine #6071
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Edenzzzz
reviewed
Oct 4, 2024
Edenzzzz
reviewed
Oct 4, 2024
Edenzzzz
reviewed
Oct 11, 2024
Edenzzzz
reviewed
Oct 11, 2024
Edenzzzz
reviewed
Oct 14, 2024
Edenzzzz
approved these changes
Oct 15, 2024
ver217
approved these changes
Oct 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚨 Issue number
fixed #6017
📝 What does this PR do?
The double_ring_groups need to consider the tp groups as the tp axis is the first axis.


And the ranks in double_ring_groups need to transformered into global ranks.
refer: https://arxiv.org/pdf/2406.18485
Problem Transformation:
Given a consecutive array from 0 to world_size - 1 and a number num_rings, divide the array into num_rings subarrays by evenly dividing world_size by num_rings.
Inner Ring Group:
For each subarray, that is a single num_ring, take one number every tp_size elements. The extracted numbers are grouped together every inner_ring_size to form a new element. Continue this process until reaching world_size. The collection of all these new elements forms the inner ring group array.
Inter Ring Group:
From each subarray, take the numbers at the same index to form a new element. These new elements are combined into a new array, which is the inter ring group.
Test code:
example1:
world size = 8, tp 2, sp 4, inner_ring_size = 2
results:

example2:
world size = 32, tp 8, sp 4, inner_ring_size = 2,
2 nodes and 16 gpus in one node
results:

example3:
world_size = 32 tp_size = 4 sp_size = 8,inner_ring_size = 4
results:

example 4:
world_size = 24 tp_size = 2 sp_size = 6,inner_ring_size = 3
results:
