[CUDA] TopK kernel based on Radix and Bitonic Hybrid Sort#1731
Closed
tianleiwu wants to merge 3 commits into
Closed
[CUDA] TopK kernel based on Radix and Bitonic Hybrid Sort#1731tianleiwu wants to merge 3 commits into
tianleiwu wants to merge 3 commits into
Conversation
This reverts commit 55c4aa7.
hariharans29
reviewed
Sep 6, 2025
| // Helper to determine the optimal partition size for the hybrid sort algorithm | ||
| // based on vocabulary and batch size. | ||
| inline int GetHybridSortPartitionSize(int vocab_size, int batch_size) { | ||
| if (vocab_size >= 147456) { |
Member
There was a problem hiding this comment.
Could you share commentary around how these numbers were chosen ?
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.
This PR is for a new TopK kernel based on hybrid of Radix Sort and Bitonic Sort in different stages. You can see the change here.
Note that I have split the sampling code change to another PR: #1732. If you have comments related to sampling kernel, you can add comments there. That will be merged first.
The new TopK kernel has 6X ~ 10X improvement compared to selection sort for batch_size=1, k=50, vocab_size=201088.