Repository navigation
feat: Adaptive topk algorithm selection based on input characteristics - #1578
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements adaptive Top-K algorithm selection based on input characteristics (primarily K value) to optimize performance across different workload scenarios. The implementation intelligently chooses between bitonic sort for small K values (≤128) and 11-bit radix sort for larger K values, maximizing performance across the entire spectrum.
Key Changes:
- Adaptive algorithm selection heuristic based on K value and input length
- Extended capacity support from 512 to 2048 elements
- Variable-length input support via rowStarts/rowEnds parameters
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| op_tests/test_topk_plain.py | Updated test to handle new function signatures and expanded test parameter ranges; added exception handling for Triton fallback |
| csrc/kernels/topk_plain_kernels.cu | Core implementation of adaptive selection logic; added support for variable-length inputs and increased MAX_CAPACITY to 2048 |
| csrc/kernels/topk_per_row_kernels.cu | Added null-safe handling for rowStarts/rowEnds parameters and extended k parameter to filtering functions |
| csrc/include/topk_plain.h | Updated function signature to include topk_out tensor and variable-length support parameters |
| csrc/include/rocm_ops.hpp | Updated Python bindings with new parameters and default values |
| csrc/include/opus/opus.hpp | Fixed type inconsistency: changed __fp16 to _Float16 for med3 template specialization |
| aiter/ops/topk_plain.py | Updated Python wrapper signature with additional parameters for variable-length support |
| aiter/jit/optCompilerConfig.json | Added topk_per_row_kernels.cu to build sources |
Comments suppressed due to low confidence (1)
csrc/kernels/topk_per_row_kernels.cu:1340
- Similar to the other function, the parameter
kis added tofilter_and_histogram_for_one_blockat line 1182 but is never used in the function body (lines 1183-1340). This indicates either an incomplete implementation or an unnecessary parameter addition. Review ifkshould be used for any logic within this function.
IdxT k)
{
constexpr int num_buckets = calc_num_buckets<BitsPerPass>();
for(int i = threadIdx.x; i < num_buckets * 2; i += blockDim.x)
{
histogram[i] = 0;
}
IdxT* p_filter_cnt = &counter->filter_cnt;
if(threadIdx.x == 0)
{
*p_filter_cnt = 0;
}
__syncthreads();
int const start_bit = calc_start_bit<T, BitsPerPass>(pass);
unsigned const mask = calc_mask<T, BitsPerPass>(pass);
if(pass == 0)
{
T local_min = std::numeric_limits<T>::max();
T local_max = std::numeric_limits<T>::lowest();
auto f = [histogram, select_min, start_bit, mask, &local_min, &local_max](
T value, IdxT, int& acc, int& prev_bin_idx, bool is_last) {
int bucket = calc_bucket<T, BitsPerPass>(value, start_bit, mask, select_min);
// atomicAdd(histogram + bucket, static_cast<IdxT>(1));
if(bucket == prev_bin_idx)
{
acc++;
}
else
{
if(acc > 0)
{
atomicAdd(histogram + prev_bin_idx, static_cast<IdxT>(acc));
}
acc = 1;
prev_bin_idx = bucket;
}
if(is_last)
{
return;
}
int bucket_low =
calc_bucket<T, BitsPerPass>(value, 0, (1 << BitsPerPass) - 1, select_min);
atomicAdd(histogram + num_buckets + bucket_low, static_cast<IdxT>(1));
local_min = fminf(local_min, value);
local_max = fmaxf(local_max, value);
};
vectorized_process(threadIdx.x, blockDim.x, in_buf, previous_len, f);
using BlockReduceT =
hipcub::BlockReduce<T, BlockSize, hipcub::BLOCK_REDUCE_WARP_REDUCTIONS>;
__shared__ typename BlockReduceT::TempStorage temp_storage;
__shared__ bool use_one_pass;
T global_min = BlockReduceT(temp_storage).Reduce(local_min, hipcub::Min());
T global_max = BlockReduceT(temp_storage).Reduce(local_max, hipcub::Max());
if(threadIdx.x == 0)
{
auto global_min_bits = twiddle_in(global_min, select_min);
auto global_max_bits = twiddle_in(global_max, select_min);
uint32_t diff = global_min_bits ^ global_max_bits;
use_one_pass = diff < (1u << BitsPerPass);
}
__syncthreads();
return use_one_pass;
}
else if(!out_buf)
{
// not use vectorized_process here because it increases #registers a lot
auto const kth_value_bits = counter->kth_value_bits;
int const previous_start_bit = calc_start_bit<T, BitsPerPass>(pass - 1);
for(IdxT i = threadIdx.x; i < previous_len; i += blockDim.x)
{
const T value = in_buf[i];
auto const previous_bits = (twiddle_in(value, select_min) >> previous_start_bit)
<< previous_start_bit;
if(previous_bits == kth_value_bits)
{
int bucket = calc_bucket<T, BitsPerPass>(value, start_bit, mask, select_min);
atomicAdd(histogram + bucket, static_cast<IdxT>(1));
}
}
}
else
{
// not use vectorized_process here because it increases #registers a lot
IdxT* p_out_cnt = &counter->out_cnt;
auto const kth_value_bits = counter->kth_value_bits;
int const previous_start_bit = calc_start_bit<T, BitsPerPass>(pass - 1);
if(in_idx_buf)
{
for(IdxT i = threadIdx.x; i < previous_len; i += blockDim.x)
{
const T value = in_buf[i];
auto const previous_bits = (twiddle_in(value, select_min) >> previous_start_bit)
<< previous_start_bit;
if(previous_bits == kth_value_bits)
{
IdxT pos = atomicAdd(p_filter_cnt, static_cast<IdxT>(1));
out_buf[pos] = value;
out_idx_buf[pos] = in_idx_buf[i];
int bucket = calc_bucket<T, BitsPerPass>(value, start_bit, mask, select_min);
atomicAdd(histogram + bucket, static_cast<IdxT>(1));
}
else if(previous_bits < kth_value_bits)
{
IdxT pos = atomicAdd(p_out_cnt, static_cast<IdxT>(1));
if(WRITE_TOPK_VALUES)
{
out[pos] = value;
}
out_idx[pos] = in_idx_buf[i];
}
}
}
else
{
for(IdxT i = threadIdx.x; i < previous_len; i += blockDim.x)
{
const T value = in_buf[i];
auto const previous_bits = (twiddle_in(value, select_min) >> previous_start_bit)
<< previous_start_bit;
if(previous_bits == kth_value_bits)
{
IdxT pos = atomicAdd(p_filter_cnt, static_cast<IdxT>(1));
out_buf[pos] = value;
out_idx_buf[pos] = i;
int bucket = calc_bucket<T, BitsPerPass>(value, start_bit, mask, select_min);
atomicAdd(histogram + bucket, static_cast<IdxT>(1));
}
else if(previous_bits < kth_value_bits)
{
IdxT pos = atomicAdd(p_out_cnt, static_cast<IdxT>(1));
if(WRITE_TOPK_VALUES)
{
out[pos] = value;
}
out_idx[pos] = i;
}
}
}
}
return false;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
valarLip
previously approved these changes
Dec 12, 2025
valarLip
approved these changes
Dec 22, 2025
zufayu
pushed a commit
that referenced
this pull request
Dec 23, 2025
#1578) * Add radix-base selection * Remove explicit template * Update the selected k condition * remove pos < k guard * code format * Update csrc/include/rocm_ops.hpp Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_plain_kernels.cu Co-authored-by: Copilot <[email protected]> * Update test_topk_plain.py * Update TODO message * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update op_tests/test_topk_plain.py Co-authored-by: Copilot <[email protected]> * format test_topk_plain.py with black * Disable triton test for a resonalbe execution time * add explicit template instantiation * fix explicit template instantiation * add explicit template instantiation * Add bf16 support * Fix linter * Fix build errors * Fix condition * Fix build and test * Update conditions --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> Co-authored-by: MHYang <[email protected]>
Zzz9990
added a commit
that referenced
this pull request
Dec 25, 2025
* fix sink error for asm fmha (#1652) Signed-off-by: Linjun-AMD <[email protected]> * add guard in case pynccl init failed (#1671) * One shot pa (#1670) * add one shot pa kernel * fix buffer load in sliding window kernel * fix typo * revert --------- Co-authored-by: root <[email protected]> * fix(pa_ps): fix pa_ps_asm .co for gfx950 (#1669) Signed-off-by: Double Young <[email protected]> * modify test_bf16gemm_test (#1678) * Fix Ruff command in pre-checks (#1675) * fix mha bwd golden perf issue (#1666) * topk uplift v1 (#1662) /lgtm The customer has tested the code. It can work. * topk uplift v1 * topk add api for choose topk_v1 or topk_v2 --------- Co-authored-by: yonshuai <[email protected]> Co-authored-by: yongshuai <[email protected]> * fix missing return in mha_bwd (#1688) * Remove the input parameter "out" in gemm_a4w4 (#1679) * Remove the input parameter "out" in gemm_a4w4 * update * format --------- Co-authored-by: valarLip <[email protected]> * fwd v3 hd192 optimize inst alignment for causal mode (#1663) Co-authored-by: Lingpeng Jin <[email protected]> * fix swa case mismatch (#1694) * fixing the fp4 gemm tune script Exception caused by tile_m name inconsistency (#1686) * CI: Migrate Triton tests to aiter-1gpu-runner (#1690) * add ntile 128 for a8 blkQ moe 1 stage (#1695) * add fmoe co with tilesize 32x128 * add ps co * fix pertoken co bug * add co to csv * add 128ntile logic for one stage asm * fix mem fault during perf turn * en vs for pertoken kernel --------- Co-authored-by: feifei14119 <[email protected]> Co-authored-by: zufayu <[email protected]> * Optimize RoPE in the cases that hdim is small. (#1698) * Introduce new grid config strategy for compatibility with cases that hdim is small. * add launch bound to make sure that occu is always 8 * follow Copilot the suggestions * rm garbage from whl (#1696) * enhance prebuild logic (#1672) * enhance prebuild logic * ATen.h build issues * bug fix * bug fix II * bug fix III --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> * LLfp4 qr cap for atom (#1673) * QR cap implemented to limit QR to prefill * test git config * Fix to genericize qr comm cap * Incorrect cap number * [MLA] MLA conditions rewrite (#1665) * open mla mtp and remove some logs * fix qlen dense 128,N * fix hint * support sparse qlen input = 1 * change default splits * fix dp causal (#1677) * add two fp4 tune shapes and tuned config (#1687) * add two fp4 tune shapes and tuned config * change 32800 to 65536 to cover all cases between 32768 to 65536 as per feedback * Dev/a8w4 and a8w8splitk (#1667) * support moe a8w8 splitk (#1654) * Add support to a8w8_ck_moe_blk_gemm1 splitk * add switch and add some logging * tiny fix * update ck 3rd party and add some logging * add AITER_HEURISTIC_ONLY env * update ck * add condition to bypass tuned cfg * change bypass type * fix * fix removed log * upate ck submodule * fix lint * force to run tests --------- Co-authored-by: oscar <[email protected]> * Zan/moe a8w4 (#1655) * update * update * update quant * ut ready * update quant type * compile pass * python3 op_tests/test_moe_2stage.py -t 16 -e 1 -k 1 -dim 256,256 ready * update aiter dipatcher for bf16&fp8 * support a16 a8 dispatch * finish quant & sort * update aiter framework for a8w4 moe * update ck * update * update * update for atom * update --------- Co-authored-by: Zzz9990 <Zzz9990> Co-authored-by: root <[email protected]> * update ck * fix dispatch * fix too much logging * update * update ck * update ck * fix ruff code style * revert aiter-test yaml * fix ci * fix ci * fix ci * add mocked tuned result and decoding cfg token to next power of 2 * Update tuned_fmoe.csv remove duplicate * remove hack dtype * fix black * unique index * add empty arg to ck_moe_stage1 * resolve bias into lru cache * rename bypass cfg to AITER_BYPASS_TUNE_CONFIG --------- Co-authored-by: oscar <[email protected]> Co-authored-by: Zzz9990 <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: felix <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> * bf16_gemm_clean_in_kl (#1700) * bf16_gemm_clean_in_kl * update * update * update * update * fix tuner (#1701) * fix tuner * Update gradlib/gradlib/GemmTuner.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: amd-ruitang3 <[email protected]> Co-authored-by: Copilot <[email protected]> * add gen_fake for 4 gemm operators (#1456) Co-authored-by: Lin, Soga <[email protected]> Co-authored-by: sogalin <[email protected]> * fix llvm issue (#1703) * fix llvm issue * fix copilot * feat: Adaptive topk algorithm selection based on input characteristics (#1578) * Add radix-base selection * Remove explicit template * Update the selected k condition * remove pos < k guard * code format * Update csrc/include/rocm_ops.hpp Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_plain_kernels.cu Co-authored-by: Copilot <[email protected]> * Update test_topk_plain.py * Update TODO message * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update op_tests/test_topk_plain.py Co-authored-by: Copilot <[email protected]> * format test_topk_plain.py with black * Disable triton test for a resonalbe execution time * add explicit template instantiation * fix explicit template instantiation * add explicit template instantiation * Add bf16 support * Fix linter * Fix build errors * Fix condition * Fix build and test * Update conditions --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> Co-authored-by: MHYang <[email protected]> * fix mha bwd build error (#1705) * fix moe bug when pipever=v1 and nblk=64 (#1707) * fix bug * update * fix (#1710) * fix * update lint * [PA] Optimize PA Decode Gluon Performance for BF16/FP16 with KV_BLOCK_SIZE=64 and Fix ROCm 7.0 AOT Compilation (#1691) * Optimize pa_decode_gluon f16/bf16 perf for KV_BLOCK_SIZE=64 & fix ROCm 7.0 AOT - Add dedicated blocked layouts for f16/bf16 compute types - Add local AOT compile tool to fix ROCm 7.0 compatibility * black format file * format file to pass the ruff check * fix error in gfx950 * Fix argument parsing logic when AITER_JIT_DIR is set (#1715) When AITER_JIT_DIR is defined the enum module is loaded as "module_aiter_enum" rather than "aiter.jit.module_aiter_enum". This caused the docstring cleanup of enums to not work properly, causing a NameError exception in check_args. * fix topk deocde bug in logit value is same (#1716) Co-authored-by: yonshuai <[email protected]> * add fp32 input (#1706) * add fp32 input * format code * perf bug fix * logic fix : out type != input type * bug fix * format code * remove dtype convert before act_and_mul in fused_moe --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: chenjun <[email protected]> * add sampling aot (#1711) * add sampling aot * simple compile * fix compile bugs * fix a bug * revert changes --------- Co-authored-by: root <[email protected]> * update * bugfix * update * update --------- Signed-off-by: Linjun-AMD <[email protected]> Signed-off-by: Double Young <[email protected]> Co-authored-by: Linjun-AMD <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> Co-authored-by: who who who <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: Double Young <[email protected]> Co-authored-by: amd-ruitang3 <[email protected]> Co-authored-by: Satya Nikhil Kodukula <[email protected]> Co-authored-by: JaxChen29 <[email protected]> Co-authored-by: steamedMantou <[email protected]> Co-authored-by: yonshuai <[email protected]> Co-authored-by: yongshuai <[email protected]> Co-authored-by: Yu Guo <[email protected]> Co-authored-by: la <[email protected]> Co-authored-by: valarLip <[email protected]> Co-authored-by: shay-li77 <[email protected]> Co-authored-by: Hongxia Yang <[email protected]> Co-authored-by: Xin Huang <[email protected]> Co-authored-by: zufayu <[email protected]> Co-authored-by: feifei14119 <[email protected]> Co-authored-by: zufayu <[email protected]> Co-authored-by: ruanjm <[email protected]> Co-authored-by: amirumoAMD <[email protected]> Co-authored-by: yadaish <[email protected]> Co-authored-by: oscar <[email protected]> Co-authored-by: felix <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: mqhc2020 <[email protected]> Co-authored-by: Lin, Soga <[email protected]> Co-authored-by: sogalin <[email protected]> Co-authored-by: ClementLinCF <[email protected]> Co-authored-by: MHYang <[email protected]> Co-authored-by: lalala-sh <[email protected]> Co-authored-by: yanguahe <[email protected]> Co-authored-by: omoisis-dn <[email protected]> Co-authored-by: chenjun <[email protected]>
ZhangLirong-amd
pushed a commit
that referenced
this pull request
Dec 29, 2025
#1578) * Add radix-base selection * Remove explicit template * Update the selected k condition * remove pos < k guard * code format * Update csrc/include/rocm_ops.hpp Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_plain_kernels.cu Co-authored-by: Copilot <[email protected]> * Update test_topk_plain.py * Update TODO message * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update op_tests/test_topk_plain.py Co-authored-by: Copilot <[email protected]> * format test_topk_plain.py with black * Disable triton test for a resonalbe execution time * add explicit template instantiation * fix explicit template instantiation * add explicit template instantiation * Add bf16 support * Fix linter * Fix build errors * Fix condition * Fix build and test * Update conditions --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> Co-authored-by: MHYang <[email protected]>
zhuyuhua-v
pushed a commit
that referenced
this pull request
Jan 14, 2026
#1578) * Add radix-base selection * Remove explicit template * Update the selected k condition * remove pos < k guard * code format * Update csrc/include/rocm_ops.hpp Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_plain_kernels.cu Co-authored-by: Copilot <[email protected]> * Update test_topk_plain.py * Update TODO message * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update op_tests/test_topk_plain.py Co-authored-by: Copilot <[email protected]> * format test_topk_plain.py with black * Disable triton test for a resonalbe execution time * add explicit template instantiation * fix explicit template instantiation * add explicit template instantiation * Add bf16 support * Fix linter * Fix build errors * Fix condition * Fix build and test * Update conditions --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> Co-authored-by: MHYang <[email protected]>
valarLip
added a commit
that referenced
this pull request
Mar 18, 2026
#1578) * Add radix-base selection * Remove explicit template * Update the selected k condition * remove pos < k guard * code format * Update csrc/include/rocm_ops.hpp Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update csrc/kernels/topk_plain_kernels.cu Co-authored-by: Copilot <[email protected]> * Update test_topk_plain.py * Update TODO message * Update csrc/kernels/topk_per_row_kernels.cu Co-authored-by: Copilot <[email protected]> * Update op_tests/test_topk_plain.py Co-authored-by: Copilot <[email protected]> * format test_topk_plain.py with black * Disable triton test for a resonalbe execution time * add explicit template instantiation * fix explicit template instantiation * add explicit template instantiation * Add bf16 support * Fix linter * Fix build errors * Fix condition * Fix build and test * Update conditions --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Lingpeng Jin <[email protected]> Co-authored-by: MHYang <[email protected]>
ClementLinCF
added a commit
to AFDEAPAC/aiter
that referenced
this pull request
Oct 2, 2026
topk_select checks the shape and dtype of `input`, `end` and `output_idx`, and of their strides only that `input` has unit inner stride; but several backends read or write dense rows: - plain read a row-strided input -- a column slice of a wider tensor, for one -- as dense rows and returned a wrong top-k, on every kernel family (register, wide first digit, 512-thread, LDS tail with and without the sampled stage, generic radix, block sort), uniform and ragged. The call sites pass stride0 = -1, which the C++ side reads as "rows width apart", and its uniform form takes no row pitch at all; only the ranged form reads row r at r * stride0. - plain, argmax and sampled wrote dense rows into a row-strided output_idx, and decode refused it. - every backend read a strided `end` as dense, and decode refused it. argmax, small_k, the streaming selector (all its forms), decode and sampled already read a row-strided input correctly. The public topk_plain wrapper now takes the layout from the tensor: in the ranged form, which also sizes its launch and scratch by stride0, a row with unit inner stride and a pitch at least the width is read in place, with stride0 taken from the tensor when left at -1; every other non-dense input is handed over densely. The entry hands every backend a dense `end`, and, when `output_idx` is not dense, a dense result that it copies into `output_idx` at the end, as it already does for a reordered result. A contiguous tensor takes exactly the path it took before; the kernels are unchanged (the device code is byte-identical). The cost falls only on the layouts that were wrong: one copy of the input for a strided uniform plain call, of the row ends for a strided `end`, and of the result for a strided output_idx. Passing the pitch to every kernel instead would change the machine code of every plain kernel for a layout the uniform form does not otherwise see. The bug came with topk_select itself (d81eb48, ROCm#5499); the "-1 means rows width apart" default dates from 1532816 (ROCm#1578). Tests: test_topk_select.py gains test_strided_layouts (12 routes x 4 layouts: strided input, strided input with ragged rows, strided output_idx with guard columns, strided end), and test_topk_plain.py gains test_strided_rows (padded and broadcast rows through both forms, stride0 left at -1 and given). Before this change the first fails 39 of its 48 cases and the second ends the process with SIGFPE (the ranged form given a broadcast tensor's own stride 0); after it both pass.
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.
Motivation
We need a selection mechanism to choose the optimal top-K algorithm.
Technical Details
Adaptive algorithm selection based on K value:
Test Plan
python test_topk_plain.py
Test Result
This figures illustrates the performance comparison across different Top-K strategies. The dashed line represents BlockTopK (our bitonic sort-based implementation), which demonstrates competitive performance for K ≤ 128 but begins to lag behind the radix sort-based approach (radix_11bits) as K increases beyond this threshold.
Our AdaptiveTopK strategy intelligently selects the optimal algorithm based on K: leveraging BlockTopK for K ≤ 128 and switching to radix_11bits for K > 128. This adaptive selection ensures peak performance across the entire K spectrum, as evidenced by the solid line consistently matching or exceeding the best-performing algorithm at each K value.
Submission Checklist