perf(flydsl): fuse Kimi-K3 KDA decode and f_b projection - #4495
Draft
JohnQinAMD wants to merge 6 commits into
Draft
JohnQinAMD wants to merge 6 commits into
JohnQinAMD wants to merge 6 commits into
Conversation
Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com> Assisted-by: OpenAI Codex
Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com> Assisted-by: OpenAI Codex
Sort public imports and exports, use functools.cache, and annotate intentional FlyDSL stream defaults for the repository-wide lint configuration. Assisted-by: OpenAI Codex Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new gfx950-only FlyDSL decode specialization for Kimi-K3 KDA, and an optional fused variant that folds the head-local 128×128 f_b projection into the same workgroup to remove an intermediate global materialization and kernel launch.
Changes:
- Introduces public Python wrappers for
flydsl_kimi_k3_kda_decodeandflydsl_kimi_k3_kda_decode_with_f_b, plus ais_flydsl_kimi_k3_kda_decode_supportedcapability predicate. - Adds two new FlyDSL kernels implementing (1) KDA decode and (2) fused
f_bprojection + KDA decode on gfx950. - Adds focused correctness tests comparing fused vs. reference behavior and validating contract rejection.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| op_tests/flydsl_tests/test_kimi_k3_kda_decode.py | Adds correctness/contract tests for the new decode and fused-f_b decode paths. |
| aiter/ops/flydsl/kimi_k3_kda_decode.py | New high-level API wrapper with device/shape/dtype/stride validation and kernel launch. |
| aiter/ops/flydsl/kernels/kimi_k3_kda_decode.py | New FlyDSL kernel implementing fused conv + recurrent state update + RMSNorm/gate for decode. |
| aiter/ops/flydsl/kernels/kimi_k3_kda_decode_fb.py | New FlyDSL kernel that fuses the f_b projection into the decode workgroup. |
| aiter/ops/flydsl/init.py | Exposes the new public symbols behind the FlyDSL availability gate. |
Suppressed comments (1)
aiter/ops/flydsl/kimi_k3_kda_decode.py:376
batch = f_a.shape[0] if f_a.ndim == 2 else -1leads to the same misleading failure mode as the decode-only wrapper: rank!=2 inputs trip the "non-empty batch dimension" check rather than reporting the expected rank/shape forf_a. Adding an explicitf_a.ndimcheck makes the error actionable.
if not f_a.is_cuda:
raise ValueError("`f_a` must be a CUDA tensor.")
device = f_a.device
batch = f_a.shape[0] if f_a.ndim == 2 else -1
_check_same_device((("f_b_weight", f_b_weight),), device)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
JohnQinAMD
force-pushed
the
perf/kimi-k3-kda-fb-clean
branch
from
August 2, 2026 02:08
37943cc to
762b3e9
Compare
op_tests/op_benchmarks/flydsl/ does not exist on main, no CI job references it, and none of the 84 existing flydsl kernel modules ship a companion benchmark. The script is kept out of tree; measured numbers go in the PR description instead. Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
JohnQinAMD
marked this pull request as draft
August 2, 2026 16:01
5 tasks
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
Add gfx950 FlyDSL specializations for Kimi-K3 KDA decode and for the
incremental boundary that also computes the head-local
128 x 128f_bprojection. The latter removes a low-occupancy GEMV, global
g1materialization, and its dependency bubble.
The wrapper owns the exact device, shape, dtype, stride, cache, state-index,
and gate contract and fails closed otherwise. The two kernels keep separate
static ABIs and schedules.
Test plan
oracle at batch 1, 8, and 16, including graph replay and invalid contracts.
f_b+ decode against the complete fused boundary.Test results
MI355X/gfx950, TP8 batch-one decode, BF16 output/cache/gates, FP32 recurrent
state; 21 alternating paired trials:
f_b+ decodef_b+ decodegit diff --check, and DCO checks passed.Overlap and limits
vllm-project/vllm#50654 overlaps the decode-core ownership. Reviewers should
choose one core implementation; this PR's distinct incremental fused-
f_bboundary remains independently useful. No endpoint gain is attributed here.
Tool assistance
OpenAI Codex assisted with implementation, tests, benchmarking, and drafting this description.