Repository navigation
[Fix] KDA: Compile the CuTe DSL decode kernel for the caller's dt_bias dtype - #47866
Merged
Merged
Conversation
SunskyXH
requested review from
BBuf,
HydraQYH,
celve and
yuan-luo
as code owners
November 2, 2026 07:17
This comment has been minimized.
This comment has been minimized.
BBuf
approved these changes
Nov 2, 2026
BBuf
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Compiling with the caller's dt_bias dtype and including it in the cache key addresses both the incorrect loads and cross-dtype kernel reuse. The regression test exercises both dtypes at the same shape and checks outputs and the full state pool over multiple decode steps. Reviewed the code; GPU tests were not rerun locally.
Collaborator
|
/tag-and-rerun-ci |
Collaborator
|
/rerun-failed-ci |
1 similar comment
Collaborator
|
/rerun-failed-ci |
Collaborator
|
[BBuf Review Agent] @SunskyXH these still fail after a rerun, and I can't tell from the logs whether it's this PR. Could you take a look?
|
Collaborator
|
/rerun-failed-ci |
1 similar comment
Collaborator
|
/rerun-failed-ci |
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
_get_compiled_kernelincutedsl_kda.pycompiles the CuTe DSL KDA decode kernels against a bf16dt_biasplaceholder, and the dtype is not part of the compile-cache key. CuTe launches do not check tensor dtypes, so when a caller passes an fp32dt_bias, the kernel reads the fp32 bytes as bf16. Kimi-Linear keepsdt_biasin fp32 (kimi_linear.py), andkda_cutedsl.pyforwards it without a cast. So with--linear-attn-decode-backend cutedslthe forget gates are wrong, and NaN shows up in the decode output and in every state slot the batch touches.Modifications
cutedsl_kda.py: compile with the caller'sdt_biasdtype, and add the dtype to the compile-cache key. The kernel bodies are unchanged; they already convertdt_biasto fp32 on load.test/registered/kernels/ops/attention/test_cutedsl_kda.py, modeled ontest_cutedsl_gdn.py. For batch sizes 16 and 128, with dense and varlen inputs, it runs bf16 and then fp32dt_biasat the same shape. Over 3 decode steps it compares the outputs and the whole state pool against Tritonfused_sigmoid_gating_delta_rule_update(is_kda=True), with one padded-1slot. Running both dtypes at one shape means a kernel compiled for one dtype cannot quietly serve the other.Accuracy Tests
The new test on one H200 (H = HV = 32, K = V = 128):
dt_biasdt_bias(as in Kimi-Linear)test_cutedsl_gdn.pystill passes.Speed Tests and Profiling
The kernels are unchanged. A model compiles one variant for its
dt_biasdtype, and nothing is added per call.Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #41751237296
Latest PR Test (Extra): ❌ Run #41751237093
Latest PR Test (AMD ROCm 10): 🚫 Run #41751237232
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: