[ROCm][Bugfix] Kimi-K3 Fix KDA NaN on mixed batches and racy autotune config (#50649)

Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
This commit is contained in:
kliuae
2026-08-05 08:07:21 +00:00
committed by GitHub
parent b92352ca2c
commit f5cd862dbd
3 changed files with 556 additions and 7 deletions
+8 -1
View File
@@ -28,6 +28,13 @@ BT_LIST_AUTOTUNE = [32, 64, 128]
NUM_WARPS_AUTOTUNE = [2, 4, 8, 16] if is_amd else [4, 8, 16, 32]
# num_stages=4 is excluded. The `u` loop has a trip count of 2 (V / BV), and a
# 4-stage pipeline over it emits a third, consumer-less async copy into LDS that
# the `w` loop then reuses; at num_warps=4 that races on gfx950 and `u` comes
# back with non-deterministic O(1e38) garbage once a batch reaches 4096 tokens.
_RECOMPUTE_W_U_NUM_STAGES = [2, 3]
@triton.heuristics(
{
"STORE_QG": lambda args: args["qg"] is not None,
@@ -39,7 +46,7 @@ NUM_WARPS_AUTOTUNE = [2, 4, 8, 16] if is_amd else [4, 8, 16, 32]
configs=[
triton.Config({}, num_warps=num_warps, num_stages=num_stages)
for num_warps in [2, 4, 8]
for num_stages in [2, 3, 4]
for num_stages in _RECOMPUTE_W_U_NUM_STAGES
],
key=["H", "K", "V", "BT", "BK", "BV", "IS_VARLEN"],
)