Repository navigation
[Config] [Perf] Add Kimi K3 PTPC M128 tuning for gfx1250 - #8626
ZLkanyo009 wants to merge 2 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (2)
- Write the row the way the tuner does.
aiter/configs/model_configs/a8w8_bpreshuffle_tuned_gemm_kimik3.csv:1356is hand-written:us,tflops,bwanderrRatioare blank. It is the only row out of the 4959 merged keys (canonical plus the 11 model files) without them. Duplicate keys are ranked byus(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 emptyerrRatioalso 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. Thesk1in the kernel name already carries the split.- Fix: run
gemm_a8w8_bpreshuffle_tune.pyfor this one shape and commit its row. If you fill it in by hand, usesplitK=0, your measuredus=3.9349, and the matchingtflops/bwwitherrRatio=0.0. Then update the two body sentences ("splitK=1", "Keep us … blank") to match.
- 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).
|
The tuner-format and low-M follow-ups are complete on this PR. Commit The same-harness runs on frozen
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. |
|
Superseded as the review entry for this tuning batch by #8729 (head 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. |
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_bshape 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
aiter/configs/model_configs/a8w8_bpreshuffle_tuned_gemm_kimik3.csv(1354 to 1355 rows), preserving all existing rows.(gfx, cu_num, M, N, K, q_dtype_w):(gfx1250, 256, 128, 16384, 512, torch.float8_e4m3fn).libtype=flydsl,kernelId=856, andflydsl_bpreshuffle_wmma_t64x256x128_mw1_nw4_nb2_sk1_cm1_cn1. The CSV uses the gfx1250 WMMA tuner'ssplitK=0convention; the kernel name still encodes split-K 1. Recordus=3.9349,tflops=545.76,bw=3214.45GB/s anderrRatio=0.0from the accepted M128 measurement and its numerical checks.Performance (if applicable)
Measured on kernel/selection revision
58b89b757837and reused for this metadata-only update: gfx1250, 256 CUs, NUMA balancing 0; full TP1 M128/N16384/K512, FP8 PTPC, BF16 output, split1.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
226aa69a751fe7ce7ff356eeb594a0916a491798androcm/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
58b89b757837; metadata update checked on CPUrun_public_dispatch.py --phase gpupassed 140 allocating-public cases in two stages, covering 280 eager and NaN-poisoned graph comparisons.run_backend_abba.py --phase gpupassed 12 full-output comparisons across its four phases and collected 80 formal timing samples. Both ran on gfx1250 with FlyDSL 0.5.3, PyTorch2.11.0+rocm10.1.0a20260811-bkc.20260820, HIP7.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
This adds a tuning entry for an existing interface and kernel; it adds no user option or API behavior requiring guide changes.
Dependencies
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
58b89b7578377ba462e9109ba0023b6755921321and its preparation parent; this metadata-only follow-up has separate CPU checks. Before publication, upstream main was observed atdc83fa8face7dfef797f53ee1179478ea929a889(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. Offlineinstall_d04_cpu.pycompleted 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.linearand 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_FAULTcause 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-strictalias fallback observation is also source-only.The allocating
aiter.gemm_a8w8_bpreshufflelooks 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. Publicgemm_a8w8_bpreshuffle_outwas 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
58b89b757837emits splitK=0 for gfx1250 WMMA and computes metrics with input/weight/output bytes per element (1,1,2). Its exactGemmCommonTuner.calculatefunction 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, parent526972dad8f015fe735b4655708675b11d7c852b. The format-only head0566f294leaves 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.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.
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.