Skip to content

[Triton/Gluon] [Config] Tune gfx1250 a16w16 GEMMs for Kimi K2 - #6595

Merged
vgokhale merged 22 commits into
mainfrom
erizheng-bf16-gemm-tune
Nov 16, 2026
Merged

vgokhale merged 22 commits into
mainfrom
erizheng-bf16-gemm-tune

Conversation

@erizheng-amd

@erizheng-amd erizheng-amd commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds tuned Gluon gemm_a16w16 and gemm_a16w16_persistent configs for Kimi-K2 BF16 GEMMs on gfx1250 96-CU partitions. It covers 12 (N, K) shapes:

  • the nine Kimi-K2 TP8 GEMM shapes: (1536, 1536), (2048, 512), (7168, 1024), (4608, 7168), (7168, 2304), (7168, 256), (2112, 7168), (512, 7168) and (384, 7168);
  • the three TP4 attention projections: (3072, 1536), (4096, 512) and (7168, 2048).

The OPUS rows for these shapes are in #7514.

Motivation

On a gfx1250 96-CU partition, main has no tuned config for most of these GEMMs, or has one only for some M:

  • Gluon gemm_a16w16: the 96cu tree has no file for (2048, 512), (3072, 1536), (4096, 512) or (7168, 2048), so those shapes use DEFAULT.json at every M. It has files for the other eight TP8 shapes, but five of them define only M ≤ 128, M_LEQ_8192 and any, so M = 129–4096 uses DEFAULT.json. For the nine TP8 shapes, the configs in this PR differ from what main serves in 80 of 126 buckets, mostly at M ≥ 256.
  • Gluon gemm_a16w16_persistent: there is no 96cu tree, so 96-CU devices read the plain tree. That tree was tuned on 256 CUs and has no file for any of these shapes, so they all use its DEFAULT.json.

Changes

All changes are limited to gfx1250 with cu_num=96, under aiter/ops/triton/configs/gfx1250/96cu/gluon/gemm/. Selections on 256 CUs are the same as on main.

  • Gluon gemm_a16w16 (96cu):
    • The nine TP8 shapes: a new file for (2048, 512), and new configs in the existing files for the other eight. Each file has all 14 buckets (M_LEQ_1 to M_LEQ_8192, and any) and no fallback.
    • The three TP4 shapes: new files for (3072, 1536), (4096, 512) and (7168, 2048). Their buckets are M_LEQ_4, M_LEQ_8, M_LEQ_16, M_LEQ_8192 and any, with DEFAULT_FALLBACK, so M = 1 and M = 17–4096 use DEFAULT.json.
    • DEFAULT.json is unchanged.
  • Gluon gemm_a16w16_persistent (96cu): a new tree with files for all 12 shapes, with the same bucket layout as above. Its DEFAULT.json is a byte-for-byte copy of the plain tree's.

Validation

  • For the nine TP8 shapes, every bucket in this PR's files is the config the tuner wrote: 126 of 126 in each tree. The tuner checked each config in three ways:
    • Correctness: before timing, the config was compared with an fp32 reference on the TN layout that Kimi uses. The relative Frobenius error had to be below 2e-2.
    • Acceptance: a config replaced the served one only if both of these held: its median gain was larger than max(2%, the interquartile spread of the round medians), and it was faster in at least 5 of the 7 rounds.
    • Loading: after the file was written, get_gemm_config on the 96-CU device returned that config for every bucket.
  • Without a GPU, at the PR head:
    • all 25 changed files parse as JSON;
    • every bucket has every key that DEFAULT.json defines;
    • the 96cu persistent DEFAULT.json is byte-identical to the plain one;
    • no file outside gfx1250/96cu/gluon/gemm/ changes.
  • Not yet run on the PR head: verify_configs.py --expect-tuned, the shape-collision unittest and the Gluon a16w16 and persistent correctness tests.

Performance

q_b_proj, 1536 x 1536

M Default µs Gluon µs Persistent µs Gain vs default
1 2.41 2.41 2.57 +0%
4 2.58 2.46 2.58 +5%
8 2.73 2.48 2.59 +10%
16 2.54 2.54 2.60 +0%
32 2.71 2.71 2.77 +0%
64 3.08 3.08 3.09 +0%
128 3.92 3.92 3.99 +0%
256 9.38 4.73 4.82 +98%
512 8.03 6.60 6.82 +22%
1024 18.75 9.11 9.09 +106%
2048 21.69 15.02 14.85 +46%
4096 42.04 26.84 25.88 +62%
8192 61.69 53.73 49.85 +24%
16384 203.0 107.7 98.33 +106%

kv_b_proj, 2048 x 512

M Default µs Gluon µs Persistent µs Gain vs default
1 2.00 1.91 2.17 +5%
4 2.07 1.96 2.15 +6%
8 2.09 1.97 2.15 +6%
16 2.12 2.02 2.18 +5%
32 2.25 2.09 2.20 +8%
64 2.33 2.28 2.41 +3%
128 2.58 2.58 5.06 +0%
256 5.27 3.26 6.26 +61%
512 5.42 4.44 4.41 +23%
1024 9.07 6.28 6.27 +45%
2048 15.72 10.47 10.03 +57%
4096 27.68 18.64 17.41 +59%
8192 70.15 31.67 28.14 +149%
16384 145.5 61.62 56.06 +160%

o_proj, 7168 x 1024

M Default µs Gluon µs Persistent µs Gain vs default
1 3.24 3.24 3.88 +0%
4 3.58 3.50 3.92 +3%
8 3.64 3.64 3.93 +0%
16 4.02 3.75 4.11 +7%
32 4.25 4.10 4.40 +4%
64 4.98 4.98 5.23 +0%
128 6.55 6.55 6.40 +2%
256 33.90 9.97 10.05 +240%
512 27.52 17.69 16.64 +65%
1024 65.55 28.41 28.99 +131%
2048 87.94 52.13 49.90 +76%
4096 158.2 92.98 84.06 +88%
8192 202.6 184.4 164.0 +24%
16384 753.4 347.0 312.5 +141%

dense gate_up, 4608 x 7168

M Default µs Gluon µs Persistent µs Gain vs default
1 9.24 9.24 9.54 +0%
4 9.42 9.42 9.68 +0%
8 9.88 9.64 9.82 +2%
16 10.60 10.36 10.39 +2%
32 11.76 11.38 11.65 +3%
64 14.13 14.13 15.09 +0%
128 22.20 22.20 21.79 +2%
256 74.76 32.03 31.78 +135%
512 92.72 55.48 55.91 +67%
1024 191.8 94.80 100.4 +102%
2048 226.3 185.4 179.8 +26%
4096 450.8 317.4 328.7 +42%
8192 797.2 638.9 650.2 +25%
16384 1924.3 1289.2 1295.9 +49%

dense down, 7168 x 2304

M Default µs Gluon µs Persistent µs Gain vs default
1 5.40 5.40 6.16 +0%
4 5.59 5.44 6.18 +3%
8 5.57 5.57 6.20 +0%
16 5.93 5.93 6.28 +0%
32 6.91 6.52 7.04 +6%
64 8.44 8.44 9.45 +0%
128 11.72 11.72 11.53 +2%
256 51.39 19.10 19.37 +169%
512 51.82 32.91 33.29 +57%
1024 112.4 57.83 57.69 +95%
2048 147.6 103.6 101.5 +45%
4096 272.7 182.7 180.2 +51%
8192 417.5 364.7 349.7 +19%
16384 1165.4 710.3 673.4 +73%

shared-expert down, 7168 x 256

M Default µs Gluon µs Persistent µs Gain vs default
1 2.01 2.01 2.44 +0%
4 2.07 2.07 2.42 +0%
8 2.08 2.08 2.44 +0%
16 2.14 2.14 2.47 +0%
32 2.38 2.38 2.55 +0%
64 2.79 2.79 2.77 +1%
128 3.67 3.52 3.28 +12%
256 6.89 4.48 4.33 +59%
512 10.70 5.94 6.69 +80%
1024 21.50 11.01 12.32 +95%
2048 39.26 19.10 18.83 +108%
4096 86.17 31.05 29.93 +188%
8192 59.48 59.48 58.75 +1%
16384 448.5 115.9 112.2 +300%

fused q_a + kv_a, 2112 x 7168

M Default µs Gluon µs Persistent µs Gain vs default
1 5.60 5.60 5.78 +0%
4 5.85 5.85 5.90 +0%
8 6.01 6.01 5.92 +2%
16 6.13 6.13 6.30 +0%
32 6.99 6.99 7.77 +0%
64 9.53 9.53 10.41 +0%
128 12.99 12.99 13.96 +0%
256 26.19 20.76 21.06 +26%
512 45.55 31.36 31.79 +45%
1024 61.48 54.01 54.72 +14%
2048 126.9 99.37 102.1 +28%
4096 234.8 178.4 178.3 +32%
8192 381.2 315.3 327.5 +21%
16384 776.1 637.2 661.5 +22%

shared-expert gate_up, 512 x 7168

M Default µs Gluon µs Persistent µs Gain vs default
1 4.52 4.52 4.29 +5%
4 4.55 4.55 4.37 +4%
8 4.55 4.55 4.39 +4%
16 4.60 4.60 4.42 +4%
32 5.00 5.00 4.55 +10%
64 5.74 5.53 5.35 +7%
128 6.49 6.49 6.90 +0%
256 13.88 9.59 9.72 +45%
512 21.14 12.47 13.40 +70%
1024 26.83 20.26 20.42 +32%
2048 42.83 30.02 30.16 +43%
4096 70.75 54.25 52.36 +35%
8192 120.7 93.51 100.2 +29%
16384 197.5 185.2 179.1 +10%

MoE router, 384 x 7168

M Default µs Gluon µs Persistent µs Gain vs default
1 4.46 4.46 4.07 +10%
4 4.48 4.48 4.14 +8%
8 4.49 4.49 4.16 +8%
16 4.53 4.53 4.18 +8%
32 4.91 4.73 4.44 +11%
64 5.22 5.22 4.70 +11%
128 6.27 6.27 5.74 +9%
256 12.27 7.83 7.93 +57%
512 11.82 11.28 10.71 +10%
1024 15.37 15.37 15.65 +0%
2048 30.24 23.13 24.37 +31%
4096 39.06 33.82 34.92 +15%
8192 83.00 61.99 63.16 +34%
16384 136.5 129.3 125.5 +9%

PR Self-Review

Reviewed revision

7a8722e

Behavior and intent

This PR adds tuned Gluon gemm_a16w16 and gemm_a16w16_persistent configs for 12 Kimi-K2 BF16 GEMM shapes on gfx1250 96-CU partitions. They are the nine TP8 shapes (1536, 1536), (2048, 512), (7168, 1024), (4608, 7168), (7168, 2304), (7168, 256), (2112, 7168), (512, 7168) and (384, 7168), and the three TP4 attention projections (3072, 1536), (4096, 512) and (7168, 2048).

On main, 96-CU devices mostly get untuned configs for these shapes. In gemm_a16w16, four of the shapes have no 96cu file, and five more have no buckets for M = 129–4096, so those cases use DEFAULT.json. gemm_a16w16_persistent has no 96cu tree, so it reads the 256-CU tree, which has none of these shapes.

What changes:

  • gemm_a16w16 (96cu): new or retuned files for all 12 shapes. The TP8 files cover all 14 M buckets. The TP4 files cover M_LEQ_4, M_LEQ_8, M_LEQ_16, M_LEQ_8192 and any, and use DEFAULT.json for the rest.
  • gemm_a16w16_persistent (96cu): a new tree with the same 12 shapes and a byte-identical copy of the plain DEFAULT.json. 21 buckets use split-K.
  • For the nine TP8 shapes, the geomean gain over main is +25% for gemm_a16w16 and +35% for persistent, mostly at M ≥ 256.

Nothing changes on 256-CU devices or other architectures. The OPUS rows are in #7514.

Side effects, on 96-CU gfx1250 only:

  • A CU tree is read whole, so the 9 shape files in the plain persistent tree no longer apply on 96 CUs: (1024, 7168), (128, 2880), (128, 4096), (128, 5120), (1280, 2880), (256, 7168), (2880, 1024), (2880, 4096) and (5120, 2880). Those shapes now use DEFAULT.json.

  • Configs are not keyed on memory layout, and tuning ran only on TN, the layout Kimi uses. Every bucket fits in LDS on TN. On other layouts, 15 bucket and layout pairs that work on main now exceed LDS and raise OutOfResources:

    • gemm_a16w16: (2112, 7168) M_LEQ_256 NT; (512, 7168) M_LEQ_256 NT and TT; (512, 7168) M_LEQ_1024 NT.
    • persistent, TT: (1536, 1536) M_LEQ_32 and M_LEQ_64; (2048, 512) M_LEQ_256; (2112, 7168) M_LEQ_1 to M_LEQ_16; (384, 7168) M_LEQ_128; (4608, 7168) M_LEQ_32; (512, 7168) M_LEQ_64; (7168, 1024) M_LEQ_64.

    The tuner's LDS filter leaves out layout padding and the persistent kernel's C buffer. These 15 pairs are not fixed at this revision.

Validation and unverified scope

Hardware: gfx1250, 96-CU partition, bf16.

  • Tuning (nine TP8 shapes): every bucket is the config the tuner wrote. Each candidate passed an fp32-reference check on TN (relative error < 2e-2). To replace the served config, it had to be faster by more than max(2%, the run-to-run spread) and win at least 5 of 7 rounds. Afterwards, get_gemm_config returned the written config for every bucket.
  • Launch check at ef6beed: I ran every bucket of the 24 shape files through gemm_a16w16(x, w, config=..., persistent=...) at the bucket's largest M (16384 for any). I used every layout each kernel accepts and compared the output with an fp32 torch matmul. All 282 TN launches ran, and every launch that ran had relative error ≤ 1.72e-3. All 33 failures were OutOfResources on non-TN layouts: the 15 regressions above, plus 18 that also fail on main.
  • Static checks at ef6beed: all 25 changed files are under gfx1250/96cu/gluon/gemm/, parse as JSON and have every DEFAULT.json key. The 96cu persistent DEFAULT.json is byte-identical to the plain one.
  • CI: MI35X Triton shards 3–6 failed because the runner lost its connection. MI35X is gfx950 and does not read these files. The other checks passed or were skipped, and two jobs are still running.

Unverified:

  • The 15 non-TN regressions are not fixed.
  • verify_configs.py --expect-tuned, the shape-collision unittest and the Gluon a16w16 op tests were not run at ef6beed, so the config=None lookup is untested at this revision.
  • Not measured: the TP4 shapes' performance (their M = 1 and M = 17–4096 are not tuned), the 9 plain-tree persistent shapes on DEFAULT.json, fp16, and an end-to-end Kimi-K2 run.
  • For persistent (2112, 7168) at M = 8192 and 16384, the gain comes from screening-pass timings, not the final rounds.
  • Because DEFAULT.json has no NUM_KSPLIT, a future tuner sweep would benchmark the 21 split-K buckets at split 1. Runtime is unaffected.

PR-specific question

These configs are read only by gemm_a16w16 in aiter/ops/triton/gemm/basic/gemm_a16w16.py, on the Gluon backend (the default on gfx1250), and only when the caller passes no config. With persistent=False it looks up GEMM-A16W16, and with persistent=True it looks up GEMM-A16W16-PERSISTENT.

tuned_gemm runs the non-persistent kernel for any shape and M that has no row in the BF16 tuned CSV, and it never selects the persistent kernel. Where a CSV row exists, the row takes precedence over these configs. Examples are the FlyDSL rows for (2112, 7168) at M = 64 and 256, and the OPUS rows in #7514.

The workload key has four parts:

  • the gfx1250 architecture;
  • a device CU count of 96: only then does resolve_config_dir() pick the 96cu tree, and only if that tree has a DEFAULT.json;
  • an exact (N, K) match in the file name;
  • the M bucket: the smallest M_LEQ_x with M ≤ x, otherwise any. In the TP4 files, missing buckets come from DEFAULT.json.

Dtype and memory layout are not part of the key.

Unrelated shapes keep their previous selection:

  • git diff --name-only against the merge base lists 25 files, all under gfx1250/96cu/gluon/gemm/. 256-CU devices and other architectures therefore read the same files as on main.
  • In the 96cu gemm_a16w16 tree, DEFAULT.json and every other shape file are unchanged, so every other shape resolves as before.
  • The new 96cu persistent DEFAULT.json is byte-identical (cmp) to the plain one that 96-CU devices read before. Persistent shapes without a plain-tree shape file therefore get the same config.

The exception is the 9 plain-tree persistent shapes listed above, which now use DEFAULT.json on 96 CUs.

Changed op tests

None

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

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.

🟡 Changes recommended

The new sparse configs replace intermediate default buckets with oversized tiles that add padded work.

1 open finding
What changed in this PR

Tunes gfx1250 Gluon A16W16 GEMM configurations for Kimi K2 workloads.

Changes:

  • Adds shape-specific configurations for three GEMMs.
  • Retunes selected buckets for the existing 2112 × 7168 configuration.
  • Adjusts tile sizes, buffer counts, warp counts, and kernel selection.
File Description
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=7168-K=2048.json Adds five tuned M buckets.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=4096-K=512.json Adds kv_b_proj shape tuning.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=3072-K=1536.json Adds five tuned M buckets.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=2112-K=7168.json Retunes small-M entries and large-M warp counts.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@aiter-bot

aiter-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 7a8722ee600f · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

This PR adds tuned Gluon `gemm_a16w16` and `gemm_a16w16_persistent` configs for 12 Kimi-K2 BF16 GEMM shapes on gfx1250 96-CU partitions. They are the nine TP8 shapes (1536, 1536), (2048, 512), (7168, 1024), (4608, 7168), (7168, 2304), (7168, 256), (2112, 7168), (512, 7168) and (384, 7168), and the three TP4 attention projections (3072, 1536), (4096, 512) and (7168, 2048).

On `main`, 96-CU devices mostly get untuned configs for these shapes. In `gemm_a16w16`, four of the shapes have no 96cu file, and five more have no buckets for M = 129–4096, so those cases use `DEFAULT.json`. `gemm_a16w16_persistent` has no 96cu tree, so it reads the 256-CU tree, which has none of these shapes.

What changes:

* `gemm_a16w16` (96cu): new or retuned files for all 12 shapes. The TP8 files cover all 14 M buckets. The TP4 files cover `M_LEQ_4`, `M_LEQ_8`, `M_LEQ_16`, `M_LEQ_8192` and `any`, and use `DEFAULT.json` for the rest.
* `gemm_a16w16_persistent` (96cu): a new tree with the same 12 shapes and a byte-identical copy of the plain `DEFAULT.json`. 21 buckets use split-K.
* For the nine TP8 shapes, the geomean gain over `main` is +25% for `gemm_a16w16` and +35% for persistent, mostly at M ≥ 256.

Nothing changes on 256-CU devices or other architectures. The OPUS rows are in #7514.

Side effects, on 96-CU gfx1250 only:

* A CU tree is read whole, so the 9 shape files in the plain persistent tree no longer apply on 96 CUs: (1024, 7168), (128, 2880), (128, 4096), (128, 5120), (1280, 2880), (256, 7168), (2880, 1024), (2880, 4096) and (5120, 2880). Those shapes now use `DEFAULT.json`.
* Configs are not keyed on memory layout, and tuning ran only on TN, the layout Kimi uses. Every bucket fits in LDS on TN. On other layouts, 15 bucket and layout pairs that work on `main` now exceed LDS and raise `OutOfResources`:
  * `gemm_a16w16`: (2112, 7168) `M_LEQ_256` NT; (512, 7168) `M_LEQ_256` NT and TT; (512, 7168) `M_LEQ_1024` NT.
  * persistent, TT: (1536, 1536) `M_LEQ_32` and `M_LEQ_64`; (2048, 512) `M_LEQ_256`; (2112, 7168) `M_LEQ_1` to `M_LEQ_16`; (384, 7168) `M_LEQ_128`; (4608, 7168) `M_LEQ_32`; (512, 7168) `M_LEQ_64`; (7168, 1024) `M_LEQ_64`.

  The tuner's LDS filter leaves out layout padding and the persistent kernel's C buffer. These 15 pairs are not fixed at this revision.

Validation and unverified scope

Hardware: gfx1250, 96-CU partition, bf16.

* **Tuning (nine TP8 shapes):** every bucket is the config the tuner wrote. Each candidate passed an fp32-reference check on TN (relative error < 2e-2). To replace the served config, it had to be faster by more than max(2%, the run-to-run spread) and win at least 5 of 7 rounds. Afterwards, `get_gemm_config` returned the written config for every bucket.
* **Launch check at ef6beedb2:** I ran every bucket of the 24 shape files through `gemm_a16w16(x, w, config=..., persistent=...)` at the bucket's largest M (16384 for `any`). I used every layout each kernel accepts and compared the output with an fp32 `torch` matmul. All 282 TN launches ran, and every launch that ran had relative error ≤ 1.72e-3. All 33 failures were `OutOfResources` on non-TN layouts: the 15 regressions above, plus 18 that also fail on `main`.
* **Static checks at ef6beedb2:** all 25 changed files are under `gfx1250/96cu/gluon/gemm/`, parse as JSON and have every `DEFAULT.json` key. The 96cu persistent `DEFAULT.json` is byte-identical to the plain one.
* **CI:** MI35X Triton shards 3–6 failed because the runner lost its connection. MI35X is gfx950 and does not read these files. The other checks passed or were skipped, and two jobs are still running.

Unverified:

* The 15 non-TN regressions are not fixed.
* `verify_configs.py --expect-tuned`, the shape-collision unittest and the Gluon a16w16 op tests were not run at ef6beedb2, so the `config=None` lookup is untested at this revision.
* Not measured: the TP4 shapes' performance (their M = 1 and M = 17–4096 are not tuned), the 9 plain-tree persistent shapes on `DEFAULT.json`, fp16, and an end-to-end Kimi-K2 run.
* For persistent (2112, 7168) at M = 8192 and 16384, the gain comes from screening-pass timings, not the final rounds.
* Because `DEFAULT.json` has no `NUM_KSPLIT`, a future tuner sweep would benchmark the 21 split-K buckets at split 1. Runtime is unaffected.

PR-specific question

These configs are read only by `gemm_a16w16` in `aiter/ops/triton/gemm/basic/gemm_a16w16.py`, on the Gluon backend (the default on gfx1250), and only when the caller passes no `config`. With `persistent=False` it looks up `GEMM-A16W16`, and with `persistent=True` it looks up `GEMM-A16W16-PERSISTENT`.

`tuned_gemm` runs the non-persistent kernel for any shape and M that has no row in the BF16 tuned CSV, and it never selects the persistent kernel. Where a CSV row exists, the row takes precedence over these configs. Examples are the FlyDSL rows for (2112, 7168) at M = 64 and 256, and the OPUS rows in #7514.

The workload key has four parts:

* the gfx1250 architecture;
* a device CU count of 96: only then does `resolve_config_dir()` pick the `96cu` tree, and only if that tree has a `DEFAULT.json`;
* an exact (N, K) match in the file name;
* the M bucket: the smallest `M_LEQ_x` with M ≤ x, otherwise `any`. In the TP4 files, missing buckets come from `DEFAULT.json`.

Dtype and memory layout are not part of the key.

Unrelated shapes keep their previous selection:

* `git diff --name-only` against the merge base lists 25 files, all under `gfx1250/96cu/gluon/gemm/`. 256-CU devices and other architectures therefore read the same files as on `main`.
* In the 96cu `gemm_a16w16` tree, `DEFAULT.json` and every other shape file are unchanged, so every other shape resolves as before.
* The new 96cu persistent `DEFAULT.json` is byte-identical (`cmp`) to the plain one that 96-CU devices read before. Persistent shapes without a plain-tree shape file therefore get the same config.

The exception is the 9 plain-tree persistent shapes listed above, which now use `DEFAULT.json` on 96 CUs.

Changed op tests

None

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

erizheng-amd and others added 6 commits October 30, 2026 13:38
This shape was tuned on a 96-CU partition, and gfx1250/96cu already has a
tuned GEMM-A16W16-N=2112-K=7168.json (#6573), so the 256-CU file goes back
to its main version.

Co-authored-by: Cursor <[email protected]>
DEFAULT.json is a byte-identical copy of
gfx1250/gluon/gemm/gemm_a16w16_persistent/DEFAULT.json, to start the 96-CU
tree for the Kimi-K2 shapes tuned on a 96-CU partition.

Co-authored-by: Cursor <[email protected]>
Pure git mv. These shapes were tuned on a 96-CU partition.

Co-authored-by: Cursor <[email protected]>
@erizheng-amd erizheng-amd changed the title [Triton/Gluon] [Config] Tune gfx1250 Gluon a16w16 GEMMs for Kimi K2 [Triton/Gluon] [OPUS] [Config] Tune gfx1250 a16w16 GEMMs for Kimi K2 Oct 30, 2026
@erizheng-amd
erizheng-amd requested a balanced review from Copilot October 30, 2026 15:23

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.

🟡 Changes recommended

The tuning configs omit required waves_per_eu values, and the PR mixes OPUS changes with Gluon configs contrary to the one-backend-per-PR rule.

3 open issues

Review effort: Balanced

Comment thread csrc/opus_gemm/opus_gemm_common.py Resolved
@erizheng-amd
erizheng-amd marked this pull request as ready for review October 30, 2026 18:08
@erizheng-amd
erizheng-amd requested review from a team and a balanced review from Copilot October 30, 2026 18:08
@github-actions github-actions Bot changed the title [Triton/Gluon] [OPUS] [Config] Tune gfx1250 a16w16 GEMMs for Kimi K2 [Triton/Gluon] [OPUS] Tune gfx1250 a16w16 GEMMs for Kimi K2 Oct 30, 2026

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.

🔵 Needs a closer look

The 12 reported Gluon correctness failures lack case details and baseline results, and GPU validation is unavailable here to determine whether the new configs introduce regressions.

1 open issue
2 resolved since last review

Review effort: Balanced

@erizheng-amd
erizheng-amd requested a review from azaidy October 30, 2026 18:12
erizheng-amd and others added 2 commits October 30, 2026 20:02
…aligned to BLOCK_SIZE_K

The non-EVEN_K path masked the A/B data loads but loaded the e8m0 scales
unmasked, so the last K iteration read scale groups past the end of the
scale tensors. Garbage 0xFF bytes (NaN in e8m0) propagate through
tl.dot_scaled even where the data is zero, producing NaN rows in the
output, and fresh allocations can page-fault. Mask the scale loads and
fill with 127 (scale 1.0), matching gemm_afp4wfp4 and batched_gemm_a16wfp4.

Co-authored-by: Cursor <[email protected]>
One backend per PR: this PR keeps the gfx1250 96cu Gluon a16w16 and
a16w16_persistent configs. The OPUS kernel registration, the Kimi-K2
OPUS rows in kimik2_bf16_tuned_gemm.csv and the policy parity test
change move to the erizheng-bf16-gemm-opus branch.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot changed the title [Triton/Gluon] [OPUS] Tune gfx1250 a16w16 GEMMs for Kimi K2 [Triton/Gluon] [Config] Tune gfx1250 a16w16 GEMMs for Kimi K2 Nov 5, 2026
@github-actions github-actions Bot added Config and removed OPUS labels Nov 5, 2026

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.

🔵 Needs a closer look

Twelve unresolved non-TN Gluon correctness failures lack baseline comparisons, and nine persistent-shape fallback changes on 96-CU gfx1250 lack benchmarks, requiring GPU validation unavailable in this review.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:45

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.

🔵 Needs a closer look

The 12 unresolved non-TN Gluon correctness failures and fallback changes for nine unbenchmarked persistent shapes require baseline comparisons and gfx1250 96-CU validation to establish regression risk.

1 open issue

Review effort: Balanced

@erizheng-amd

Copy link
Copy Markdown
Contributor Author

Please create separate PRs for separate backends

Done, the OPUS side tuning results are now in #7514

@zufayu
zufayu requested review from a team and vgokhale November 7, 2026 06:49
Copilot AI balanced review requested due to automatic review settings November 9, 2026 19:41

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.

🟡 Changes recommended

Several tuned GEMM buckets exceed gfx1250’s LDS limit for supported BF16 layouts and need retuning and validation through the public wrappers.

8 open issues
1 resolved since last review

Review effort: Balanced

@erizheng-amd

Copy link
Copy Markdown
Contributor Author

Gentle ping for some reviews please @azaidy @vgokhale

@vgokhale
vgokhale merged commit a9aef4a into main Nov 16, 2026
@vgokhale
vgokhale deleted the erizheng-bf16-gemm-tune branch November 16, 2026 15:46
yzhou103 pushed a commit that referenced this pull request Nov 19, 2026
* [OPUS] Tune gfx1250 a16w16 GEMMs for Kimi K2 on 96 CUs

Register the gfx1250 a16w16 kernels for 96 CUs as well as 256, so OPUS
rows tuned on a 96-CU partition resolve. Add 20 OPUS rows to
kimik2_bf16_tuned_gemm.csv for the four Kimi-K2 BF16 projection shapes,
(N, K) = (2112, 7168), (3072, 1536), (4096, 512) and (7168, 2048), at
M = 4, 8, 16, 8192 and 16384.

The policy parity test keys its pre-PR codegen map by CU count too.
With two gfx1250 CU tables, a same-shape row on 96 and 256 CUs would
otherwise overwrite the other in that map.

Split out of #6595, which keeps the Gluon configs.

Co-authored-by: Cursor <[email protected]>

* Addressing copilot review comment

* Tune gfx1250 96cu OPUS a16w16 for extra Kimi-K2 shapes

* Address reviewer comment

---------

Co-authored-by: Cursor <[email protected]>
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