Skip to content

[HIP] [FlyDSL] [GFX1250] Kimi-K3 DSpark PTPC/blockscale and f_b_proj GEMM rows - #7142

Merged
coderfeli merged 6 commits into
mainfrom
xiaobingsuper/gfx1250-k3-k128-mxscale-tune
Oct 30, 2026
Merged

coderfeli merged 6 commits into
mainfrom
xiaobingsuper/gfx1250-k3-k128-mxscale-tune

Conversation

@XiaobingSuper

@XiaobingSuper XiaobingSuper commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Kimi-K3 TP8 on gfx1250 had three related tuning gaps:

  • KDA f_b_proj (N=1536, K=128) runs as a 128x128 E8M0 blockscale GEMM. [Config] [GFX1250] Kimi-K3 TP8 gemm tune #6763 left it untuned because no FlyDSL mxfp8_128 kernel accepted K=128.
  • The TP8+DCP8 DSpark draft lacked complete PTPC and BF16 tuning coverage.
  • The same DSpark linears had no complete 128x128 E8M0 blockscale coverage for running ATOM with per_block_fp8 online quantization.

Technical Details

  • Includes ab74716 from gfx1250/flydsl-gemm-k128 (@aoli26): a two-buffer generic kernel runs K=128 as one K tile (prologue + drain). If that commit lands separately, this PR reduces to the tuner/config changes.
  • csrc/gemm_a8w8_mxfp8_bpreshuffle/gemm_a8w8_mxfp8_bpreshuffle_tune.py: on gfx1250, --mxscale_table tunes 128x128 shapes on the mxfp8_128 kernels used by 2-D dispatch. Rows retain their numeric kernels_list id; gfx950 is unchanged.
  • All shape sets use M = 1, 2, 4, ..., 32768 plus 48 (17 values).
  • KDA 128x128 E8M0 blockscale: N=1536, K=128.
  • DSpark PTPC FP8:
    • N=2112, K=7168 (fused_qkv_a_proj)
    • N=12288, K=1536 (q_b_proj, TP8+DCP8 QREP)
    • N=2048, K=512 (kv_b_proj, observed in the DSpark runtime log)
    • N=7168, K=1024 (o_proj)
    • N=3584, K=7168 (gate_up_proj)
    • N=7168, K=1792 (down_proj)
  • DSpark 128x128 E8M0 blockscale:
    • N=2176, K=7168 (fused_qkv_a_proj; logical N=2112 padded to the 128-row kernel tile)
    • N=12288, K=1536
    • N=7168, K=1024
    • N=3584, K=7168
    • N=7168, K=1792
  • DSpark BF16: N=7168, K=35840 (context_proj).
  • lm_head was already covered.

ATOM selects the new E8M0 table with per_block_fp8, ATOM_FP8_BLOCKSCALE_USE_E8M0_SCALE=1, and the default-enabled blockscale weight preshuffle.

Test Plan

  • MI455X, gfx1250, 256 CU, FlyDSL 0.4.0.
  • K=128 and DSpark blockscale:
    python3 csrc/gemm_a8w8_mxfp8_bpreshuffle/gemm_a8w8_mxfp8_bpreshuffle_tune.py --mxscale_table -i <shapes> -o <out> --mp 1
  • DSpark PTPC:
    python3 csrc/ck_gemm_a8w8_bpreshuffle/gemm_a8w8_bpreshuffle_tune.py -i <102 shapes> -o <out> --libtype flydsl
  • DSpark BF16:
    python3 csrc/gemm_a16w16/gemm_a16w16_tune.py -i <17 shapes> -o <out>
  • op_tests/tuning_tests/test_csv_validation.py and test_config_shape_collision.py.

Test Result

  • K=128: 17/17 shapes retuned, errRatio <= 4e-4. The new run improved M=8192 from 5.2454 to 4.6248 us and M=32768 from 14.4338 to 12.2369 us; faster prior picks were retained for the other M values.
  • DSpark PTPC: all six N/K pairs cover all 17 requested M values; 90 previously missing rows were added, all succeeded. The supplemental N=2048/K=512 run completed 17/17 with zero reported error.
  • DSpark 128x128 E8M0 blockscale: 85/85 shapes tuned successfully with FlyDSL. For the 15 pre-existing N=2176/K=7168 rows, 14 local winners replaced the prior rows and one faster prior row was retained; 70 rows were added. Maximum errRatio across the five pairs is 0.0087.
  • DSpark BF16: 17/17 shapes succeeded with zero reported error. Picks are 8 FlyDSL, 7 Opus, and 2 Triton rows.
  • Config validation: 49 passed, 50 subtests passed. No duplicate runtime keys.

Submission Checklist

aoli26 and others added 2 commits October 29, 2026 07:59
Kimi-K3 TP8's KDA f_b_proj (N=1536, K=128) runs gemm_a8w8_blockscale_
bpreshuffle with 128x128 E8M0 scales and had no gfx1250 row: no FlyDSL
mxfp8_128 kernel took K=128 until a two-buffer generic kernel could run it
as one K tile.

gemm_a8w8_mxfp8_bpreshuffle_tune.py --mxscale_table now tunes gfx1250's
128x128 table on the mxfp8_128 kernels the 2-D dispatch runs (row-major A),
and keeps their kernels_list id like the table's other gfx1250 rows; gfx950
is unchanged. It produced 17 rows (M 1..32768 and 48), added to the Kimi-K3
table sorted by (N, K, M).
@XiaobingSuper
XiaobingSuper requested review from a team and a balanced review from Copilot October 29, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 7142 --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.

@github-actions github-actions Bot changed the title [Config] [FlyDSL] [GFX1250] Kimi-K3 f_b_proj (N=1536, K=128) mxfp8_128 GEMM rows; gfx1250 in the mxfp8 tuner [HIP] [FlyDSL] [GFX1250] Kimi-K3 f_b_proj (N=1536, K=128) mxfp8_128 GEMM rows; gfx1250 in the mxfp8 tuner Oct 29, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@XiaobingSuper XiaobingSuper changed the title [HIP] [FlyDSL] [GFX1250] Kimi-K3 f_b_proj (N=1536, K=128) mxfp8_128 GEMM rows; gfx1250 in the mxfp8 tuner [HIP] [FlyDSL] [GFX1250] Kimi-K3 DSpark and f_b_proj GEMM rows Oct 29, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@XiaobingSuper XiaobingSuper changed the title [HIP] [FlyDSL] [GFX1250] Kimi-K3 DSpark and f_b_proj GEMM rows [HIP] [FlyDSL] [GFX1250] Kimi-K3 DSpark PTPC/blockscale and f_b_proj GEMM rows Oct 29, 2026
@XiaobingSuper
XiaobingSuper requested a review from aoli26 October 29, 2026 09:41
Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 12d3b830f5de · 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 architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  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

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

@aoli26 aoli26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

The seven gfx1250 OPUS rows added for N=7168 K=35840 carried pre-#6937
global kids (21172, 21177, 21317), which no longer exist in the gfx1250
a16w16 registry, so test_shipped_tuned_selection_diff_is_exhaustive
failed on them. Renumber them to the local kids of the same kernel
symbols (kid_for_name): 591, 596 and 716. Kernels and timings are
unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@coderfeli
coderfeli merged commit 59fae20 into main Oct 30, 2026
58 checks passed
@coderfeli
coderfeli deleted the xiaobingsuper/gfx1250-k3-k128-mxscale-tune branch October 30, 2026 13:31
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
…GEMM rows (#7142)

* Enable K=128 for gfx1250 FlyDSL GEMM

* [Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 rows for N=1536 K=128

Kimi-K3 TP8's KDA f_b_proj (N=1536, K=128) runs gemm_a8w8_blockscale_
bpreshuffle with 128x128 E8M0 scales and had no gfx1250 row: no FlyDSL
mxfp8_128 kernel took K=128 until a two-buffer generic kernel could run it
as one K tile.

gemm_a8w8_mxfp8_bpreshuffle_tune.py --mxscale_table now tunes gfx1250's
128x128 table on the mxfp8_128 kernels the 2-D dispatch runs (row-major A),
and keeps their kernels_list id like the table's other gfx1250 rows; gfx950
is unchanged. It produced 17 rows (M 1..32768 and 48), added to the Kimi-K3
table sorted by (N, K, M).

* [Config] Tune Kimi-K3 DSpark GEMMs on gfx1250

Co-authored-by: Cursor <cursoragent@cursor.com>

* [Config] Tune Kimi-K3 DSpark blockscale GEMMs on gfx1250

Co-authored-by: Cursor <cursoragent@cursor.com>

* [Config] Tune Kimi-K3 DSpark kv_b_proj PTPC GEMM

Co-authored-by: Cursor <cursoragent@cursor.com>

* [Config] Use per-arch OPUS kids in the Kimi-K3 gfx1250 BF16 rows

The seven gfx1250 OPUS rows added for N=7168 K=35840 carried pre-#6937
global kids (21172, 21177, 21317), which no longer exist in the gfx1250
a16w16 registry, so test_shipped_tuned_selection_diff_is_exhaustive
failed on them. Renumber them to the local kids of the same kernel
symbols (kid_for_name): 591, 596 and 716. Kernels and timings are
unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: aoli26 <Ao.Li@amd.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
aoli26 added a commit that referenced this pull request Nov 2, 2026
Conflicts, keeping both sides:
- kernel_fits_shape and the mxfp8 runner K-tile check: our partial last K
  tile (one split, 32x32 w_scale) plus main's generic K=128 two-buffer case
  (#7142).
- gemm_a8w8_mxfp8_bpreshuffle_tune.py: keep our gfx1250 32x32 + 128x128
  tuning (a superset of #7142's 128x128-only path); merge the docstrings and
  take main's warning text.
- test_gemm_a8w8_blockscale.py: union of the imports.
- dsv41 dense mxscale table: 3-way per key; of the 27 keys both sides added,
  the lower-us row wins (23 ours, 4 main); every row is kept verbatim.

Needed beyond the textual conflicts:
- The gfx950 FlyDSL blockscale block from #5969 uses b_preshuffle (renamed
  here) and reports BW like the other columns.
- The tuner's kernelId remap also covers gfx1250 32x32 rows ("mxfp8"); gfx1250
  128x128 rows keep main's kernels_list id.
- dsv41_batched (#7247) repeated 6 keys of dsv4_batched, which the runtime
  merge rejects; drop main's copies (ours have the lower us).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants