-
Notifications
You must be signed in to change notification settings - Fork 26.7k
[a2av] 2D all-to-all-vdev #155058
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
Closed
Closed
[a2av] 2D all-to-all-vdev #155058
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update
[ghstack-poisoned]
- Loading branch information
commit baa5600928e387053e2a40d00956af4313b6587c
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -419,11 +419,15 @@ at::Tensor nvshmem_all_to_all_vdev_2d( | |
| void* output_ptr = out_hdl->get_buffer_ptrs()[rank]; | ||
| int64_t* splits_ptr = (int64_t*)(splits_hdl->get_buffer_ptrs()[rank]); | ||
|
|
||
| auto split_shape = in_out_splits.sizes(); | ||
| TORCH_CHECK(split_shape.size() == 2 && split_shape[0] == 3, "in_out_splits must be 2D with 3 rows"); | ||
| TORCH_CHECK(split_shape[1] % world_size == 0, "Each row of in_out_splits must be a multiple of world_size"); | ||
| // Number of experts per rank | ||
| int ne = in_out_splits.stride(0) / world_size; | ||
| TORCH_CHECK(ne * world_size == in_out_splits.stride(0), "Each row of in_out_splits must be a multiple of world_size") | ||
| int ne = split_shape[1] / world_size; | ||
|
|
||
| auto stream = at::cuda::getCurrentCUDAStream(input.device().index()); | ||
| // Set device context for getting the stream and launching kernels below | ||
| c10::cuda::CUDAGuard guard(input.device()); | ||
| auto stream = at::cuda::getCurrentCUDAStream(); | ||
|
|
||
| // Exchange output splits and source offsets | ||
| // Use collective launch because kernel involves nvshmem barrier | ||
|
|
@@ -444,7 +448,6 @@ at::Tensor nvshmem_all_to_all_vdev_2d( | |
| // Naive for now, use 1 block per expert. | ||
| // Total number of blocks is limited to 64 (intra-node) or 8 (inter-node). | ||
| int num_blocks = std::min(world_size * ne, world_size > 8 ? 8 : 64); | ||
| LOG(INFO) << "num_blocks: " << num_blocks << ", ne: " << ne << ", world_size: " << world_size; | ||
|
|
||
| // Stride at dim 0 (assuming input is contiguous, TODO) | ||
| size_t stride_bytes = input.stride(0) * input.element_size(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here you are assuming that input.stride(0) == output.stride(0), you should check it
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't see a check for
in_out_splits.is_contiguous()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry added.