[ROCm][Bugfix] Kimi-K3 Fix KDA NaN on mixed batches and racy autotune config - #50649
Merged
Merged
Conversation
Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
5 tasks
13 tasks
Member
Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
kliuae
requested review from
dllehr-amd,
hongxiayang and
tjtanaa
as code owners
August 4, 2026 04:42
Contributor
Author
tjtanaa
enabled auto-merge (squash)
August 4, 2026 04:45
djdisodo
pushed a commit
to djdisodo/vllm
that referenced
this pull request
Aug 16, 2026
The FLA W/U recompute kernel pipelines loads through its u loop, then reuses LDS for the following w loop. For Qwen3.6 GDN, V/BV is 2. With num_stages=4, Triton can issue a third consumer-less async copy that races the w loop and returns non-deterministic O(1e38) values. Upstream commit f5cd862 (vllm-project#50649) diagnosed the same loop structure in the ROCm Kimi KDA copy on gfx950, but that fix did not cover this shared FLA implementation used by Qwen. On our gfx906 TP=2 run, autotuning selected stages=2 on rank 0 and the unsafe stages=4 on rank 1 because their timings differed by less than one percent. Exclude stages=4 from this kernel on ROCm while preserving the existing CUDA search space. Stages 2 and 3 remain available, and their observed timings were within one percent of stage 4. This is a correctness restriction tied to the kernel pipeline shape, not a gfx906-only performance tuning.
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.
Purpose
For Kimi-K3, there are two correctness bugs on the ROCm Kimi-K3 KDA path.
KimiGatedDeltaNetAttention._forwardsends the decode sequences of a mixed decode+prefill non-speculative batch through the KDA chunk kernelchunk_kda_with_fused_gate. The chunk kernel treats each decode as length=1 sequence, and returns NaN for them. This PR separates the decode out of the mixed batch and pass them tofused_recurrent_kda.recompute_w_u_fwd_kernelautotunes the configuration ofnum_stages=4. This configuration, particularly in combination withnum_warps=4, is racy for this kernel, and can silently produce large (e.g. ~1e38) garbage values that corrupts the downstream. This PR addresses this by leaving thenum_stages=4out in autotuning so that it doesn't land on the erroneous configuration.Test Plan
moonshotai/Kimi-K3with gsm8k on MI355XServer command
lm_eval
Test Result
Before, 5-shot
PR, 5-shot
PR, 20-shot
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.