Skip to content

[Config] [Tuning] Qwen3.8-Flash-Next TP4 prefill BF16 GEMMs on MI308X (gfx942, 80 CU) - #7204

Merged
zovonoir merged 2 commits into
ROCm:mainfrom
zovonoir:qwen38-flash-tp4-prefill-bf16-tune
Nov 6, 2026
Merged

zovonoir merged 2 commits into
ROCm:mainfrom
zovonoir:qwen38-flash-tp4-prefill-bf16-tune

Conversation

@zovonoir

@zovonoir zovonoir commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This adds aiter/configs/model_configs/qwen38_flash_next_tp4_prefill_bf16_tuned_gemm.csv: 37 BF16 GEMM rows for gfx942 with 80 CUs (MI308X), covering the large-M prefill shapes of Qwen3.8-Flash-Next served at TP4 with MTP. Like the other files under model_configs/, it is picked up by the existing merge in AITER_CONFIG.get_config_file. No code changes.

The table uses no hipBLASLt solutions. 24 rows use aiter OPUS kernels and 13 rows stay on torch (native) because nothing beat it there. The first revision pinned hipBLASLt solution indices. Following review, it was retuned without them, because a pinned solidx is tied to the hipBLASLt build and can fault or pick an unrelated kernel when CI images update hipBLASLt.

Without these rows the shapes miss the tuned table (the existing qwen38_flash_next_bf16_tuned_gemm.csv has no rows for them) and fall back to torch (aten::mm). Torch picks poor kernels for some of them: [16384,10240]x[10240,320] takes 1.83 ms on torch and 0.84 ms with the OPUS row.

N x K M buckets
2560 x 2560 2048, 4096, 8192, 16384, 32768, 65536
3584 x 2560 2048, 4096, 8192, 16384
2560 x 1536 2048, 4096, 8192, 16384
320 x 10240 2048, 4096, 8192, 16384
4 x 10240 2048, 4096, 8192, 16384
320 x 2560 2048, 4096, 8192, 16384
24 x 2560 2048, 4096, 8192, 16384
2560 x 160 2048, 4096, 8192, 16384
10240 x 2560 2048, 4096, 8192

The shapes come from the MTP drafter (fc_hidden 2560 x 2560, which runs over all four streams and therefore reaches 4T rows; QKV 3584 x 2560; HC 320 x 10240), the final HC mixer, and the PLE projections.

The M buckets follow getPaddedM, the tuned-table lookup rule (gl=1: M > 8192 with N > 4096 maps to 8192, otherwise the next power of two). Tuned with csrc/gemm_a16w16/gemm_a16w16_tune.py --mp 4 --shape_grouped (no --with-hipblaslt; candidates asm, opus, triton, torch) on MI308X, ROCm 7.2.4. All selected rows have err_ratio 0.

Kernel time

Production-op benchmark (gemm_a16w16_tune.py --run_config), same container and GPUs for all three columns, sum over the 37 shapes:

torch for all 37 this table (OPUS + torch) earlier hipBLASLt revision
total us 21,241 16,733 16,023

The largest wins over torch are [16384,10240]x[10240,320] (1830 -> 838 us), [16384,2560]x[2560,3584] (3153 -> 1342 us) and [16384,2560]x[2560,320] (478 -> 219 us). On the 2560- and 10240-wide GEMMs OPUS is on par with or faster than the hipBLASLt solutions; it gives up some time on N = 320 at M = 16384 and on the small-N / K = 160 shapes.

Results

4x MI308X (GPUs 4-7), TP4 / EP4 Qwen3.8-Flash-Next-PTPC-FP8, image atom-sglang:qwen38-flash-next-20261102-full (aiter 0c8a7a59c, ROCm 7.2.4, SGLang v0.5.20 + ATOM), BF16 KV, MTP on (EAGLE 2 steps), radix cache on and flushed (#cached-token = 0 in every measured run). sglang.bench_serving random, OSL 1, ~800K input tokens per case, mean of r1 and r2 after a discarded r0. One fresh container per column, run back to back.

ISL x CON no table (tok/s) this table (tok/s) gain earlier hipBLASLt revision (tok/s)
1024 x 64 28,463 29,184 +2.5% 29,556
4096 x 32 30,034 30,152 +0.4% 30,573
16384 x 16 28,881 29,489 +2.1% 29,062
30720 x 8 28,413 28,765 +1.2% 28,684
63488 x 4 27,730 27,790 +0.2% 28,057
129024 x 2 26,723 26,886 +0.6% 27,018
geomean 28,356 28,690 +1.2% 28,803 (+1.6%)

r1 / r2 differ by at most 2.6% (hipBLASLt), 4.4% (this table) and 6.5% (no table), so the 0.4% between this table and the hipBLASLt revision is within run-to-run noise.

GSM8K 400 (run_eval, chat, thinking off): 0.9725 without the table, 0.975 with it (0.9725 with the hipBLASLt revision). The change only selects GEMM kernels; dtypes are unchanged.

Deploying into a prebuilt image

module_deepgemm_opus compiles only the OPUS kernel ids referenced by the tuned CSVs at build time (gen_instances.py --tune_files ...). A from-source or JIT build of aiter picks this table up automatically. In an image whose OPUS module was built before this file was added, dropping in the CSV alone makes the first lookup fail with opus_gemm_a16w16_launch: kid 3 is not compiled in the current OPUS module. Remove aiter/jit/module_deepgemm_opus.so and aiter/jit/build/module_deepgemm_opus so it rebuilds (about 15 s). After that rebuild, all 37 shapes run through tgemm.mm with max relative error 7.1e-3 against an FP32 reference.

PR Self-Review

Reviewed revision

4578a2feb

Behavior and intent

This adds 37 BF16 GEMM rows for gfx942 with 80 CUs under aiter/configs/model_configs/: 24 OPUS rows and 13 torch rows, with no hipBLASLt. With them, the large-M prefill GEMMs of Qwen3.8-Flash-Next at TP4 (MTP drafter, final HC mixer, PLE) use OPUS kernels where those beat torch, and stay on torch native elsewhere. Without them, these keys are not in any tuned table and tgemm falls back to torch (aten::mm). No code changes.

Validation and unverified scope

Validated:

  • In the atom-sglang:qwen38-flash-next-20261102-full image (aiter 0c8a7a59c) with the OPUS module rebuilt, get_GEMM_A16W16_config returns the new rows (for example (16384, 320, 10240) -> opus opus_gemm_gfx942_512x128x128x64_2x4_16x16x16_0x0x0). All 37 shapes run through tgemm.mm against an FP32 reference.
  • On 4x MI308X, TP4 / EP4 SGLang + ATOM serving with MTP: +1.2% geomean input throughput over six ISL x concurrency cases against no table, and GSM8K 400 of 0.9725 without vs 0.975 with the table (tables above).

Unverified:

  • The serving runs used that image's aiter with this file added, not aiter main.
  • Other CU counts are untouched: every row is keyed on cu_num=80.

PR-specific question

The rows are consumed by exactly 37 keys: (gfx942, 80, M, N, K, bias=False, bf16, bf16, scaleAB=False, bpreshuffle=False) for the (N, K) pairs and M buckets listed above. M is the getPaddedM bucket, and lookup is an exact key match. None of the 37 keys exists in any BF16 tuned file on main; this was checked against configs/bf16_tuned_gemm.csv and every model_configs/*bf16_tuned_gemm*.csv. So every other shape keeps the solution it had before. The OPUS kernel ids used here also enter module_deepgemm_opus through its --tune_files glob.

Changed op tests

None.

Related: ROCm/ATOM#2834, ROCm/ATOM#2847.

… CU)

37 large-M shapes (M 2048..65536) of the MTP drafter, the final HC mixer and
the PLE projections that fell back to torch (aten::mm, as low as 60 TFLOPS
for [M,10240]x[10240,320]); hipBLASLt solutions from gradlib gemm_tuner.py.
@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 7204 --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 4578a2febdbe · 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 adds 37 BF16 GEMM rows for gfx942 with 80 CUs under `aiter/configs/model_configs/`: 24 OPUS rows and 13 `torch` rows, with no hipBLASLt. With them, the large-M prefill GEMMs of Qwen3.8-Flash-Next at TP4 (MTP drafter, final HC mixer, PLE) use OPUS kernels where those beat torch, and stay on torch native elsewhere. Without them, these keys are not in any tuned table and `tgemm` falls back to `torch` (`aten::mm`). No code changes.

Validation and unverified scope

Validated:
* In the `atom-sglang:qwen38-flash-next-20261102-full` image (aiter `0c8a7a59c`) with the OPUS module rebuilt, `get_GEMM_A16W16_config` returns the new rows (for example `(16384, 320, 10240)` -> `opus` `opus_gemm_gfx942_512x128x128x64_2x4_16x16x16_0x0x0`). All 37 shapes run through `tgemm.mm` against an FP32 reference.
* On 4x MI308X, TP4 / EP4 SGLang + ATOM serving with MTP: +1.2% geomean input throughput over six ISL x concurrency cases against no table, and GSM8K 400 of 0.9725 without vs 0.975 with the table (tables above).

Unverified:
* The serving runs used that image's aiter with this file added, not aiter `main`.
* Other CU counts are untouched: every row is keyed on `cu_num=80`.

PR-specific question

The rows are consumed by exactly 37 keys: `(gfx942, 80, M, N, K, bias=False, bf16, bf16, scaleAB=False, bpreshuffle=False)` for the (N, K) pairs and M buckets listed above. M is the `getPaddedM` bucket, and lookup is an exact key match. None of the 37 keys exists in any BF16 tuned file on `main`; this was checked against `configs/bf16_tuned_gemm.csv` and every `model_configs/*bf16_tuned_gemm*.csv`. So every other shape keeps the solution it had before. The OPUS kernel ids used here also enter `module_deepgemm_opus` through its `--tune_files` glob.

Changed op tests

None.

Related: ROCm/ATOM#2834, ROCm/ATOM#2847.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply

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.

@zovonoir
zovonoir marked this pull request as ready for review October 30, 2026 08:46
@zovonoir
zovonoir requested review from a team and a balanced review from Copilot October 30, 2026 08:46
@github-actions github-actions Bot changed the title [Tuning] Qwen3.8-Flash-Next TP4 prefill BF16 GEMMs on MI308X (gfx942, 80 CU) [Config] [Tuning] Qwen3.8-Flash-Next TP4 prefill BF16 GEMMs on MI308X (gfx942, 80 CU) 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

Static checks passed, but correctness and performance of the 37 hardware-specific hipBLASLt solution selections remain unverified without an exact-head GPU validation report from gfx942 hardware with 80 CUs.

No open issues 🎉

What changed in this PR

Adds BF16 GEMM tuning data for Qwen3.8-Flash-Next TP4 prefill on MI308X (gfx942, 80 CUs), using the existing model-config merge mechanism without changing code.

Changes:

  • Adds 37 hipBLASLt solutions covering nine projection shapes and M buckets from 2048 to 65536.
  • Targets tuned-table misses that otherwise fall back to PyTorch; the PR reports a 2.6% geometric-mean serving throughput improvement.
File Description
aiter/​configs/​model_configs/​qwen38_flash_next_tp4_prefill_bf16_tuned_gemm.csv Adds model-specific BF16 GEMM solutions, kernel metadata, and tuning measurements.

Review effort: Balanced

ZLkanyo009
ZLkanyo009 previously approved these changes Oct 30, 2026

@ZLkanyo009 ZLkanyo009 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, approving. I checked the table mechanically:

  • The header matches bf16_tuned_gemm.csv.
  • All 37 keys are unique and are all gfx942 / 80 CU hipBLASLt entries with err_ratio 0.
  • None of the keys collide with bf16_tuned_gemm.csv or any of the other 27 model_configs/*bf16_tuned_gemm.csv tables, so the model-config merge stays unambiguous.
  • The nine (N, K) shapes line up with the Qwen3.8-Flash-Next TP4 prefill projections.

Since it only adds a model-specific table, it's safe to merge independently of the ATOM PRs.

@zovonoir

zovonoir commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@valar-cop Come and check this out.

@valar-cop

This comment has been minimized.

Review follow-up: a pinned hipBLASLt solidx is tied to the hipBLASLt build
and can fault or pick an unrelated kernel when the library is updated.
Retuned the same 37 keys with csrc/gemm_a16w16/gemm_a16w16_tune.py (no
--with-hipblaslt): 24 rows now use aiter OPUS kernels, 13 rows stay on
torch native where nothing beats it.
Copilot AI balanced review requested due to automatic review settings November 5, 2026 07:01
@zovonoir
zovonoir requested a review from demonsan November 5, 2026 07:02

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 reported hipBLASLt validation does not cover the submitted OPUS/PyTorch table, leaving its correctness and performance unverified.

1 open issue

Review effort: Balanced

@zovonoir
zovonoir requested a review from ZLkanyo009 November 5, 2026 07:40
@zovonoir

zovonoir commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@ZLkanyo009 your approval was dismissed by the new push (4578a2f). The table now uses OPUS and torch native instead of pinned hipBLASLt solutions, following @demonsan's review. The keys are the same 37 and there are still no collisions with the other BF16 tables on current main. Details and re-measured TP4 numbers are in the description. Could you take another look?

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

@zovonoir
zovonoir merged commit 8b11477 into ROCm:main Nov 6, 2026
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.

6 participants