Skip to content

[FlyDSL] [Perf] Consolidate Kimi K3 TP1 GEMM tuning on gfx1250 - #8729

Open
ZLkanyo009 wants to merge 2 commits into
ROCm:mainfrom
ZLkanyo009:tune/kimi-tp1-main-consolidated-20261126
Open

ZLkanyo009 wants to merge 2 commits into
ROCm:mainfrom
ZLkanyo009:tune/kimi-tp1-main-consolidated-20261126

Conversation

@ZLkanyo009

@ZLkanyo009 ZLkanyo009 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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-strict TDM rows now fall through to the next valid candidate or default backend; the selector and wrapper use the same rule.

Table / N / K Changed M Source PRs
E8M0 / 7168 / 33792 4096, 8192, 16384 #8557
E8M0 / 67584 / 7168 1024, 2048, 4096, 8192, 16384 #8557
E8M0 / 12288 / 128 128 #8561
E8M0 / 12288 / 1536 256 #8672
E8M0 / 7168 / 14336 64, 96, 256, 384 #8672, #8677, #8710
E8M0 / 28672 / 7168 64, 96, 128 #8672, #8706
E8M0 / 7168 / 8192 64, 96, 256, 384 #8672, #8677, #8709
E8M0 / 18432 / 1536 3072 #8703
PTPC / 16384 / 512 64, 128 #8626, #8677
BF16 / 163840 / 7168 128 #8674

E8M0 uses 128x128 weight-scale blocks. PTPC uses FP8 E4M3FN weights and the gfx1250 tuner's splitK=0 metadata convention; kernelName encodes 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 0cbdcc3e source 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.

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.
@ZLkanyo009
ZLkanyo009 requested a review from a team November 26, 2026 03:27
@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 8729 --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.

@aiter-bot

aiter-bot commented Nov 26, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision f7fc42fa16ca · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

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

@yzhou103

Copy link
Copy Markdown
Contributor

@valar-cop review

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

a few small things..

ci green.

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,,,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blank us/tflops/bw/errRatio? these become the only blank-timing rows, intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

splitK=0 but kernelName is sk1? set splitK=1 like the M64 row

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 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 (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.

  1. Make the TDM capability one predicate instead of a selector copy. aiter/tuned_gemm.py:195-203 restates the wrapper's rule (aiter/ops/flydsl/gemm_kernels.py:287-289, TDM requires exact gfx1250) as borrowed_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 from flydsl_hgemm for the raise and from the selector with runtime_gfx, without a borrowed-row special case. Your four tests and the five Qwen keys keep the same result.
  2. 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 reads kernelName (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.
  3. 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.
  4. 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 us into 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.
  5. 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 ZLkanyo009 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot changed the title [Perf] Consolidate Kimi K3 TP1 GEMM tuning on gfx1250 [FlyDSL] [Perf] Consolidate Kimi K3 TP1 GEMM tuning on gfx1250 Nov 30, 2026

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.

5 participants