Skip to content

[Config] [Perf] Add Kimi K3 PTPC M128 tuning for gfx1250 - #8626

Open
ZLkanyo009 wants to merge 2 commits into
ROCm:mainfrom
ZLkanyo009:tune/kimi-k3-tp1-ptpc-kv-b-20261125
Open

ZLkanyo009 wants to merge 2 commits into
ROCm:mainfrom
ZLkanyo009:tune/kimi-k3-tp1-ptpc-kv-b-20261125

Conversation

@ZLkanyo009

@ZLkanyo009 ZLkanyo009 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add one Kimi K3 PTPC FP8 tuning row for gfx1250, 256 CUs, M128/N16384/K512. It selects the existing tile64x256x128 FlyDSL kernel in place of the natural tile128x512x128 fallback. On kernel/selection revision 58b89b757837, all 140 allocating-public correctness cases passed; one BF16 backend ABBA round measured 5.548275 to 3.934875 us (1.410026x). The requested low-M follow-up now measures 5.343925 to 3.884775 us at M65 and 5.450100 to 3.927850 us at M96; both passed independent result acceptance.

Motivation

The full TP1 kv_b shape in Kimi K3's conditional uncached-prefill/MHA path has no matching tuned row. The smaller tile improves the measured standalone backend workload. This mapping does not establish use or benefit in ordinary DSpark decode, cached/fused/sparse paths, serving, or model/end-to-end execution.

Changes

  • Append one row to aiter/configs/model_configs/a8w8_bpreshuffle_tuned_gemm_kimik3.csv (1354 to 1355 rows), preserving all existing rows.
  • Key (gfx, cu_num, M, N, K, q_dtype_w): (gfx1250, 256, 128, 16384, 512, torch.float8_e4m3fn).
  • Select libtype=flydsl, kernelId=856, and flydsl_bpreshuffle_wmma_t64x256x128_mw1_nw4_nb2_sk1_cm1_cn1. The CSV uses the gfx1250 WMMA tuner's splitK=0 convention; the kernel name still encodes split-K 1. Record us=3.9349, tflops=545.76, bw=3214.45 GB/s and errRatio=0.0 from the accepted M128 measurement and its numerical checks.

Performance (if applicable)

Measured on kernel/selection revision 58b89b757837 and reused for this metadata-only update: gfx1250, 256 CUs, NUMA balancing 0; full TP1 M128/N16384/K512, FP8 PTPC, BF16 output, split1.

Measurement Before After Speedup
Main: one before/after/after/before round 5.548275 us 3.934875 us 1.410026x
Historical native1120: separate revision and run 5.538250 us 3.947900 us 1.402834x

Main explicitly selected the installed production backend's baseline kernel 1260 and candidate 856, using one shared preallocated BF16 output. Each phase completed 0.5 seconds of synchronized warmup outside timing, then 20 GPU-event samples with 10 complete backend calls per sample (80 samples total). Values are medians of the two per-role phase medians; the AB and BA pairs were 1.400516x and 1.419638x. Timing includes complete GEMM, FP32 PTPC scale application and BF16 output stores. FP8 quantization, weight shuffling and reference construction were prepared outside timing.

This is one backend ABBA round. It does not measure allocating-public latency, a baseline public default dispatch, FP16/unmeasured-interior-M performance, model/end-to-end gain, or repeat-run uncertainty. The main result interval was 2026-11-24 18:20:22.005614-18:20:28.012887 UTC.

Historical native1120 used AITER 226aa69a751fe7ce7ff356eeb594a0916a491798 and rocm/fw-bringup:gfx1250-atom-k3-20261120; its scope also included full GEMM and FP32 PTPC scales with prepared operands. Recorded native evidence is retained separately from the main measurement.

Testing

  • Unit tests added or updated
  • Original M128 benchmark reused; new M65 and M96 same-harness BF16 complete-backend ABBA rounds independently accepted at 58b89b757837; metadata update checked on CPU
  • Tested on MI250X
  • Tested on MI300X

run_public_dispatch.py --phase gpu passed 140 allocating-public cases in two stages, covering 280 eager and NaN-poisoned graph comparisons. run_backend_abba.py --phase gpu passed 12 full-output comparisons across its four phases and collected 80 formal timing samples. Both ran on gfx1250 with FlyDSL 0.5.3, PyTorch 2.11.0+rocm10.1.0a20260811-bkc.20260820, HIP 7.16.26315, and NUMA balancing 0.

Local read-only checks passed for the exact base/head CSV diff: git diff --check, schema/key validation, unchanged existing rows, and the single appended row. The pinned PR self-review parser accepted this body. The repository hook's Python/C++ formatters do not apply to this CSV, and its opening lines have no copyright to update. The mutating hook and full CI were not run; these scoped checks are not a CI/readiness verdict.

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

This adds a tuning entry for an existing interface and kernel; it adds no user option or API behavior requiring guide changes.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None.

PR Self-Review

Reviewed revision

0566f29

Behavior and intent

The new row selects an existing smaller PTPC tile for the target lookup bucket. Existing padded-M lookup reaches it from M65-128, and the key has no output dtype, so both BF16 and FP16 are affected. Kernel code, dispatch guards, and public APIs are unchanged.

Validation and unverified scope

The original GPU validation below remains pinned to kernel/selection head 58b89b7578377ba462e9109ba0023b6755921321 and its preparation parent; this metadata-only follow-up has separate CPU checks. Before publication, upstream main was observed at dc83fa8face7dfef797f53ee1179478ea929a889 (2026-11-25T02:25:56.235096+00:00); the accepted commit was not rebased, and these results do not validate later upstream revisions.

Against base 526972dad8f015fe735b4655708675b11d7c852b, source/CSV and runtime-package review passed. Offline install_d04_cpu.py completed with Python 3.12, FlyDSL 0.5.3 and pandas 2.3.3; imports resolved to the isolated main tree. The canonical-plus-eleven-model merge matched all 4959 keys and every cell. The retained padding library covered 70 distinct shapes with 140 scalar calls, and 140 CPU lookups matched the plan.

The actual public loader/Python padding and dispatch then passed 140 disjoint GPU cases: both output dtypes for every M65-128, M64/M129 boundaries, and the four representative logical/physical K pairs described below. The 280 full-output comparisons checked 434,438,144 elements in total. All mismatch counts were zero under the original rtol=0.01, atol=0.01, maximum mismatch fraction=0.05 protocol against FP32 dequantized operands followed by F.linear and output casting. This is not bitwise equality: maximum absolute errors were 0.5 for BF16 and 0.0625 for FP16.

The original public result intervals on 2026-11-24 were 18:04:22.831101-18:04:30.207616 UTC (2 cases) and 18:15:22.262096-18:15:48.036131 UTC (138 cases). The backend ABBA's 12 additional comparisons also had zero mismatches under that protocol, with maximum absolute error 0.5. All three GPU stages exited naturally with code zero; their exact containers were removed, owned devices released, and the original NUMA balancing value 1 restored. Cleanup records were captured at 18:07:13.551739, 18:16:07.425550, and 18:21:03.200336 UTC respectively. The accepted health evidence contained no new severe errors; the retained historical HSA_STATUS_ERROR_MEMORY_FAULT cause remains unresolved, with no recovery claim.

Unverified: full CI/review readiness, other GPU architectures, exhaustive padded-K coverage, repeat-run performance uncertainty, allocating-public/FP16/unmeasured-interior-M performance, and model/end-to-end effects. No op tests changed; MI250X/MI300X results are absent because this tuning targets gfx1250.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

The key above participates in the default canonical-plus-model merge; model identity is not part of the key, so matching default callers can share the row. Source and actual CPU table/ABI checks establish selection of the new row at M65-128 and unchanged M64/M129 neighbors for N16384/K512. Actual allocating-public GPU records now cover both output dtypes across those shapes, with the expected bridge configuration and launch route. Other architectures, CU counts, N values and quantized dtypes retain their prior selection in source checks only. The existing gfx1250-strict alias fallback observation is also source-only.

The allocating aiter.gemm_a8w8_bpreshuffle looks up logical K first, then physical padded K. Actual M65 cases exercised logical/physical K pairs 128/512, 384/512, 512/640 and 512/768 for both output dtypes; this is representative, not exhaustive, padded-K coverage. Public gemm_a8w8_bpreshuffle_out was not called, and its existing gfx1250 rejection remains intact. Explicit config overrides and power-selection overlays are outside this default-merge validation.

Changed op tests

None.

Tuner-format follow-up

This follow-up changes only the appended row's five metadata fields; its key, kernel ID/name and all 1354 pre-existing row bytes stay unchanged. The tuner at 58b89b757837 emits splitK=0 for gfx1250 WMMA and computes metrics with input/weight/output bytes per element (1,1,2). Its exact GemmCommonTuner.calculate function produces 545.76 TFLOPS and 3214.45 GB/s from the accepted unrounded 3.9348749443888664 us candidate median; the CSV latency is rounded to four decimals. Bandwidth is the tuner's tensor-byte accounting, not measured HBM traffic.

The stored errRatio=0.0 is supported by the original M128 backend's 12 full-output checks, all with zero mismatches under rtol=atol=0.01 and maximum mismatch fraction=0.05. It does not claim a new tuner sweep or stricter/bitwise equality. The existing 140-case public results and source-version limits above retain their original verification times.

CPU checks confirm a unique target key among the original 4959 merged keys and identical arguments to the source-bound gfx1250 backend bridge before/after this metadata edit; split-K comes from the unchanged kernel name. No GPU work was rerun for this formatting update.

Low-M same-harness follow-up (2026-11-26)

M65 and M96 now have independently accepted before/after measurements using the same complete-backend harness and frozen kernel/selection source 58b89b7578377ba462e9109ba0023b6755921321, parent 526972dad8f015fe735b4655708675b11d7c852b. The format-only head 0566f294 leaves the selected kernel and backend arguments unchanged. These runs compare baseline kernel 1260 with candidate 856 at full N16384/K512, FP8 input/weights with FP32 PTPC scales and BF16 output, gfx1250/CU256, FlyDSL 0.5.3 and NUMA0. Both use the actual ceil-power-of-two M lookup target 128.

Actual M Baseline us Candidate us Before TFLOPS After TFLOPS Throughput increase AB / BA speedup
65 5.343925 3.884775 204.067058 280.716139 37.560732% 1.376298x / 1.374916x
96 5.450100 3.927850 295.519851 410.049453 38.755299% 1.387259x / 1.387847x

Each point is one before/after/after/before round: four phases, 0.5 seconds synchronized warmup per phase, 20 GPU-event samples per phase and 10 complete backend calls per sample. The reported latency is the median of the two per-role phase medians, exactly as in the original M128 result. Operands are warm and reused, with one shared preallocated output; quantization, shuffling, reference construction and allocation remain outside timing. This is not the separate rotating-weight protocol used by other tuning PRs.

Each point passed 12 full-output eager/graph/post-timing comparisons: 12,779,520 elements at M65 and 18,874,368 at M96, with zero mismatches at rtol=atol=0.01 and allowed mismatch fraction 0.05; maximum absolute error was 0.5, so this is not bitwise equality. Each result contains 80 formal samples. The original 140 allocating-public cases and their original verification times were reused, not rerun. M128 was not rerun.

  • M65 actual result interval: 2026-11-26T02:23:31.11869793Z to 2026-11-26T02:23:37.396369457Z; independent acceptance: 2026-11-26T02:37:20.063168+00:00.
  • M96 actual result interval: 2026-11-26T02:31:43.042815455Z to 2026-11-26T02:31:49.236210668Z; independent acceptance: 2026-11-26T02:39:20.634865+00:00.

Both containers exited naturally with code 0 and were removed; the retained release observations show no owned device FDs/KFD holders and NUMA0. The exact frozen installation and compiled cache were copied/reused. The actual launcher reported hasAotBinding=false; no new AOT or newly bound AOT launch is claimed.

These results address the requested M65 check and the additional M96 point at the same harness boundary. They do not establish every M65-128 performance point, allocating-public/FP16 timing, other source versions, model/E2E improvement or repeat-run uncertainty. CI and reviewer approval remain separate.

Primary logs for prior run 45572350074 confirm that MI35X shards 0/1/4/6/7 each timed out for 30 minutes downloading the Aiter wheel, then for another 30 minutes in its retry. Their test-container launch and test steps were skipped. These five historical failures therefore do not report a GEMM test failure; current-head CI is separate.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 8626 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@ZLkanyo009
ZLkanyo009 marked this pull request as ready for review November 25, 2026 07:58
@ZLkanyo009
ZLkanyo009 requested a review from a team November 25, 2026 07:58
@github-actions github-actions Bot changed the title [Perf] Add Kimi K3 PTPC M128 tuning for gfx1250 [Config] [Perf] Add Kimi K3 PTPC M128 tuning for gfx1250 Nov 25, 2026
@aiter-bot

aiter-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 0566f2943751 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

The new row selects an existing smaller PTPC tile for the target lookup bucket. Existing padded-M lookup reaches it from M65-128, and the key has no output dtype, so both BF16 and FP16 are affected. Kernel code, dispatch guards, and public APIs are unchanged.

Validation and unverified scope

The original GPU validation below remains pinned to kernel/selection head `58b89b7578377ba462e9109ba0023b6755921321` and its preparation parent; this metadata-only follow-up has separate CPU checks. Before publication, upstream main was observed at `dc83fa8face7dfef797f53ee1179478ea929a889` (2026-11-25T02:25:56.235096+00:00); the accepted commit was not rebased, and these results do not validate later upstream revisions.

Against base `526972dad8f015fe735b4655708675b11d7c852b`, source/CSV and runtime-package review passed. Offline `install_d04_cpu.py` completed with Python 3.12, FlyDSL 0.5.3 and pandas 2.3.3; imports resolved to the isolated main tree. The canonical-plus-eleven-model merge matched all 4959 keys and every cell. The retained padding library covered 70 distinct shapes with 140 scalar calls, and 140 CPU lookups matched the plan.

The actual public loader/Python padding and dispatch then passed 140 disjoint GPU cases: both output dtypes for every M65-128, M64/M129 boundaries, and the four representative logical/physical K pairs described below. The 280 full-output comparisons checked 434,438,144 elements in total. All mismatch counts were zero under the original rtol=0.01, atol=0.01, maximum mismatch fraction=0.05 protocol against FP32 dequantized operands followed by `F.linear` and output casting. This is not bitwise equality: maximum absolute errors were 0.5 for BF16 and 0.0625 for FP16.

The original public result intervals on 2026-11-24 were 18:04:22.831101-18:04:30.207616 UTC (2 cases) and 18:15:22.262096-18:15:48.036131 UTC (138 cases). The backend ABBA's 12 additional comparisons also had zero mismatches under that protocol, with maximum absolute error 0.5. All three GPU stages exited naturally with code zero; their exact containers were removed, owned devices released, and the original NUMA balancing value 1 restored. Cleanup records were captured at 18:07:13.551739, 18:16:07.425550, and 18:21:03.200336 UTC respectively. The accepted health evidence contained no new severe errors; the retained historical `HSA_STATUS_ERROR_MEMORY_FAULT` cause remains unresolved, with no recovery claim.

**Unverified:** full CI/review readiness, other GPU architectures, exhaustive padded-K coverage, repeat-run performance uncertainty, allocating-public/FP16/unmeasured-interior-M performance, and model/end-to-end effects. No op tests changed; MI250X/MI300X results are absent because this tuning targets gfx1250.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

The key above participates in the default canonical-plus-model merge; model identity is not part of the key, so matching default callers can share the row. Source and actual CPU table/ABI checks establish selection of the new row at M65-128 and unchanged M64/M129 neighbors for N16384/K512. Actual allocating-public GPU records now cover both output dtypes across those shapes, with the expected bridge configuration and launch route. Other architectures, CU counts, N values and quantized dtypes retain their prior selection in source checks only. The existing `gfx1250-strict` alias fallback observation is also source-only.

The allocating `aiter.gemm_a8w8_bpreshuffle` looks up logical K first, then physical padded K. Actual M65 cases exercised logical/physical K pairs 128/512, 384/512, 512/640 and 512/768 for both output dtypes; this is representative, not exhaustive, padded-K coverage. Public `gemm_a8w8_bpreshuffle_out` was not called, and its existing gfx1250 rejection remains intact. Explicit config overrides and power-selection overlays are outside this default-merge validation.

Changed op tests

None.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Action required before merge (2)

  1. Write the row the way the tuner does. aiter/configs/model_configs/a8w8_bpreshuffle_tuned_gemm_kimik3.csv:1356 is hand-written:
    • us, tflops, bw and errRatio are blank. It is the only row out of the 4959 merged keys (canonical plus the 11 model files) without them. Duplicate keys are ranked by us (aiter/jit/core.py:628-643), and NaN sorts last. So if another file ever adds this key, this row loses, and the auto-dedup write-back (core.py:645-666) deletes it from kimik3.csv. The empty errRatio also leaves no accuracy record for the row.
    • splitK=1: the tuner writes 0 for every gfx1250 WMMA row (csrc/ck_gemm_a8w8_bpreshuffle/gemm_a8w8_bpreshuffle_tune.py:633), and all 154 existing gfx1250 flydsl rows have 0. The sk1 in the kernel name already carries the split.
    • Fix: run gemm_a8w8_bpreshuffle_tune.py for this one shape and commit its row. If you fill it in by hand, use splitK=0, your measured us=3.9349, and the matching tflops/bw with errRatio=0.0. Then update the two body sentences ("splitK=1", "Keep us … blank") to match.
  2. Post one before/after number at the low end of the bucket. Padded lookup sends every M from 65 to 128 to this row (M113-128 at gl=0, M65-112 at gl=1). At M=65, tile_m 64 launches a second M block that is almost empty, where main's tile128 fallback (id 1260) uses one. The ABBA covers only M=128. Run the same harness at M=65 (and ideally M=96).

Checked and fine:

  • The key format and column order match all 12 merged files.
  • kernelId 856 is the name in the row (gfx1250 kernels_list, 1420 entries), and the tile fits M65-128 with N16384/K512, K640 and K768.
  • Main's default for this shape is id 1260, as the body says.
  • No duplicate key exists, and no other shape or arch changes selection. Probe: 4958 keys before, 4959 after, the only change being this added key.
  • The body's lookup claims (logical K then physical K, both output dtypes, the strict alias through base_gfx_arch) match the code.

The MI35X shards 0/1/4/6/7 failed by timing out on "Download Aiter wheel artifact". That is infrastructure, not this PR; please re-run them.


Reviewed at 58b89b7 (standard, two independent passes with CPU lookup/kernel-list probes). Already fixed: n/a (first review).

@ZLkanyo009

Copy link
Copy Markdown
Contributor Author

The tuner-format and low-M follow-ups are complete on this PR. Commit 0566f294 fills only the appended row's five metadata cells; the kernel, key and all 1354 existing rows are unchanged. splitK=0 follows the pinned tuner's convention while the unchanged kernel name encodes split-K 1. The recorded M128 values come from the accepted result and exact tuner calculation, not a new sweep.

The same-harness runs on frozen 58b89b75 now give:

Actual M / N / K Baseline us Candidate us Before → after TFLOPS Throughput increase
65 / 16384 / 512 5.343925 3.884775 204.067 → 280.716 +37.56%
96 / 16384 / 512 5.450100 3.927850 295.520 → 410.049 +38.76%

Both use FP8 input/weights, FP32 PTPC scales, BF16 output, NUMA0 and the original warm-operand ABBA protocol: 80 formal samples and 12 complete-output checks per point, zero tolerance mismatches. Full public correctness retains its original 140-case evidence. The source/cache were reused without a new AOT; M128 was not rerun. The body records the exact source, timing intervals and limits. These are complete-backend exact-M observations, not allocating-public, whole-bucket, FP16 or model/E2E timings; CI/review approval is still separate.

Primary logs for prior run 45572350074 confirm that MI35X shards 0/1/4/6/7 each timed out for 30 minutes downloading the Aiter wheel, then for another 30 minutes in its retry. Their test-container launch and test steps were skipped. These five historical failures therefore do not report a GEMM test failure; current-head CI is separate.

@ZLkanyo009

Copy link
Copy Markdown
Contributor Author

Superseded as the review entry for this tuning batch by #8729 (head 0cbdcc3ea501d0cf2c957af7e5c65dea51147add). The consolidated main PR includes this PR's final changes at 0566f2943751d82c9f95aab7aaffc4e0cd969773 and links the original validation and review history. Its CPU composition checks preserve the final configuration choices; the original GPU results keep their measured-source and protocol limits.

Please use the consolidated PR for review of this batch. This source PR remains open for provenance; no merge or closure is performed here, and the two should not be merged independently.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants