Skip to content

[Config] Add tuned GEMM and fused-MoE configs for MI350P (gfx950, 128 CUs) - #7218

Merged
yifehuan merged 15 commits into
mainfrom
mi350p-tuning
Nov 13, 2026
Merged

yifehuan merged 15 commits into
mainfrom
mi350p-tuning

Conversation

@RElbers

@RElbers RElbers commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On a 128 CU gfx950 part (MI350P), GEMM and fused-MoE lookups find no tuned row and fall back to the default dispatch. The only exception is the Qwen3.8-27B rows from #6939. This PR adds 825 rows at gfx950, cu_num=128. They don't change dispatch on 256 CU parts, and none overlap the before mentioned merged PR.

Changes

Rows are appended to the model's existing table under model_configs/, or put in a new model file where none exists. No existing row is modified. Three Qwen3-235B FP8 MoE rows need the xbf16/flat columns, which a8w8_blockscale_tuned_fmoe_qwen3_235b.csv lacks, so those rows go in a new qwen3_235b_fp8_tuned_fmoe.csv. The 11 GPT-OSS FP4 rows go in a new gptoss_fp4_gfx950_tuned_fmoe.csv, because gptoss_fp4_tuned_fmoe.csv has no gfx column and the wheel build cannot infer gfx950 from cu_num 128.

model rows families
Qwen3-235B 326 a4w4 blockscale 204, a8w8 blockscale bpreshuffle 61, fp4 MoE 43, bf16 10, fp8 MoE 8
DeepSeek-V4-Flash 322 a8w8 blockscale bpreshuffle 213, a8w8 blockscale 52, bf16 43, fp4 MoE 14
Kimi-K2 81 bf16 81
GPT-OSS 55 bf16 44, fp4 MoE 11
GLM-5.2 31 a8w8 blockscale bpreshuffle 16, a8w8 blockscale 15
MiniMax-M3 10 a8w8 bpreshuffle 10

The rows were tuned with the in-tree tuners and timed against the default dispatch in the production operator. No row uses hipBLASLt: a hipBLASLt solution index belongs to one hipBLASLt build, so the bf16 rows use FlyDSL, asm, opus or torch kernels. Four DeepSeek-V4-Flash lm_head shapes where none of those beat the default have no row.

Test Plan

  • op_tests/tuning_tests/test_config_shape_collision.py
  • A lookup check: every bf16 row resolves as written at gfx950/128.
  • Default vs tuned with --run_config on each family's shapes:
    • Default: the config env var points at the canonical table, which has no 128 CU rows.
    • Tuned: the production merged table.
    • Each pair ran back to back on one GPU, in both orders. The two orders agree within 1%.

Test Result

Collision test OK. No ERROR or MISMATCH statuses in any run. Overall: 76,629 → 65,972 us over 829 shapes, geomean 1.28x, total 1.16x.

The bf16 row and the overall line were measured before de6a7fa, which replaced 15 bf16 hipBLASLt rows with the fastest FlyDSL or torch kernel and dropped the 4 lm_head rows; they will be re-measured. The other families' rows have not changed since.

family rows default (us) tuned (us) geomean / total best worst
bf16 182 4431.8 3480.8 1.39x / 1.27x 2.15x 1.02x
a8w8 blockscale 67 7712.3 5637.2 1.37x / 1.37x 2.18x 0.97x
a8w8 bpreshuffle 10 123.1 96.1 1.28x / 1.28x 1.42x 1.12x
a4w4 blockscale 204 10934.8 10240.3 1.28x / 1.07x 1.80x 0.99x
a8w8 blockscale bpreshuffle 290 15247.6 13418.8 1.25x / 1.14x 1.88x 1.00x
fused MoE 76 38179.5 33098.7 1.13x / 1.15x 1.53x 0.99x

Reviewed revision

190e1af

Behavior and intent

On a 128 CU gfx950 part, the shapes above dispatch to their tuned kernel instead of the default, since no row existed at cu_num 128 for them. Other archs and CU counts are unchanged.

Validation and unverified scope

python3 -m pytest op_tests/tuning_tests/test_config_shape_collision.py passes at 190e1af (32 passed). On MI350P (gfx950, 128 CUs), before de6a7fa: every bf16 row resolved as written at gfx950/128, and --run_config against the default dispatch reported no ERROR or MISMATCH, with the gains in Test Result.

Unverified: the bf16 lookup check and timings since de6a7fa replaced 15 bf16 rows and dropped 4; they will be re-measured.

PR-specific question

Every added row is keyed at gfx950, cu_num=128 plus its family's shape columns, so other CU counts and archs cannot reach them. No existing row is modified, and the collision test confirms no added key duplicates one already on main.

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

@aiter-bot

aiter-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 190e1afea285 · 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

On a 128 CU gfx950 part, the shapes above dispatch to their tuned kernel instead of the default, since no row existed at cu_num 128 for them. Other archs and CU counts are unchanged.

Validation and unverified scope

`python3 -m pytest op_tests/tuning_tests/test_config_shape_collision.py` passes at 190e1afea2 (32 passed). On MI350P (gfx950, 128 CUs), before de6a7fac8f: every bf16 row resolved as written at gfx950/128, and `--run_config` against the default dispatch reported no ERROR or MISMATCH, with the gains in Test Result.

Unverified: the bf16 lookup check and timings since de6a7fac8f replaced 15 bf16 rows and dropped 4; they will be re-measured.

PR-specific question

Every added row is keyed at `gfx950`, `cu_num=128` plus its family's shape columns, so other CU counts and archs cannot reach them. No existing row is modified, and the collision test confirms no added key duplicates one already on main.

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 could not review the current head (for example, quota or service failure)

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.

@RElbers RElbers changed the title Add tuned GEMM and fused-MoE configs for gfx950 at 128 CUs Add tuned GEMM and fused-MoE configs for MI350P (gfx950, 128 CUs) Oct 30, 2026
@mjkvaak-amd

Copy link
Copy Markdown
Contributor

Perf A/B on MI350P (gfx950, 128 CUs) for the Qwen3-235B MXFP4 tables in this PR: +8-9% prefill and +5-10% decode throughput at the concurrencies that matter, end-to-end in vLLM.

Setup

  • amd/Qwen3-235B-A22B-Instruct-2507-MXFP4, TP=1, image vllm/vllm-openai-rocm:nightly-335dd77b09161c5d63139b4e7ae51bb9928305b1 (vLLM 0.33.0rc1.dev320, AITER 0.1.26).
  • Candidate = control + qwen3_235b_a4w4_blockscale_tuned_gemm.csv, qwen3_235b_bf16_tuned_gemm.csv, qwen3_235b_fp4_tuned_fmoe.csv mounted into aiter/configs/model_configs/ (byte-identical to c618f0e) + two Triton preshuffled configs. Nothing else differs.
  • Both arms:
    VLLM_ROCM_USE_AITER=1 SAFETENSORS_FAST_GPU=1 VLLM_ROCM_SHUFFLE_KV_CACHE_LAYOUT=1 \
    vllm serve amd/Qwen3-235B-A22B-Instruct-2507-MXFP4 \
      --tensor-parallel-size 1 --max-model-len 10240 --no-enable-prefix-caching \
      --attention-backend ROCM_AITER_FA --kv-cache-dtype fp8 --no-enable-chunked-prefill \
      --max-num-batched-tokens 16384 --gpu-memory-utilization 0.985 \
      --max-cudagraph-capture-size 144 --compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}'
    
  • vllm bench serve-style random token ids, prefill 8000 in / 50 out (4x concurrency prompts), decode 50 in / 4096 out (1x concurrency prompts). Two rounds, control and candidate on two cards in parallel, cards swapped between rounds; values are the mean of the two rounds.

Prefill, 8000 in / 50 out (input tok/s)

Concurrency Control Candidate Change
2 9,526 10,686 +12.2%
4 10,572 11,381 +7.6%
8 10,789 11,783 +9.2%
16 12,334 13,368 +8.4%
32 13,000 14,135 +8.7%

Decode, 50 in / 4096 out (output tok/s)

Concurrency Control Candidate Change
1 101.7 113.8 +12.0%
16 595 614 +3.2%
64 1,376 1,508 +9.6%
128 1,675 1,788 +6.7%
144 1,733 1,814 +4.7%

Per-round changes agree within ~2-4 points everywhere except decode c=16 (-6.8% / +14.8%; median TPOT 27.0 -> 26.0 ms). Mean TPOT at decode c=64 goes 43.7 -> 39.9 ms.

Notes

  1. vLLM only uses the tuned a4w4 ASM rows if a Triton GEMM-AFP4WFP4_PRESHUFFLED-N=..-K=..json also exists for the shape (kernels/linear/mxfp4/aiter.py: is_asm_fp4_gemm_tuned(n, k) and is_triton_gemm_afp4wfp4_presh_ws_tuned(n, k)). For the TP=1 dense shapes (N=9216, K=4096 and N=4096, K=8192) neither file exists, so without them the a4w4 rows in this PR are silently unused. The candidate mounts copies of the N=8192 neighbours (same K) under those names; they are not tuned for these shapes. Adding tuned preshuffled configs for the two shapes alongside these rows would make the a4w4 table effective out of the box.
  2. --max-num-batched-tokens 16384 in both arms: the fused-MoE rows stop at 16384 tokens, so a 32768-token prefill step falls back to the untuned 2-stage default ("no tuned FlyDSL config").
  3. Accuracy, gsm8k 5-shot (1319 problems, greedy), candidate config vs. the original serving recipe: 0.9439 vs 0.9424, 35 fixed / 33 broke, McNemar p=0.90.

@RElbers
RElbers marked this pull request as ready for review November 2, 2026 13:28
@RElbers
RElbers requested review from a team and a balanced review from Copilot November 2, 2026 13:28
@github-actions github-actions Bot changed the title Add tuned GEMM and fused-MoE configs for MI350P (gfx950, 128 CUs) [Config] Add tuned GEMM and fused-MoE configs for MI350P (gfx950, 128 CUs) Nov 2, 2026
@github-actions github-actions Bot added the Config label Nov 2, 2026
- Adds six tuned config files for gfx950 at 128 CU, covering the a4w4, a8w8,
  bf16 and fused MoE families, so dispatch on that part stops falling through
  to an untuned default.
- Places them under model_configs rather than the canonical tables, so the
  runtime merge adds these rows to each family instead of substituting them.

The merge key includes cu_num, so the 128 CU rows and the shipped 256 CU rows
coexist and each part reaches its own.
- Adds eight tuned config files for gfx950 at 128 CU, extending the a8w8
  blockscale, a8w8 blockscale bpreshuffle, bf16 and fused MoE families.
- Covers fused MoE at two tensor parallel splits, which key apart on inter_dim
  and so merge as distinct shapes rather than displacing one another.
- Adds shapes to eight existing gfx950 128 CU config files in the a4w4, a8w8
  blockscale, a8w8 blockscale bpreshuffle and fused MoE families.
- Leaves every previously tuned row untouched, so the additions widen coverage
  without changing an existing dispatch choice.
- Adds 90 bf16 rows across three gfx950 128 CU files, one of them new, so the
  a16w16 family covers the shapes previously left untuned, including the
  (M, 64640, 4096) lm_head GEMM.
- Adds two a8w8 blockscale bpreshuffle rows that close five DeepSeek-V4 shapes
  which matched no tuned row and fell through to the heuristic.

Every addition appends, so no previously tuned row is modified or reordered.
Most of the new bf16 rows name flydsl kernels, which bake the die count in at
AOT time, so they depend on the base tree more than the hipblaslt rows beside
them.
- Removes (16, 4096, 4096) at gfx950 128 CU, which the DeepSeek-V4-Flash file
  also carries after the previous commit. The merge dedups on
  (gfx, cu_num, M, N, K) with no model in the key, so the two collided and
  setup.py refused to load.
- Keeps the faster-measured row: the ck kernel in the DeepSeek file at
  10.88 us against 15.68 us for the asm row removed here, which is also what
  aiter's own auto-resolution selects.
- Records the 512x384x7168 bf16 shape measured on a 128 CU gfx950 part, which
  the existing table covers only at 256 CUs, so the lookup found nothing there.

The merged bf16 family has no other row on this key, checked against all 31 files
rather than this one alone, since the runtime merges them together.
Adds 80 rows to the 512x384x7168 one already here, all tuned on a 128 CU
gfx950 part with csrc/gemm_a16w16/gemm_a16w16_tune.py.  The 512x384x7168 row
came from the same sweep, so it is left as it stands rather than re-added.

Shape-collision guard passes on the whole tree:

    python3 -m unittest op_tests.tuning_tests.test_config_shape_collision
    Ran 27 tests ... OK

which merges this file with aiter/configs/bf16_tuned_gemm.csv and every other
bf16_tuned_gemm model file, so the check is family-wide.

Every batch reported an empty Failed shapes and the worst err_ratio is 0.0226,
which is bf16 accumulation over K=7168 rather than a kernel problem - the
K=512 shapes come out at 0.

The 44 shapes of the list still untuned are the ones GEMM lookup reaches only
at an exact M.  getPaddedM(M,N,K,0) rounds M up to 16 below 257 and to 32
below 1025, and the lookup tries exact M, then gl=0, then gl=1, so the bucket
boundaries tuned here already serve every M between them.

Kernel choice splits by M: FlyDSL wins all 23 shapes at M<=64, 21 of 25 from
65 to 256, and 14 of 33 above that, where asm takes over.
- Changes the (384, 1024, 7168) row from kernel id 1221 to 73, the id the gfx950 a16w16 opus registry gives the kernel the row names.

The lookup rejected id 1221 as unknown and the shape fell back to torch, so the tuned kernel was never selected.
- Appends the rows for models that already have a table in a family to that table, so each model keeps one file per family.
- Gives the DeepSeek-V4-Flash and Qwen3-235B rows plain model-named files where no table existed, replacing the separate _mi350p files.
- Drops the gfx and flat columns from the GPT-OSS MoE rows to match their target file; the merge infers gfx950 from cu_num 128, and every moved row had flat 0.
- Keeps the Qwen3-235B FP8 MoE rows in a file of their own, since three are flat 1-stage kernels that need the xbf16 and flat columns the existing table lacks.

Dispatch is unchanged: every row lands in the same merged family table with the same key and kernel.
- Removes four Qwen3-235B a4w4 blockscale rows (M 128 and 512 at N 4096, 4608 and 9216) and one GLM-5.2 a8w8 blockscale row (32, 8192, 2048).
- Their tuned kernels ran slower than the default dispatch in the production operator, though the tuner's own sweep had picked them, so these shapes now keep the default.

The padded-M lookup maps each removed M to itself, so no neighbouring row takes over these shapes.

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 11 new configuration rows lack explicit gfx950 tagging, so loading them uses the host GPU’s architecture and can cause incorrect cross-architecture matches.

1 open issue
What changed in this PR

Adds 829 tuned GEMM and fused-MoE configuration rows targeting MI350P (gfx950, 128 compute units), extending AITER’s model-specific dispatch tables beyond the earlier Qwen3.8-27B tuning.

Changes:

  • Covers six model families across BF16, FP8, and FP4 operations.
  • Appends tuning entries to existing tables and adds model-specific tables where needed.
  • Adds a separate Qwen3-235B FP8 MoE table supporting xbf16 and flat settings.

All paths below are under aiter/configs/model_configs/.

File Description
qwen3_235b_fp8_tuned_fmoe.csv Adds 8 FP8 MoE configurations with layout flags.
qwen3_235b_fp4_tuned_fmoe.csv Adds 43 FP4 MoE configurations.
qwen3_235b_bf16_tuned_gemm.csv Adds 10 BF16 GEMM configurations.
qwen3_235b_a4w4_blockscale_tuned_gemm.csv Adds 204 FP4 blockscale GEMM configurations.
kimik2_bf16_tuned_gemm.csv Appends 81 Kimi-K2 BF16 GEMM configurations.
gptoss_fp4_tuned_fmoe.csv Appends 11 GPT-OSS FP4 MoE configurations.
gptoss_bf16_tuned_gemm.csv Appends 44 GPT-OSS BF16 GEMM configurations.
dsv4flash_fp4_tuned_fmoe.csv Adds 14 DeepSeek-V4-Flash FP4 MoE configurations.
dsv4flash_bf16_tuned_gemm.csv Adds 47 DeepSeek-V4-Flash BF16 GEMM configurations.
dsv4flash_a8w8_blockscale_tuned_gemm.csv Adds 52 FP8 blockscale GEMM configurations.
dsv4flash_a8w8_blockscale_bpreshuffle_tuned_gemm.csv Adds 213 B-preshuffled FP8 blockscale configurations.
a8w8_bpreshuffle_tuned_gemm_minimax_m3.csv Appends 10 MiniMax-M3 B-preshuffled FP8 configurations.
a8w8_blockscale_tuned_gemm_glm5.2.csv Appends 15 GLM-5.2 FP8 blockscale configurations.
a8w8_blockscale_bpreshuffle_tuned_gemm_qwen3_235b.csv Appends 61 Qwen3-235B B-preshuffled FP8 configurations.
a8w8_blockscale_bpreshuffle_tuned_gemm_glm5.2.csv Appends 16 GLM-5.2 B-preshuffled FP8 configurations.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 2, 2026 13:33

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 tuning rows can match unintended GPU architectures, and unchecked build-specific hipBLASLt indices can terminate the process instead of falling back safely.

2 open issues

Review effort: Balanced

- Swaps the gfx950 128 CU hipBLASLt rows of the DeepSeek-V4-Flash and GPT-OSS bf16 tables for the fastest FlyDSL or torch kernel retuned without hipBLASLt.
- Drops the four lm_head rows where no such kernel beat the default, so those sizes use F.linear.

A hipBLASLt solution index belongs to one hipBLASLt build, and hipb_mm exits the process on an index the installed library does not have.
Copilot AI balanced review requested due to automatic review settings November 4, 2026 08:20

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. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 21:15

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. Try requesting a review at a lower effort level.

- Moves the 11 gfx950 rows at cu_num 128 from gptoss_fp4_tuned_fmoe.csv into
  gptoss_fp4_gfx950_tuned_fmoe.csv, keyed by gfx, with their values unchanged.
- Leaves gptoss_fp4_tuned_fmoe.csv as it is on main.

The old table has no gfx column, so a row's arch is inferred from cu_num, and
128 is not in that map: the wheel build fell back to gfx942, the first arch
in GPU_ARCHS, and the FlyDSL AOT replay failed compiling the FP4 kernels for it.
Copilot AI balanced review requested due to automatic review settings November 6, 2026 08:47

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. Try requesting a review at a lower effort level.

# Conflicts:
#	aiter/configs/model_configs/a8w8_bpreshuffle_tuned_gemm_minimax_m3.csv
Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:18

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. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 20:56

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. Try requesting a review at a lower effort level.

@yifehuan yifehuan 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

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