Skip to content

[Config] Add MI350P FP8 blockscale B-preshuffle GEMM tuning for Qwen38-27B-FP8 - #6939

Merged
yifehuan merged 1 commit into
ROCm:mainfrom
a-sidorova:asidorov/feature/tuned_a8w8_bpreshuffle_qwen38_27b_fp8
Oct 28, 2026
Merged

yifehuan merged 1 commit into
ROCm:mainfrom
a-sidorova:asidorov/feature/tuned_a8w8_bpreshuffle_qwen38_27b_fp8

Conversation

@a-sidorova

@a-sidorova a-sidorova commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

aiter/configs/model_configs/a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv has gfx950 rows only for 256 CUs (MI355X). On MI350P (gfx950, 128 CUs) no row matches. The PR adds tuned bpreshuffle blockwise FP8 kernels for Qwen3.8-27B-FP8 for MI350P TP=1.

Technical Details

  • Add 121 gfx950 / cu_num=128 rows to a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv. The 119 MI355X rows do not change.
  • The shapes are the ones in a8w8_blockscale_bpreshuffle_untuned_gemm_qwen38_27b.csv: 5 (N, K) pairs, each with 25 values of M from 1 to 16384.
  • Each shape was tuned with the ck, cktile and asm backends, and the fastest kernel was kept. Winners: asm 51, ck 42, cktile 28.
  • 4 shapes are not added because the tuned kernel was not faster than the default kernel: M=24 N=16384 K=5120, and M=48/56/64 N=34816 K=5120. These shapes keep the default kernel.
  • All rows pass the tuner's accuracy check (max errRatio 0.0025).

Test Result

Time per GEMM call on MI350P, measured with gemm_a8w8_blockscale_tune.py --run_config. Each speedup is shown as "geomean over shapes / ratio of total time". Total time is the sum over the shapes in the row.

  • No preshuffle: plain gemm_a8w8_blockscale with default kernels.
  • B-preshuffle default: gemm_a8w8_blockscale_bpreshuffle before this PR (no 128-CU rows in the tuned config).
  • B-preshuffle tuned: this PR.

By (N, K)

Shape Shapes No preshuffle, µs B-preshuffle default, µs B-preshuffle tuned, µs Default vs no preshuffle Tuned vs default Tuned vs no preshuffle
N=14336, K=5120 25 11922 10091 5694 1.34x / 1.18x 1.38x / 1.77x 1.84x / 2.09x
N=16384, K=5120 25 14558 11680 6274 1.36x / 1.25x 1.33x / 1.86x 1.82x / 2.32x
N=34816, K=5120 25 35805 25188 17815 1.45x / 1.42x 1.23x / 1.41x 1.78x / 2.01x
N=5120, K=6144 25 5608 4472 2457 1.21x / 1.25x 1.72x / 1.82x 2.07x / 2.28x
N=5120, K=17408 25 15295 12835 6696 1.18x / 1.19x 1.71x / 1.92x 2.02x / 2.28x
All 125 83189 64266 38936 1.30x / 1.29x 1.46x / 1.65x 1.90x / 2.14x

By M

M Shapes No preshuffle, µs B-preshuffle default, µs B-preshuffle tuned, µs Default vs no preshuffle Tuned vs default Tuned vs no preshuffle
1-16 25 1215 1385 972 0.86x / 0.88x 1.47x / 1.42x 1.27x / 1.25x
24-64 30 2054 1723 1341 1.16x / 1.19x 1.35x / 1.28x 1.56x / 1.53x
80-256 40 6584 3374 2512 1.87x / 1.95x 1.38x / 1.34x 2.57x / 2.62x
512-16384 30 73336 57783 34110 1.28x / 1.27x 1.70x / 1.69x 2.17x / 2.15x
  • Tuned vs B-preshuffle default: no shape is slower by more than 2%. The best shape is 2.36x.
  • Tuned vs no preshuffle: no shape is slower by more than 2%. The worst shape is 0.993x (M=16, N=14336, K=5120), the best is 3.70x.

Test environment

  • GPU: AMD Instinct MI350P (gfx950, 128 CUs, 450 W)

How to reproduce

Run inside the container, from the AITER root:

# With GPU_ARCHS=gfx950 and no CU_NUM, the JIT build compiles only the 256-CU
# instances and the 128-CU rows are skipped.
unset GPU_ARCHS
export HIP_VISIBLE_DEVICES=0
TUNER=csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale_tune.py
SHAPES=aiter/configs/model_configs/a8w8_blockscale_bpreshuffle_untuned_gemm_qwen38_27b.csv
TUNED=aiter/configs/model_configs/a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv

# Baselines. Run them on the parent commit, which has no 128-CU rows.
python3 $TUNER -i $SHAPES -o /tmp/unused.csv --run_config               # no preshuffle
python3 $TUNER -i $SHAPES -o /tmp/unused.csv --preshuffle --run_config  # B-preshuffle default

# This PR: the 121 tuned shapes.
python3 $TUNER -i $SHAPES -o /tmp/unused.csv --preshuffle --run_config $TUNED

Tuning (one backend per run):

for lt in ck cktile asm; do
  python3 $TUNER -i $SHAPES -o /tmp/qwen38_27b_mi350p_$lt.csv \
      --preshuffle --libtype $lt --mp 1 -k --timeout 600 \
      --compare --update_improved --min_improvement_pct 3 \
      -o2 /tmp/qwen38_27b_mi350p_all_candidates_$lt.csv -v
done

Submission Checklist

@a-sidorova
a-sidorova requested review from a team and a balanced review from Copilot October 26, 2026 07:33
@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 6939 --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.

@a-sidorova

Copy link
Copy Markdown
Contributor Author

Hi @yifehuan! May I ask you to review this PR please? Thank you in advance!

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 ASM selections route supported FP16-output requests to a BF16-only backend.

2 open issues
What changed in this PR

Adds MI350P-specific tuning to AITER’s Qwen38-27B FP8 B-preshuffle GEMM configuration, targeting gfx950 GPUs with 128 compute units.

Changes:

  • Adds 121 tuned shape entries using ASM, CK, and CKTile backends.
  • Preserves the existing 119 MI355X entries.
  • Records kernel selections, timing measurements, and accuracy metrics.
File Description
aiter/​configs/​model_configs/​a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv Adds 128-CU MI350P tuning entries for Qwen38-27B GEMMs.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 26, 2026 12:48
@github-actions github-actions Bot changed the title [Config] Add MI350P FP8 blockscale B-preshuffle GEMM tuning for Qwen38-27B-FP8 Add MI350P FP8 blockscale B-preshuffle GEMM tuning for Qwen38-27B-FP8 Oct 26, 2026
@github-actions github-actions Bot removed the Config label Oct 26, 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

Hardware-specific accuracy and performance results remain independently unverified and require human confirmation.

2 open issues

Review effort: Balanced

@a-sidorova
a-sidorova force-pushed the asidorov/feature/tuned_a8w8_bpreshuffle_qwen38_27b_fp8 branch from 8d5e164 to 717641b Compare October 26, 2026 13:00
Copilot AI balanced review requested due to automatic review settings October 26, 2026 13:00
@a-sidorova
a-sidorova force-pushed the asidorov/feature/tuned_a8w8_bpreshuffle_qwen38_27b_fp8 branch from 717641b to 154d186 Compare October 26, 2026 13:03

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 reported padded lookup still selects a tuned kernel for an intentionally excluded shape rather than preserving its stated default fallback.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 26, 2026 13:05

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

Final human review is needed to reconcile the intended default-kernel exceptions with the supplied lookup-behavior evidence.

1 open issue
1 resolved since last review

Review effort: Balanced

@yifehuan

Copy link
Copy Markdown
Contributor

sry please rebase onto main to solve merge conflict, then it's ok to lgtm and merge

@a-sidorova
a-sidorova force-pushed the asidorov/feature/tuned_a8w8_bpreshuffle_qwen38_27b_fp8 branch from 154d186 to 287fd82 Compare October 27, 2026 06:07
Copilot AI balanced review requested due to automatic review settings October 27, 2026 06:07
@github-actions github-actions Bot changed the title Add MI350P FP8 blockscale B-preshuffle GEMM tuning for Qwen38-27B-FP8 [Config] Add MI350P FP8 blockscale B-preshuffle GEMM tuning for Qwen38-27B-FP8 Oct 27, 2026
@a-sidorova

Copy link
Copy Markdown
Contributor Author

sry please rebase onto main to solve merge conflict, then it's ok to lgtm and merge

Rebased and fixed conflicts: reverted latest commit 154d186 with fix for asm kernel choosing with fp16 output dtype since it was fixed by 0912a16 (the root cause of the previous merge conflicts).

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

Human confirmation is needed that omitted shapes retain their intended default dispatch before approving the tuning configuration.

1 open issue

Review effort: Balanced

….8-27B

a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv had only gfx950
rows for 256 CUs (MI355X). On MI350P (gfx950, 128 CUs) no row matches,
so every Qwen3.8-27B-FP8 GEMM uses the default B-preshuffle kernel. For
M <= 16 the default kernel is slower than the plain blockscale GEMM
(geomean 0.86x, down to 0.74x).

Add 121 gfx950/128-CU rows, tuned over ck, cktile and asm with the
shapes in a8w8_blockscale_bpreshuffle_untuned_gemm_qwen38_27b.csv
(asm 51, ck 42, cktile 28). Four shapes are not added because the tuned
kernel was not faster than the default kernel: M=24 N=16384 K=5120 and
M=48/56/64 N=34816 K=5120.

For all 125 shapes, measured with gemm_a8w8_blockscale_tune.py
--run_config on MI350P:
- vs default B-preshuffle: geomean 1.46x, total time 1.65x
- vs plain blockscale GEMM: geomean 1.90x, total time 2.14x
@a-sidorova
a-sidorova force-pushed the asidorov/feature/tuned_a8w8_bpreshuffle_qwen38_27b_fp8 branch from 287fd82 to 5038613 Compare October 27, 2026 10:55
Copilot AI balanced review requested due to automatic review settings October 27, 2026 10:55

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

Human review is needed to reconcile the reported fallback behavior with the intended exclusions before approving these tuning selections.

1 open issue

Review effort: Balanced

@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

@yifehuan
yifehuan merged commit 4e9fa41 into ROCm:main Oct 28, 2026
63 checks passed
vpietila-amd pushed a commit that referenced this pull request Oct 28, 2026
….8-27B (#6939)

a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv had only gfx950
rows for 256 CUs (MI355X). On MI350P (gfx950, 128 CUs) no row matches,
so every Qwen3.8-27B-FP8 GEMM uses the default B-preshuffle kernel. For
M <= 16 the default kernel is slower than the plain blockscale GEMM
(geomean 0.86x, down to 0.74x).

Add 121 gfx950/128-CU rows, tuned over ck, cktile and asm with the
shapes in a8w8_blockscale_bpreshuffle_untuned_gemm_qwen38_27b.csv
(asm 51, ck 42, cktile 28). Four shapes are not added because the tuned
kernel was not faster than the default kernel: M=24 N=16384 K=5120 and
M=48/56/64 N=34816 K=5120.

For all 125 shapes, measured with gemm_a8w8_blockscale_tune.py
--run_config on MI350P:
- vs default B-preshuffle: geomean 1.46x, total time 1.65x
- vs plain blockscale GEMM: geomean 1.90x, total time 2.14x
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
….8-27B (#6939)

a8w8_blockscale_bpreshuffle_tuned_gemm_qwen38_27b.csv had only gfx950
rows for 256 CUs (MI355X). On MI350P (gfx950, 128 CUs) no row matches,
so every Qwen3.8-27B-FP8 GEMM uses the default B-preshuffle kernel. For
M <= 16 the default kernel is slower than the plain blockscale GEMM
(geomean 0.86x, down to 0.74x).

Add 121 gfx950/128-CU rows, tuned over ck, cktile and asm with the
shapes in a8w8_blockscale_bpreshuffle_untuned_gemm_qwen38_27b.csv
(asm 51, ck 42, cktile 28). Four shapes are not added because the tuned
kernel was not faster than the default kernel: M=24 N=16384 K=5120 and
M=48/56/64 N=34816 K=5120.

For all 125 shapes, measured with gemm_a8w8_blockscale_tune.py
--run_config on MI350P:
- vs default B-preshuffle: geomean 1.46x, total time 1.65x
- vs plain blockscale GEMM: geomean 1.90x, total time 2.14x
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.

3 participants