Skip to content

tune: a8w8 gemm tuning for Qwen3.5 MXFP4-AttnFP8 model - #4317

Merged
zufayu merged 2 commits into
ROCm:mainfrom
mqhc2020:marv/fp8_gemm_tuning_a8w8_bpreshuffle
Jul 24, 2026
Merged

zufayu merged 2 commits into
ROCm:mainfrom
mqhc2020:marv/fp8_gemm_tuning_a8w8_bpreshuffle

Conversation

@mqhc2020

@mqhc2020 mqhc2020 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

a8w8 bpreshuffle: tuned GEMM entries for Qwen3.5 MXFP4-AttnFP8

Adds a8w8_bpreshuffle FP8 GEMM tuning entries for the Qwen3.5-397B-A17B-MXFP4-AttnFP8
model. Config-only change: +60 rows, no code changes.

Layers tuned

The model's FP8 (non-MoE-expert) GEMM shapes, each with a full M = 1..8192 sweep (15 points):

N × K layer
4096 × 4096 attention o_proj
10240 × 4096 attention qkv projection
8704 × 4096 dense MLP gate/up projection
4096 × 1024 dense MLP down_proj

Validation (MI3xx, TP=2, dense-fp8 + allreduce-fusion)

Tuned config vs untuned CK-default baseline, output tok/s per GPU, ISL∈{1k,8k}, cc=4..256:

  • Consistent throughput win: net-positive at 13/14 points, mean ≈ +1.4%, up to +3.1%
    (largest at low cc=4 and high cc=32..256; mid-range flat where CK defaults already suffice).
  • Advantage holds/grows at high concurrency (peak ~18k tok/s aggregate at ISL=8192/cc=256).

Submission Checklist

@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:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4317 --add-label <label>

@mqhc2020
mqhc2020 requested a review from eppaneamd July 21, 2026 06:23
@mqhc2020
mqhc2020 marked this pull request as ready for review July 21, 2026 06:23
@mqhc2020
mqhc2020 requested a review from a team July 21, 2026 06:23
@zufayu
zufayu requested a review from yifehuan July 22, 2026 13:32

@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

@zufayu
zufayu merged commit dca178b into ROCm:main Jul 24, 2026
42 checks passed
@mqhc2020
mqhc2020 deleted the marv/fp8_gemm_tuning_a8w8_bpreshuffle branch July 28, 2026 04:58
jiaqiang-dot-liu added a commit to jiaqiang-dot-liu/aiter that referenced this pull request Sep 15, 2026
…rop 66 stale ones

The 136 unparseable rows this branch's first commit only *reported* are now
resolved. Root cause and the migration, both recovered from git history rather
than guessed.

Root cause: a kernelName schema change that did not migrate the CSVs

`kernelInstance.name` in
`aiter/ops/flydsl/gemm_tune/flydsl_gemm_a8w8_bpreshuffle_common.py` changed its
knob field:

| commit | date | knob field |
|---|---|---|
| `878008c3` (ROCm#3134) | 2026-05-14 | `lds_stage x use_cshuffle_epilog x use_async_copy x waves_per_eu x xcd_swizzle` |
| `3910ab39` (ROCm#4151) | 2026-07-10 | `use_async_copy x waves_per_eu x xcd_swizzle x lds_stage` |

`a8w8_bpreshuffle_tuned_gemm_qwen3_5_397b_a17b_mxfp4_attnfp8.csv` was added
between them by ROCm#4317 / ROCm#4396, so it carries the five-token spelling. ROCm#4151
changed the format without migrating the shipped CSVs, and because the runtime
fallback was silent nothing reported it.

The mapping is confirmed by the observed value ranges, not inferred: across the
136 rows the tokens take `{1,2}`, `{0,1}`, `{0,1}`, `{0..4}`, `{0,4}` —
positionally exactly `lds_stage`, `use_cshuffle_epilog`, `use_async_copy`,
`waves_per_eu`, `xcd_swizzle`.

Impact was total for those shapes: each of the 289 rows in that file is a
distinct `(gfx, cu_num, M, N, K)`, so the 136 affected shapes had no second
tuned row to fall back to. They ran on the CK default heuristic, and were also
dropped from the AOT build.

What this commit does

* **70 rows migrated** (`use_cshuffle_epilog == 0`). Reordering the four
  surviving knobs into the current spelling is exact, so these tuned choices
  become live again. Example:
  `..._B16_2x0x1x3x0_default` -> `..._B16_1x3x0x2_default`.
* **66 rows dropped** (`use_cshuffle_epilog == 1`). These were tuned for a
  cshuffle-epilog variant the a8w8 bpreshuffle path no longer has — the
  remaining `cshuffle` references in the tree belong to the separate mxfp4
  kernels. Dropping the flag would name a *different* kernel than the one that
  was measured, so the `us` figures no longer describe anything buildable.
  These shapes need re-tuning; leaving inert rows in place only hides that.
* `KNOWN_UNBUILDABLE_ROWS` drops to empty, which turns the ratchet into the
  stronger invariant: **no** shipped tuned row may name an unbuildable kernel.

The migration is mechanical and reproducible:

```
old: <prefix>_{lds}x{cshuffle}x{async}x{wpe}x{xcd}_{sched}
new: <prefix>_{async}x{wpe}x{xcd}x{lds}_{sched}   # cshuffle == 0 only
```

After it, all 1375 `flydsl_bpreshuflle` rows across `aiter/configs/` parse.

Verification and why this is a draft

Checked here: every remaining row parses under both the runtime and the AOT
regex; the migration touches only the `kernelName` column (70 insertions / 136
deletions, no shape keys altered); `ruff check` and `ruff format --check` pass.

**Not verified on hardware, and that is the blocking item.** Parsing is not
building: whether each migrated `(tile, knobs)` combination compiles and is
actually faster than the CK default it currently gets needs a gfx950 run. The
downside is bounded — a migrated row that fails to build falls back to exactly
today's behaviour — but "bounded downside" is not the same as "measured win",
and 70 shapes changing dispatch backend is not something to land unmeasured.

Marked draft until an MI355X run confirms the migrated rows build and beat the
CK default. Re-tuning the 66 dropped shapes is separate work for whoever owns
them.

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

---

AI-assistance disclosure

**AI assistance was used.** This began as a warning-only change (first commit)
while auditing an unrelated per-shape dispatch override that was rejected. The
schema archaeology above is what turned it into an actual fix. Targets a
personal fork as a staging point, not `ROCm/aiter`.

Signed-off-by: jiaqiang-dot-liu <[email protected]>
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