Repository navigation
[Kernel][Perf] Add GLM-5 and Kimi-K3 MonoKernels - #1204
Merged
Merged
Conversation
coderfeli
force-pushed
the
codex/kimi-k3-mxfp4-fused
branch
from
September 27, 2026 01:14
51c7081 to
12f8f93
Compare
Signed-off-by: Felix Li <felix@local>
Add an opt-in ATOM full-layer benchmark and kernel profile so the sparse indexer cost is measured separately from the preselected-index decoder body. Make the Kimi CPU golden test independent of the process-wide default device.
Signed-off-by: Felix Li <felix@local>
Signed-off-by: Felix Li <felix@local>
融合 Kimi KDA 输出投影与 TP8 归约,并更新双语性能结果。
新增 Kimi-K3 KDA 完整层单次 GPU launch 实现,并保留按批量选择的最快 staged 路径。
保留按 batch 选择的 staged KDA 性能路径,修复完整单 launch 层的延迟初始化,并补充 S=8 覆盖。 同步格式化新 KDA 算子,并记录合入 GLM-5 #1205 后的最终性能结果。
移除与完整 GLM-5/Kimi-K3 层无关的通用 GEMM、MoE、旧 benchmark 与单元测试改动。 将 Kimi 专用 MLA、KDA、MoE 和通信实现归入 kernels/kimi_k3,并仅保留两个端到端 GPU 测试。
统一 GLM-5 与 Kimi-K3 MonoKernel 的共享目录、命名和公开接口。\n\n删除未使用的 KDA recurrence 适配器和通用 MLA/MoE wrapper,保留经过性能验证的 staged 基线与单 launch 路径。
为 Kimi-K3 MonoKernel 增加真正的顺序 MTP 状态链、单次 launch 的因果 KDA 管线,以及 TP8 正确性覆盖;保持普通 decode 与 MLA 路径性能不回退。
coderfeli
force-pushed
the
codex/kimi-k3-mxfp4-fused
branch
from
September 28, 2026 07:45
c240241 to
4ea131b
Compare
added 3 commits
September 28, 2026 07:57
补充 Kimi-K3 MonoKernel 的顺序 MTP 状态链接口、命令行用法和单 launch 调度说明。
Move GLM and Kimi-K3 under kernels/monokernel, promote reusable GEMM, MXFP8, collective, and AMDGPU primitives, and retain shape-specialized LDS layouts for the best MTP performance.\n\n将 GLM 和 Kimi-K3 统一整理到 kernels/monokernel,提取可复用的 GEMM、MXFP8、集合通信和 AMDGPU 基础模块,并保留按 shape 专门化的 LDS 布局以维持最佳 MTP 性能。
1 task
This was referenced Oct 4, 2026
This was referenced Oct 6, 2026
Open
6 tasks done
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.
Summary
This PR adds focused GLM-5 and Kimi-K3 decode MonoKernels for TP8 MI355X and now organizes them under one top-level package:
Sspeculative tokens,state_indiceshas shape[S + 1]: tokensreads the convolution/recurrent snapshot atstate_indices[s]and writes its complete post-token snapshot tostate_indices[s + 1].The public interfaces are intentionally narrow:
kernels.monokernel.glm.Glm5MonoKernelkernels.monokernel.k3.KimiK3MonoKernelGeneric gfx950 GEMM, MXFP8 projection, tagged symmetric all-reduce, low-level AMDGPU operations, packing, layouts, runtime/IPC, reference helpers, and weight contracts are shared at
kernels/monokernel/. Model-specific schedules and state semantics remain underglm/andk3/. Unused experimental storage-resolution helpers, shared-expert Torch code, and packing aliases were removed; no source-inspection tests were added.MTP schedule
The retained implementation preserves the real snapshot chain rather than treating speculative tokens as independent requests.
4 token pairs x 12 heads x 4 splits = 192 CTAs.TileRT design lineage
The resident-grid schedule, tagged-pair mailbox protocol, and phase-overlaid LDS arena follow the TileRT/GLM MonoKernel design lineage. The relevant GLM and Kimi source comments and
kernels/monokernel/README.mdreference:https://github.com/SemiAnalysisAI/InferenceX/tree/8ac98344b038a3f2da20a565fe9b974772a67ef9
The ordered KDA snapshot pipeline and state-resident MTP recurrence are Kimi-K3-specific FlyDSL extensions.
Launch count
Performance
Hardware: 8 x AMD Instinct MI355X, TP8, position 3000. Kimi results use HIP-graph replay with 32 layer invocations and 40 measured repeats; values are critical-rank medians.
True-MTP attention alone is 39.29 us at S=4 and 63.57 us at S=8. Relative to the previous retained MTP baseline (39.76/71.73 us), S=8 attention improves by 11.4%. The complete one-launch MTP layer improves from 164.94/260.99 us to 153.11/243.15 us at S=4/S=8.
Excluding the out-of-scope layer-0 dense FFN, weighting 24 MLA layers and 68 KDA layers gives a 92-layer independent-decode core estimate of 1.786x at S=4 and 1.827x at S=8 versus ATOM. This is not a full-model end-to-end result.
Validation
16 passed: complete GLM-5 and Kimi-K3 GPU integration suites.git diff --checkpass.main(e4245c23).Cold-link validation used a local external-LLVM compatibility bridge because the bundled parser cannot consume newer ROC-DL kernel metadata for some GEMM binaries. That local bridge is not included in this PR.
No new third-party dependencies.