Skip to content

Commit b3a0d97

Browse files
committed
Generalize FlyDSL decode TopK tiered kernel to all K and expose workspace API. Make the tiered persistent radix-select the sole decode TopK path for every supported K (256/512/1024/2048) by lifting top_k to a compile-time parameter, and drop the single-CTA fallback. Callers now manage scratch through flydsl_top_k_per_row_decode_workspace_size and an optional workspace= argument, with a batch-aware tier config and a deadlock guard that clamps cooperating workgroups (or forces the barrier-free short tier) to keep the non-cooperative row barrier safe.
1 parent 5152d4d commit b3a0d97

8 files changed

Lines changed: 1085 additions & 730 deletions

‎aiter/ops/flydsl/__init__.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
from .moe_kernels import flydsl_moe_stage1, flydsl_moe_stage2
4242
from .fmha_kernels import flydsl_flash_attn_func
4343
from .kernels.qk_norm_rope_quant import flydsl_qk_norm_rope_quant
44-
from .topk_per_row_decode import flydsl_top_k_per_row_decode
44+
from .topk_per_row_decode import (
45+
flydsl_top_k_per_row_decode,
46+
flydsl_top_k_per_row_decode_workspace_size,
47+
)
4548

4649
# from .linear_attention_kernels import flydsl_gdr_decode
4750

@@ -53,5 +56,6 @@
5356
"flydsl_flash_attn_func",
5457
"flydsl_qk_norm_rope_quant",
5558
"flydsl_top_k_per_row_decode",
59+
"flydsl_top_k_per_row_decode_workspace_size",
5660
# "flydsl_gdr_decode",
5761
]

‎aiter/ops/flydsl/kernels/topk_per_row_decode.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""FlyDSL decode TopK-per-row kernel builders.
44
5-
This module contains the single-CTA unordered radix-select implementation used
5+
This module contains the single-workgroup unordered radix-select implementation used
66
for non-tiered TopK sizes. K=512 is served by the tiered persistent kernel, so
77
the non-tiered ordered compact/bitonic paths are intentionally absent.
88
@@ -27,7 +27,7 @@
2727
# Width of the vectorized (stride-1) global load used by the radix passes.
2828
# Reading 4 contiguous fp32 logits per buffer instruction quarters the VMEM
2929
# instruction count of every full-row pass, which is the dominant cost of the
30-
# one-CTA-per-row decode kernel (cost grows ~linearly with row length).
30+
# one-workgroup-per-row decode kernel (cost grows ~linearly with row length).
3131
LOAD_VEC = 4
3232
RADIX_BITS = 11
3333
RADIX_BINS = 1 << RADIX_BITS
@@ -40,7 +40,7 @@ def create_topk_per_row_decode_kernel(top_k: int):
4040
Launcher signature matches the existing decode interface:
4141
``(logits, next_n, seqLens, indices, numRows, stride0, stride1, stream=...)``.
4242
The output is an unordered Top-K set. K=512 is intentionally handled by the
43-
tiered persistent kernel, which embeds the one-CTA clone for short rows.
43+
tiered persistent kernel, which embeds the one-workgroup short tier for short rows.
4444
"""
4545

4646
if top_k <= 0:

‎aiter/ops/flydsl/kernels/topk_per_row_decode_tiered.py‎

Lines changed: 301 additions & 352 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)