Skip to content

[Fix] Add gfx1250 K3 lm_head M128 tuning with strict TDM fallback - #8674

Open
ZLkanyo009 wants to merge 3 commits into
ROCm:mainfrom
ZLkanyo009:tune/kimi-k3-tp1-lm-head-m128-20261125
Open

ZLkanyo009 wants to merge 3 commits into
ROCm:mainfrom
ZLkanyo009:tune/kimi-k3-tp1-lm-head-m128-20261125

Conversation

@ZLkanyo009

@ZLkanyo009 ZLkanyo009 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Kimi K3 TP1 lm_head at M128/N163840/K7168 has no gfx1250 BF16 model-table row on the preparation base. Add the measured TDM configuration, keeping BF16 input, weights and output. The selector also skips borrowed TDM rows on gfx1250-strict, where the current TDM wrapper cannot launch, so that device retains its existing fallback.

The preparation base is main 7f1f7d159e2c2fd0a7aa3a8e47c6d2d23fb7416c. This changes one model CSV row, the borrowed-row guard and CPU regression tests. The row uses tile 128×256×128, 2 stages, 4×4 waves, split-K 1, no bias and no interleave. Measurement cells stay blank. Main's native spelling is:

flydsl_hgemm_abf16_wbf16_bf16_t128x256x128x2_ks1_w4x4x1_bias0_ktail0_gm0_ptdm_gfx1250

The dev spelling contains _i0_ptdm, which this main parser does not recognize. Only the persisted name is adapted to main's existing parser; no kernel implementation or external PR is imported. The exact main candidate has now passed the public correctness checks below. The dev integration is tracked separately in #8635; its accepted source is not a substitute for main validation.

Local CPU validation completed using the actual main selector, name parser and TDM shape validator, with scalar table/device adapters: the new name parses and round-trips; M65/112/113/127/128 satisfy the shape contract; all 44 regression subcases pass. The 20 borrowed-TDM strict subcases fail against the original main selector and pass after this change. Ordinary gfx1250 selection, non-TDM borrowed rows and exact strict fallback rows are preserved. The added repository tests are in op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py; the actual native no-device run also passes those three added methods (44 source-defined subcases), with no skips. It verifies all 33 native BF16 table inputs, 14 normal/strict/neighbor lookups, 14 scalar-padding comparisons and ten public compile-or-reuse calls on this exact candidate.

Historical performance motivation, not a result from this main candidate: on dev parent a3005ac8 with the fixed 1120 image and FlyDSL 0.5.3, a same-process seven-round comparison measured 450.207 → 259.321 µs, or 667.798 → 1159.365 TFLOPS (+73.61% throughput). The median paired latency reduction was 42.44%. Both arms used BF16 throughout; one 2.348 GB weight was reused for 16 graph calls, so this is not a cold-weight result. The baseline was the public Triton path and the candidate was the complete explicit FlyDSL call. Device timing excludes Python dispatch.

The exact main candidate 15c0cee462954da1dc945b74413a3db7f63d1dc9 passed 30 public cases and 90 full-output checks on gfx1250/CU256 with NUMA0, fixed native1120 image and FlyDSL 0.5.3. Coverage is M65/112/113/127/128, full N163840/K7168, three saved input pairs, out/allocating forms, eager execution and two independently NaN-poisoned graph replays. All 1,607,270,400 compared elements passed rtol=atol 0.01 with zero mismatches; maximum absolute error was 2.0, so this is not bit-exact equality. The saved CPU-FP64-derived references retain their original a3005 data provenance. The run exited 0, its container was removed, and no new matching GPU faults appeared in the retained log interval. No timing was collected.

The frozen main parent selects the complete Triton backend at these M values; the candidate selects the named FlyDSL backend. A separate paired experiment now compares those two complete backends in the same candidate-source process, with full N163840/K7168 and BF16 inputs, weights and outputs. This isolates the selected backends; it is not two branch executions, default-public dispatch timing or model/E2E timing.

M Parent-selected Triton (µs) Candidate-selected FlyDSL (µs) Paired latency reduction Maximum A/A drift
65 440.072 249.835 43.25% 0.71%
112 480.105 276.610 42.28% 0.47%
113 475.660 277.000 41.77% 0.67%
127 459.619 277.233 39.73% 0.56%
128 462.721 263.502 42.95% 1.00%

Latencies are pooled medians of 14 samples per arm; reductions are medians of seven within-round ABBA comparisons, so they need not equal the ratio of the displayed medians. Each graph contains 16 complete calls with a warm activation and one reused 2.348 GB weight. There is no independent cold-weight rotation or measured cache-cold guarantee. Three warmup replays, seven interleaved AB/BA rounds and seven A/A null rounds precede or accompany the seven paired rounds; Python dispatch, data loading and reference checks are outside GPU event timing.

All five runs passed 110 full-output checks over 1,964,441,600 elements using the three saved input pairs, eager calls, NaN-poisoned graph replays and post-timing checks. Zero mismatches were observed under rtol=atol 0.01. Every run exited 0 and its exact container was removed; no new matching faults appeared in the retained intervals. These are exact-M observations, not an exhaustive bucket or FP16 performance claim.

The original complete unittest module failed on both the pinned main parent and production candidate in the same no-device environment: parent 15 methods, one failure and eight subcase errors; candidate 18 methods, one failure and ten subcase errors. Those failures were traced to two stale test expectations: the OPUS test required a lower-level strict-dispatch rejection, and the legacy wrapper test mocked only the older launcher despite TDM names calling the TDM launcher. These original failures remain recorded.

Test-only follow-up f38e8112117393736946639bc3aa53ab1ebe70d0 aligns those two tests with the existing contracts. It keeps the real strict selector/fallback assertion and checks TDM routing, transposed weight shape/stride/storage, output, complete launch arguments and early strict rejection; the other 16 test methods are unchanged and no skips were added. The exact committed test bytes passed the complete native no-device module in an isolated source/cache copy: 18 methods, zero failures, zero errors and zero skips. All 8,951 source files were bound before and after that run, the container exited 0 and was removed, and no GPU or AOT stage ran. This follow-up changes only the test file; production files and table contents are byte-identical to measured commit 15c0cee462954da1dc945b74413a3db7f63d1dc9. The GPU results above remain attributed to that production commit.

Style-only follow-up c135d2f3b9f178c6b05c2707fe97d0669d6e0276 applies Black's requested formatting to one test call. The complete test module AST is unchanged from f38e8112117393736946639bc3aa53ab1ebe70d0, and production/table bytes remain unchanged. The new Black CI check passes; the native 18-method result remains attributed to the test-equivalent f38e811 run.

Public correctness, the bounded main backend comparison and the complete native unittest module are validated for the scopes above. This PR is ready for review. No model/E2E gain or strict-device GPU execution/support is claimed.

Related: https://github.com/wuhuikx/LLM-Booster/issues/710

@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 8674 --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 13:51
@ZLkanyo009
ZLkanyo009 requested a review from a team November 25, 2026 13:52
@github-actions github-actions Bot changed the title [Config][Fix] Add gfx1250 K3 lm_head M128 tuning with strict TDM fallback [Fix] Add gfx1250 K3 lm_head M128 tuning with strict TDM fallback Nov 25, 2026
@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision c135d2f3b9f1 · 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.

@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 c135d2f3b9f178c6b05c2707fe97d0669d6e0276 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.

@yzhou103

yzhou103 commented Dec 3, 2026

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.

Comment thread aiter/tuned_gemm.py
# TDM launches only on exact gfx1250; borrowed rows must not
# replace a strict device's existing fallback.
if (
borrowed_rows

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

key on runtime gfx instead of borrowed_rows? strict tdm row would raise instead of fallback, #8729 already does this

False,
self.SPLIT_K,
)
def test_strict_id_skips_borrowed_opus_row(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why drop the ValueError assert? looks like a AITER_AOT_REPLAY=1 env diff, maybe skipIf instead of removing

@yzhou103

yzhou103 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Hi @ZLkanyo009 please resolve the conflicts and comments

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants