feat: Support scaling num_experts beyond block size in dispatch_send kernel#9
Open
crgg1433 wants to merge 1 commit intoperplexityai:mainfrom
Open
feat: Support scaling num_experts beyond block size in dispatch_send kernel#9crgg1433 wants to merge 1 commit intoperplexityai:mainfrom
crgg1433 wants to merge 1 commit intoperplexityai:mainfrom
Conversation
…kernel Replace the single-pass prefix scan with a chunked two-level warp scan, allowing num_experts to scale independently of block size, enabling support for MoE models with larger expert counts.
Author
|
Hi @abcdabcd987, This PR removes the Tests are green. Could you please take a look? Thanks! |
Author
|
Hi @abcdabcd987 @nandor, just following up on this PR. It would be great to get your feedback when you have time. Let me know if anything is blocking! |
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:
Removed the
assert(num_experts <= NUM_THREADS)constraint ina2a_dispatch_send_kernelby replacing the single-pass prefix scan with a chunked two-level warp scan. This decouplesnum_expertsfrom the block thread count, allowing the kernel to scale to larger expert counts (e.g., >1024) and enabling support for MoE with many experts.Purpose:
The original implementation performs a single-pass prefix scan over tokens_per_expert, assigning one expert per thread. This design assumes
num_experts <= NUM_THREADS(up to 1024 on Hopper), which breaks when the number of experts exceeds the block size.In practice, num_experts represents the total number of all-to-all participants. When expert tensor parallelism is enabled, this value becomes
total_experts × TP degree, which can easily exceed 1024. The previous restriction therefore prevented support for models with larger expert counts or sharded experts across tensor-parallel groups.Test: