Repository navigation
[FlyDSL] [Perf] Consolidate Kimi K3 TP1 GEMM tuning on gfx1250 - #8729
ZLkanyo009 wants to merge 2 commits into
Conversation
Combine the final accepted changes from main PRs ROCm#8557, ROCm#8561, ROCm#8626, ROCm#8672, ROCm#8674, ROCm#8677, ROCm#8703, ROCm#8705, ROCm#8706, ROCm#8709, ROCm#8710 and ROCm#8711. Preserve already-merged ROCm#8566 and exclude regressing proposals and external kernel dependencies. Reuse source-specific GPU evidence and independently verify default table merging, selection composition and strict TDM fallback on CPU.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
|
@valar-cop review |
| gfx1250,256,64,12288,1536,128x128,flydsl,151,1,4.8351,flydsl_mxfp8_128_bpreshuffle_wmma_t64x128x512_mw1_nw4_nb3_sk1_cm1_cn1,499.66,4249.25,0.0033 | ||
| gfx1250,256,128,12288,1536,128x128,flydsl,146,1,5.4992,flydsl_mxfp8_128_bpreshuffle_wmma_t64x128x256_mw1_nw4_nb4_sk1_cm1_cn1,878.64,4039.99,0.0033 | ||
| gfx1250,256,256,12288,1536,128x128,flydsl,209,1,6.5077,flydsl_mxfp8_128_bpreshuffle_wmma_t128x128x256_mw2_nw2_nb3_sk1_cm1_cn1,1484.96,3927.51,0.0033 | ||
| gfx1250,256,256,12288,1536,128x128,flydsl,210,1,,flydsl_mxfp8_128_bpreshuffle_wmma_t128x128x256_mw2_nw2_nb4_sk1_cm1_cn1,,, |
There was a problem hiding this comment.
blank us/tflops/bw/errRatio? these become the only blank-timing rows, intentional?
There was a problem hiding this comment.
The blanks are intentional: the source PRs report controlled backend comparisons at their measured revisions, while these CSV columns normally hold tuner measurements. After removing the two redundant M192 rows, 15 rows retain empty fields: 13 E8M0 rows, PTPC M64 and BF16 lm_head M128. I am using the review's option to explain the fields and preserve the original evidence below.
The merge consequence is real: empty us becomes NaN and sorts last, so a later timed duplicate can displace a blank row. The checked default merges have no such duplicate keys; leaving the cells empty does not protect against a future collision. I have kept the target measurements unknown instead of copying cross-revision timings into them.
Original latency evidence for all 15 remaining rows (microseconds)
| Source PR | Scheme / operation | M / N / K | Before → After (us) | Measured revision |
|---|---|---|---|---|
| #8672 | E8M0 / q_b | 256 / 12288 / 1536 | 6.0510 → 5.6370 | 36f572cc |
| #8672 | E8M0 / down | 64 / 7168 / 14336 | 199.0480 → 34.5990 | 36f572cc |
| #8672 | E8M0 / down | 256 / 7168 / 14336 | 48.3810 → 25.9690 | 36f572cc |
| #8672 | E8M0 / gate_up | 64 / 28672 / 7168 | 104.9480 → 20.0880 | 36f572cc |
| #8672 | E8M0 / gate_up | 128 / 28672 / 7168 | 23.9320 → 20.8020 | 36f572cc |
| #8672 | E8M0 / o_proj | 64 / 7168 / 8192 | 114.8000 → 21.2620 | 36f572cc |
| #8672 | E8M0 / o_proj | 256 / 7168 / 8192 | 27.8250 → 16.0440 | 36f572cc |
| #8677 | E8M0 / down | 384 / 7168 / 14336 | 49.3140 → 27.3130 | dff7809d |
| #8677 | E8M0 / o_proj | 384 / 7168 / 8192 | 29.2790 → 16.8020 | dff7809d |
| #8677 | PTPC / kv_b | 64 / 16384 / 512 | 6.2240 → 3.9000 | dff7809d |
| #8703 | E8M0 / MLA q_b | 3072 / 18432 / 1536 | 44.4459 → 41.2320 | 15bdebaa |
| #8706 | E8M0 / gate_up | 96 / 28672 / 7168 | 79.4981 → 43.6020 | 3649f511 |
| #8709 | E8M0 / o_proj | 96 / 7168 / 8192 | 86.1315 → 22.3979 | 1f1f2808 |
| #8710 | E8M0 / down | 96 / 7168 / 14336 | 145.3407 → 36.3051 | c672ef74 |
| #8674 | BF16 / lm_head | 128 / 163840 / 7168 | 462.7210 → 263.5020 | 15c0cee4 |
These are pooled per-arm latency medians from seven ABBA rounds and seven A/A controls, with 14 samples per arm. FP8 uses BF16 output and at least 2.2 GB of rotating independent weight/scale storage; BF16 lm_head reuses one 2.348 GB weight. Quantization, references and Python dispatch are outside timing. These values are source-revision evidence, not measurements of this consolidation; paired-round gain statistics are separate from ratios of these displayed medians.
The source accuracy reports include nonzero tolerance mismatch fractions, and do not supply an equivalent per-row tuner errRatio or measured bandwidth for every row. Filling those fields with zero would be inaccurate. TFLOPS can be calculated from latency and shape, but that would not supply the missing tuner measurements.
| gfx950,256,2048,6144,7168,torch.float8_e4m3fn,flydsl,1640,0,83.6916,flydsl_bpreshuflle_128x192x256_F8_F8_B16_1x1x4x1_default,2155.4,1002.32,0.0 | ||
| gfx950,256,4096,6144,7168,torch.float8_e4m3fn,flydsl,727,0,152.9355,flydsl_bpreshuflle_128x256x128_F8_F8_B16_1x2x4x2_default,2359.02,809.05,0.0 | ||
| gfx950,256,8192,6144,7168,torch.float8_e4m3fn,flydsl,727,0,284.9048,flydsl_bpreshuflle_128x256x128_F8_F8_B16_1x2x4x2_default,2532.62,714.01,0.0 | ||
| gfx1250,256,128,16384,512,torch.float8_e4m3fn,flydsl,856,0,3.9349,flydsl_bpreshuffle_wmma_t64x256x128_mw1_nw4_nb2_sk1_cm1_cn1,545.76,3214.45,0.0 |
There was a problem hiding this comment.
splitK=0 but kernelName is sk1? set splitK=1 like the M64 row
There was a problem hiding this comment.
Updated the M64 row to splitK=0; M128 remains at 0. This matches the gfx1250 PTPC tuner's CSV convention. On this path, dispatch reads kernelName, whose sk1 suffix encodes physical split factor 1; the CSV zero is metadata, not that physical factor. The M64 kernel remains 740.
The actual default merge and M1–16384 CPU lookup checks preserve dispatch. In this five-file fix, only the metadata read through the DSpark kv_b M33–64 bucket changes from 1 to 0. No GPU timing or new kernel choice is claimed for this correction.
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (5)
Consolidating the twelve Kimi K3 tuning PRs into one entry is the right shape. I checked every source diff against this head: all 27 row changes and #8674's selector/test changes are here, nothing extra, and no duplicate gfx1250 keys after merging with the other default tables.
- Make the TDM capability one predicate instead of a selector copy.
aiter/tuned_gemm.py:195-203restates the wrapper's rule (aiter/ops/flydsl/gemm_kernels.py:287-289, TDM requires exact gfx1250) asborrowed_rows and policy in TDM_POLICIES.- The two can drift: an exact gfx1250-strict TDM row (not borrowed) still passes the selector and then raises in the wrapper.
- Ask: add one helper in
gemm_kernels.py(e.g.hgemm_policy_supported(policy, gfx)), call it fromflydsl_hgemmfor the raise and from the selector withruntime_gfx, without a borrowed-row special case. Your four tests and the five Qwen keys keep the same result.
- Answer the splitK thread with splitK=0 on the M64 row.
a8w8_bpreshuffle_tuned_gemm_kimik3.csv:1356-1357: on gfx1250 the PTPC path only readskernelName(gemm_op_a8w8.py:190-194), and every other gfx1250 wmma row in these tables uses splitK=0. The M64 row (splitK=1) is the outlier. - Drop the two redundant M192 E8M0 rows.
(192,12288,1536)and(192,7168,14336)name the same kernel and id as the M256 row of the same N/K. Every M that hits them would reach the M256 row through the coarse-M lookup anyway. "Direct source coverage" is not a reason for a table row. - Fill or explain the blank timing columns. 15 rows (13 E8M0, including the replaced M256 q_b row, plus PTPC M64 and the BF16 lm_head row) have empty us/tflops/bw/errRatio. The merger turns an empty
usinto NaN, which sorts last (aiter/jit/core.py:628-640), so a later timed duplicate replaces these rows without a warning, and the table keeps no accuracy record. Please copy the numbers from the source PRs, or reply on valar-cop's thread. - Shorten and correct the squash text. The body calls the guard "the lm_head selector's existing guard", but this PR adds it to main. At ~12k characters, with a duplicated self-review and the GPU evidence log, it is too long for a commit message. Keep the tables/keys that change, the guard and the source PR links, and move the evidence to a comment.
Verified: the five Qwen BF16 keys (M1-16, N128 K4096) go from a wrapper RuntimeError to the Triton default on gfx1250-strict. Exact gfx1250 is unchanged. CI is green.
Source PRs #8674, #8705, #8706, #8709, #8710 and #8711 (and the other six) should be closed when this merges, not merged separately. #8705 and #8711 contribute no row once item 3 is done.
Root cause vs patch
The consolidation and the measured rows are the right fix. The strict guard does fix a real crash, but it copies the wrapper's arch rule into the selector instead of having one predicate that both use. Verdict: right direction, with a patch-like part (item 1).
Reviewed at 0cbdcc3 (round 1, pass A). Supersede check: 12 source diffs compared line by line. valar-cop's two threads are covered by items 2 and 4.
Share the runtime-architecture predicate between selector and wrapper, cover exact strict rows, normalize PTPC M64 splitK metadata, and remove redundant M192 entries. Preserve all public FP8 kernel selections.
ZLkanyo009
left a comment
There was a problem hiding this comment.
Addressed the five review items in f7fc42fa:
- The selector and wrapper share
hgemm_policy_supported(policy, gfx). The selector passes the actual runtime architecture, so exact and borrowed strict TDM rows both fall through safely. - PTPC M64 now uses
splitK=0, matching M128 and the gfx1250 tuner convention; kernel740 is unchanged. - Removed the two redundant E8M0 M192 rows. The separate five-file scope check preserves dispatch for all 15 FP8 shapes over M1–16384 and all 675 measured points.
- Replied on the metadata thread with the original before/after evidence for all 15 remaining blank rows, including the NaN-ranking consequence and accuracy/protocol limits.
- Shortened the PR body to changed keys, the guard, source links and validation; it now correctly says this PR adds the guard to main.
The complete native CPU module (19 tests) and a fallback supplement (3 tests) passed with zero failures, errors or skips; independent review accepted 22 methods and 4909 subtests. The run used full 0cbdcc3e source plus a reviewed private combination, with an explicit gfx1250 fixture, mocked GPU launches and no GPU devices. The 1120 image's FlyDSL 0.5.0 was supplemented by a private offline 0.5.3 install. The two runtime Python files and native test module are byte-identical to this fix; the FP8 CSV differences add no rows to its HGEMM corpus. Separate default-merge and full-M checks cover this fix's two CSV changes.
The private main38/dev44 tuning proposals are not part of this commit. The CPU results establish the reviewed lookup/routing behavior; combined-head GPU correctness and model performance remain unmeasured. Source PR closure waits for this consolidation to merge.
Consolidate Kimi K3 TP1 tuning on gfx1250/CU256 into one main review entry: 22 E8M0 rows, two PTPC rows and one BF16 lm_head row. This also adds a shared TDM capability check to main. Exact or borrowed
gfx1250-strictTDM rows now fall through to the next valid candidate or default backend; the selector and wrapper use the same rule.E8M0 uses
128x128weight-scale blocks. PTPC uses FP8 E4M3FN weights and the gfx1250 tuner'ssplitK=0metadata convention;kernelNameencodes the physical split factor. The redundant M192 rows from #8705 and #8711 are removed because padded-M lookup reaches the same kernels through M256. #8566 is already in the base; #8586, #8601 and #8634 remain on their separate dependency lines, and #8635 remains the dev integration.Validation: the complete native CPU lookup module (19 tests) and a source-bound fallback supplement (3 tests) passed with zero failures, errors or skips; independent review accepted all 22 methods and 4909 subtests. The run used the 1120 image with a private offline FlyDSL 0.5.3 install, an explicit gfx1250 architecture fixture and mocked GPU launches, with no GPU devices. It ran the complete
0cbdcc3esource plus a reviewed private combination. Its two runtime Python files and the test module are byte-identical to this review fix; the differing FP8 CSVs contribute no HGEMM rows to that test corpus. A separate check of this five-file fix passed the actual FP8 default merges and preserved dispatch for all 15 FP8 shapes over M1–16384 (including the 675 measured points).GPU correctness and performance evidence remains attached to the measured revisions in the source PRs. This consolidation has no combined-head GPU or model performance result. The blank measurement fields and their original before/after evidence are explained in the metadata review thread. Tracking: LLM-Booster #710.