Add grid-stride + ROCm cap to generate_vbe_metadata kernel - #6108
Open
q10 wants to merge 1 commit into
Open
Conversation
Summary: generate_vbe_metadata_foreach_sample_kernel launches a 3-D grid dim3(div_round_up(max_B_feature_rank, kMaxThreads), num_ranks, T) with block = kMaxThreads, so total threads ~= max_B_feature_rank * num_ranks * T exceeds the HIP 2^32 threads-per-launch limit on ROCm once num_ranks * T is large (the existing TORCH_CHECK only guarded grid.x <= maxGridSize, not the 2^32 total-thread product). Cap grid.x with utils::cuda::cap_grid_dim_x, factoring grid.y (num_ranks) and grid.z (T) into the per-x-block thread count (kMaxThreads * num_ranks * T) for the overflow check, and add a ROCm grid-stride loop over b. No-op on CUDA. Added the cuda_utilities.cuh include. Reviewed By: henrylhtsang Differential Revision: D113351683
Contributor
|
@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113351683. |
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
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.
Summary:
generate_vbe_metadata_foreach_sample_kernel launches a 3-D grid
dim3(div_round_up(max_B_feature_rank, kMaxThreads), num_ranks, T) with
block = kMaxThreads, so total threads ~= max_B_feature_rank * num_ranks * T
exceeds the HIP 2^32 threads-per-launch limit on ROCm once num_ranks * T is
large (the existing TORCH_CHECK only guarded grid.x <= maxGridSize, not the
2^32 total-thread product).
Cap grid.x with utils::cuda::cap_grid_dim_x, factoring grid.y (num_ranks) and
grid.z (T) into the per-x-block thread count (kMaxThreads * num_ranks * T) for
the overflow check, and add a ROCm grid-stride loop over b. No-op on CUDA.
Added the cuda_utilities.cuh include.
Reviewed By: henrylhtsang
Differential Revision: D113351683