Skip to content

Add Kimi-K2 Thinking entry to per-model kernel benchmark sweep - #3431

Merged
okorzh-amd merged 2 commits into
ROCm:mainfrom
okorzh-amd:add-kimi-k2-perf-shapes
Jun 16, 2026
Merged

okorzh-amd merged 2 commits into
ROCm:mainfrom
okorzh-amd:add-kimi-k2-perf-shapes

Conversation

@okorzh-amd

Copy link
Copy Markdown
Contributor

Motivation

Add Kimi-K2 Thinking to model_shapes.json so the per-model kernel sweep in op_tests/op_benchmarks/triton/model_benchmarking_tool exercises every aiter Triton kernel Kimi K2 hits in production serving (MLA projections, dense FFN, shared-expert FFN, 384-expert MoE GEMM, RMSNorm, RoPE, MHA prefill, MLA decode). Without this entry the sweep silently drops Kimi K2 and per-kernel regressions on Kimi go unnoticed even though the model is part of the active perf workload.

Technical Details

Shape numbers were derived directly from the moonshotai/Kimi-K2-Thinking config.json: hidden=7168, dense intermediate=18432, moe_intermediate=2048, 64 heads, 384 routed experts, top_k=8, MLA q_lora=1536, kv_lora=512, qk_nope=128, qk_rope=64, v_head=128. Coverage is 13 kernels x 33 shapes.

Test Plan

Add two regression tests in test_kernel_benchmarks.py:

  • test_kimi_k2_model_shapes_entry: no-GPU structural guard that fails immediately if the Kimi entry is removed or any hot-path shape changes silently. Asserts MLA (64,1,576,512), MHA (64,64,192,128), MoE (E=384, TopK=8, Dim1=7168, Dim2=4096) and the q_b/kv_b/o_proj GEMM shapes, plus that every declared kernel is in KERNEL_DICT and the --model kimi regex matches exactly one model.
  • test_bench_models_kimi_k2_rmsnorm_runs: end-to-end smoke that drives bench_models.run_benchmarks() through Kimi rmsnorm and asserts every
    row has positive throughput, validating the full path: JSON load ->
    model regex -> handler dispatch -> Triton kernel run.

Test Result

Verified passing on MI355X (ROCm 7.2, PyTorch 2.10, Triton 3.6):
test_kimi_k2_model_shapes_entry PASSED
test_bench_models_kimi_k2_rmsnorm_runs PASSED
2 passed, 3 deselected in 13.67s

Full Kimi sweep at B=1, S=1024, TP=1 runs in ~17s on MI355X; a typical B in [1, 32, 128] x S in [1024, 8192] grid is ~1m40s.

3 rows produced, all positive throughput (test passes):

{"Model": "Kimi-K2 Thinking", "Kernel": "rmsnorm", "batch_size": null, "seq_len": null, "M": 1024, "N": 7168, "throughput": 2.632281}
{"Model": "Kimi-K2 Thinking", "Kernel": "rmsnorm", "batch_size": null, "seq_len": null, "M": 1024, "N": 1536, "throughput": 0.845229}
{"Model": "Kimi-K2 Thinking", "Kernel": "rmsnorm", "batch_size": null, "seq_len": null, "M": 1024, "N": 512, "throughput": 0.312582}

Add Kimi K2.6 (Kimi-K2 Thinking) to model_shapes.json so the per-model
kernel sweep in op_tests/op_benchmarks/triton/model_benchmarking_tool
exercises every aiter Triton kernel Kimi K2 hits in production serving
(MLA projections, dense FFN, shared-expert FFN, 384-expert MoE GEMM,
RMSNorm, RoPE, MHA prefill, MLA decode). Without this entry the sweep
silently drops Kimi K2.6 and per-kernel regressions on Kimi go unnoticed
even though the model is part of the active perf workload.

Shape numbers were derived directly from the moonshotai/Kimi-K2-Thinking
config.json: hidden=7168, dense intermediate=18432, moe_intermediate=2048,
64 heads, 384 routed experts, top_k=8, MLA q_lora=1536, kv_lora=512,
qk_nope=128, qk_rope=64, v_head=128. Coverage is 13 kernels x 33 shapes.

Add two regression tests in test_kernel_benchmarks.py:

- test_kimi_k2_model_shapes_entry: no-GPU structural guard that fails
  immediately if the Kimi entry is removed or any hot-path shape changes
  silently. Asserts MLA (64,1,576,512), MHA (64,64,192,128), MoE
  (E=384, TopK=8, Dim1=7168, Dim2=4096) and the q_b/kv_b/o_proj GEMM
  shapes, plus that every declared kernel is in KERNEL_DICT and the
  --model kimi regex matches exactly one model.
- test_bench_models_kimi_k2_rmsnorm_runs: end-to-end smoke that drives
  bench_models.run_benchmarks() through Kimi rmsnorm and asserts every
  row has positive throughput, validating the full path: JSON load ->
  model regex -> handler dispatch -> Triton kernel run.

Verified passing on MI355X (ROCm 7.2, PyTorch 2.10, Triton 3.6):
  test_kimi_k2_model_shapes_entry        PASSED
  test_bench_models_kimi_k2_rmsnorm_runs PASSED
  2 passed, 3 deselected in 13.67s

Full Kimi sweep at B=1, S=1024, TP=1 runs in ~17s on MI355X; a typical
B in [1, 32, 128] x S in [1024, 8192] grid is ~1m40s.

Co-authored-by: Claude (Cursor) <[email protected]>
Co-authored-by: Cursor <[email protected]>
@okorzh-amd
okorzh-amd requested review from a team and lucas-santos-amd May 30, 2026 03:02
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 3431 --add-label <label>

Collapse one-line list comprehension onto a single line so
`psf/black@stable` (the CI pre-check) leaves the file unchanged.

Co-authored-by: Claude (Cursor) <[email protected]>
Co-authored-by: Cursor <[email protected]>
@lalala-sh
lalala-sh requested a review from amd-ruitang3 June 2, 2026 02:10
@okorzh-amd
okorzh-amd merged commit 971d98b into ROCm:main Jun 16, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants