Skip to content

Add gfx950 a8w8 blockscale GEMM tunings for Qwen3-14B-FP8 - #7383

Merged
demonsan merged 9 commits into
ROCm:mainfrom
xiaofei-zheng:feature/xiaofei/qwen3-14b-a8w8-blockscale-gfx950
Nov 5, 2026
Merged

demonsan merged 9 commits into
ROCm:mainfrom
xiaofei-zheng:feature/xiaofei/qwen3-14b-a8w8-blockscale-gfx950

Conversation

@xiaofei-zheng

@xiaofei-zheng xiaofei-zheng commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On gfx950 (MI355X, cu_num=256), gemm_a8w8_blockscale has no tuned rows for Qwen3-14B-FP8's four TP1 linear shapes. Main therefore runs the CK default instance below M=384 and Triton from M=384 on (#5586). This PR adds 69 rows for those shapes, plus the untuned list they were tuned from. It also runs split-K rows without split-K for output other than BF16.

Motivation

On gfx950, vLLM's AiterFp8BlockScaledMMKernel calls the non-preshuffled gemm_a8w8_blockscale. a8w8_blockscale_tuned_gemm_qwen3_14b.csv holds only the gfx942 rows from #5839. #6862 and #6898 tuned the bpreshuffle table, which is the one SGLang uses.

Changes

  • a8w8_blockscale_tuned_gemm_qwen3_14b.csv: 69 gfx950 rows, of which 47 are CK, 9 CK-Tile and 13 FlyDSL, and 36 use split-K. The gfx942 rows do not change.
  • a8w8_blockscale_untuned_gemm_qwen3_14b.csv (new): the four shapes at M = 1, 2, 4, 8, 16, 32, 48, 64, 80, 96, 112, 128, 256, 512, 1024, 2048, 4096 and 8192.
  • Candidates come from gemm_a8w8_blockscale_tune.py with --libtype both (run with and without --splitK) and with --libtype flydsl. The tuner's profiler times for split-K candidates are sometimes far too low. I therefore re-timed each shape's 8 fastest candidates with CUDA graphs over cold inputs, against main's own dispatch, and kept a row only if it was at least 3% faster. I left out CK-Tile split-K candidates.
  • Not added:
    • o and down at M=512, where Triton is faster;
    • qkv at M=512, because M=384 pads onto that row and Triton is faster at M=384.
  • gemm_a8w8_blockscale: for output other than BF16, a split-K CK or CK-Tile row now runs its kernel with splitK=0 and logs one warning per (N, K, dtype). Split-K adds its partial sums atomically in the output dtype, which can overflow FP16 and return NaN. The kernel itself handles FP16, so only split-K is dropped; the row keeps its backend and that backend's stride handling. This also covers the 810 split-K rows already on main.
  • op_tests/test_gemm_a8w8_blockscale_fallback.py: 4 dispatch cases for this change, plus the pytest.main entry that the other pytest-style op tests have. Without that entry, aiter_test.sh ran none of this file's cases.

Performance (if applicable)

GEMM speedup through main's production op on one MI355X GPU. Each cell compares main's tables against main's tables plus these rows, timed with CUDA graphs over cold inputs, and gives the range over the tuned M values in that bucket:

M qkv (7168, 5120) o (5120, 5120) gate_up (34816, 5120) down (5120, 17408)
1–16 1.91–2.15× 2.24–2.55× 1.12–1.16× 3.24–3.51×
32–64 1.22–1.46× 1.39–1.66× 1.24–1.29× 1.83–2.41×
80–256 1.38–1.82× 1.11–1.57× 1.59–2.79× 1.49–1.67×
512 – – 1.99× –
1024–8192 1.40–2.49× 1.38–2.55× 2.19–2.39× 1.50–2.96×

I also timed 98 padded M values from 3 to 16384 that reach a row; all of them fall within the range of this table. The other padded M values keep main's dispatch.

End to end, the two servers differ only in AITER_CONFIG_GEMM_A8W8_BLOCKSCALE: main's tables, or main's tables plus these rows. Each arm ran on 8 servers over 4 rounds, and the arms swapped GPUs between rounds.

Hardware Workload/configuration Before After Change
MI355X, TP1, ROCm 10.0 vLLM 0.27.1 with VLLM_ROCM_USE_AITER=1 and this branch's aiter Python; Qwen3-14B-FP8, --kv-cache-dtype fp8; 320 random prompts, 1024 in / 1024 out, concurrency 64; output throughput 4709 tok/s 5902 tok/s +25.3%
median TPOT 12.83 ms 10.36 ms −19.3%
median TTFT 771 ms 506 ms −34.4%
GSM8K 5-shot, 1319 questions 0.8976 0.8946–0.9030 over 3 runs

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

The rows are gfx950-only, so testing was done on MI355X.

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The gemm_a8w8_blockscale docstring now states that split-K rows run without split-K for output other than BF16.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None.

PR Self-Review

Reviewed revision

6910f67

Behavior and intent

On gfx950 with cu_num=256, lookups for these four (N, K) pairs now hit tuned rows instead of main's untuned dispatch. The exception is M=257–512 for qkv, o and down, which keeps main's dispatch.

In every table, a split-K CK or CK-Tile row runs without split-K for output other than BF16, and every other call dispatches as before. Operand dtype is not part of the blockscale key, so these rows, like the existing ones, assume E4M3 operands.

Validation and unverified scope

  • op_tests/tuning_tests/test_csv_validation.py (19 passed) and test_config_shape_collision.py (30 passed). I merged the rows with all 18 non-preshuffled tables main reads, and no key is duplicated.
  • python3 op_tests/test_gemm_a8w8_blockscale_fallback.py, run the way aiter_test.sh runs it: 15 passed. The 4 new cases fail without the dispatch change.
  • 188 production-op lookups (47 M values × 4 shapes) match the torch reference, with errRatio ≤ 0.0032; nonzero values occur only on split-K rows. On Copilot's FP16 input, the split-K rows returned NaN for every output before the change and return none after it, and BF16 timings do not change.
  • Environment: this branch's aiter Python over the compiled modules of aiter 0.1.20.post1, which has the same CK and CK-Tile instance lists as main.
  • Unverified:
    • main's own compiled CK modules;
    • test_run_config.py, which needs main built from source;
    • test_gemm_a8w8_blockscale.py, which stops at a CK-Tile split-K case in this environment, with or without this PR;
    • other gfx950 parts;
    • TP > 1.

PR-specific question

The keys are (gfx950, 256, M, N, K) for the four (N, K) pairs at the untuned M values, except M=512 for qkv, o and down. Through get_padded_m, every M for gate_up resolves to one of these rows, and so does every M outside 257–512 for the other three layers. An M above 8192 resolves to the M=8192 row.

Lookups match N and K exactly, so other shapes cannot reach these rows. I ran get_CKGEMM_config with and without the rows over all 137 (N, K) pairs in main's tables, at every M from 1 to 1024 and at powers of two up to 32768. None of the 136,857 lookups for other pairs changed. test_config_shape_collision.py confirms that no other table has these keys.

Changed op tests

test_gemm_a8w8_blockscale_fallback.py replaces the backends with recorders and pins which one gemm_a8w8_blockscale reaches.

  • test_gemm_a8w8_blockscale_drops_split_k_for_fp16 checks CK and CK-Tile split-K rows on both sides of the threshold. FP16 output runs the row with splitK=0, and BF16 output keeps its split-K.
  • The existing cases vary only M and the arch, always with BF16 output, so they do not cover this.
  • The existing tuned-row case now tells a tuned CK call from the default one.
  • The new pytest.main entry is what makes CI run the file at all.

Hyperloom found the gap while optimizing Qwen/Qwen3-14B-FP8 on MI355X.


Powered by Hyperloom, with human review, writing and testing.

vLLM runs the non-preshuffled op on gfx950, where this table had gfx942 rows only.

Signed-off-by: xiaofei.zheng <[email protected]>
@xiaofei-zheng
xiaofei-zheng requested review from a team and a balanced review from Copilot November 3, 2026 07:35
@github-actions

github-actions Bot commented Nov 3, 2026

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

@github-actions github-actions Bot added the Config label Nov 3, 2026
@aiter-bot

aiter-bot commented Nov 3, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 6910f671d630 · 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 gfx950 with `cu_num=256`, lookups for these four (N, K) pairs now hit tuned rows instead of main's untuned dispatch. The exception is M=257–512 for qkv, o and down, which keeps main's dispatch.

In every table, a split-K CK or CK-Tile row runs without split-K for output other than BF16, and every other call dispatches as before. Operand dtype is not part of the blockscale key, so these rows, like the existing ones, assume E4M3 operands.

Validation and unverified scope

- `op_tests/tuning_tests/test_csv_validation.py` (19 passed) and `test_config_shape_collision.py` (30 passed). I merged the rows with all 18 non-preshuffled tables main reads, and no key is duplicated.
- `python3 op_tests/test_gemm_a8w8_blockscale_fallback.py`, run the way `aiter_test.sh` runs it: 15 passed. The 4 new cases fail without the dispatch change.
- 188 production-op lookups (47 M values × 4 shapes) match the torch reference, with errRatio ≤ 0.0032; nonzero values occur only on split-K rows. On Copilot's FP16 input, the split-K rows returned NaN for every output before the change and return none after it, and BF16 timings do not change.
- Environment: this branch's aiter Python over the compiled modules of aiter 0.1.20.post1, which has the same CK and CK-Tile instance lists as main.
- Unverified:
  - main's own compiled CK modules;
  - `test_run_config.py`, which needs main built from source;
  - `test_gemm_a8w8_blockscale.py`, which stops at a CK-Tile split-K case in this environment, with or without this PR;
  - other gfx950 parts;
  - TP > 1.

PR-specific question

The keys are `(gfx950, 256, M, N, K)` for the four (N, K) pairs at the untuned M values, except M=512 for qkv, o and down. Through `get_padded_m`, every M for gate_up resolves to one of these rows, and so does every M outside 257–512 for the other three layers. An M above 8192 resolves to the M=8192 row.

Lookups match N and K exactly, so other shapes cannot reach these rows. I ran `get_CKGEMM_config` with and without the rows over all 137 (N, K) pairs in main's tables, at every M from 1 to 1024 and at powers of two up to 32768. None of the 136,857 lookups for other pairs changed. `test_config_shape_collision.py` confirms that no other table has these keys.

Changed op tests

`test_gemm_a8w8_blockscale_fallback.py` replaces the backends with recorders and pins which one `gemm_a8w8_blockscale` reaches.

- `test_gemm_a8w8_blockscale_drops_split_k_for_fp16` checks CK and CK-Tile split-K rows on both sides of the threshold. FP16 output runs the row with splitK=0, and BF16 output keeps its split-K.
- The existing cases vary only M and the arch, always with BF16 output, so they do not cover this.
- The existing tuned-row case now tells a tuned CK call from the default one.
- The new `pytest.main` entry is what makes CI run the file at all.

Hyperloom found the gap while optimizing `Qwen/Qwen3-14B-FP8` on MI355X.

---

Powered by [Hyperloom](https://github.com/AMD-AGI/Hyperloom), with human review, writing and testing.

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.

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 gfx950 rows lack benchmarks against main’s actual Triton fallback and may mishandle incompatible operand or scale layouts.

2 open issues
What changed in this PR

Adds gfx950 tuning coverage for Qwen3-14B-FP8’s non-preshuffled blockscale GEMM path used by vLLM, complementing the existing preshuffled tunings.

Changes:

  • Adds 72 rows for 256-CU gfx950 GPUs across four TP1 projection shapes, with M values from 1 to 8192.
  • Selects CK and CKTile kernels, including split-K configurations.
  • Leaves existing gfx942 rows unchanged.
File Description
aiter/​configs/​model_configs/​a8w8_blockscale_tuned_gemm_qwen3_14b.csv Adds gfx950 kernel selections and tuning metrics for Qwen3-14B-FP8.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 3, 2026 07:43

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 new rows can produce incorrect results or reject supported strided inputs, and their performance has not been compared against the current Triton dispatch.

2 open issues

Review effort: Balanced

… main's dispatch, with FlyDSL

Signed-off-by: xiaofei.zheng <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 08:48

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

Split-K can produce NaNs for FP16 output, and dtype-agnostic kernel selection can fail for E5M2 inputs or produce incorrect results for int8 inputs.

2 open issues
2 resolved since last review

Review effort: Balanced

…s in gemm_a8w8_blockscale

Signed-off-by: xiaofei.zheng <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 09:55
@github-actions github-actions Bot changed the title [Config] Add gfx950 a8w8 blockscale GEMM tunings for Qwen3-14B-FP8 Add gfx950 a8w8 blockscale GEMM tunings for Qwen3-14B-FP8 Nov 3, 2026
@github-actions github-actions Bot removed the Config label Nov 3, 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.

🟡 Changes recommended

Non-E4M3 inputs can still reach CK and be misinterpreted, while the new regression tests are skipped in CI and an existing gfx942 test fails.

5 open issues

Review effort: Balanced

Comment thread aiter/ops/gemm_op_a8w8.py Resolved
Comment thread aiter/ops/gemm_op_a8w8.py Resolved
Copilot AI balanced review requested due to automatic review settings November 3, 2026 10:27

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 FlyDSL row mishandles E5M2 and numeric int8 operands on gfx950 because the operand-format guard is missing, and regression cases for both formats are needed.

4 open issues
2 resolved since last review

Review effort: Balanced

Comment thread aiter/ops/gemm_op_a8w8.py Resolved
Copilot AI balanced review requested due to automatic review settings November 4, 2026 02:36

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

Rejecting the CK-Tile split-K row can route strided scales to CK, which reads them incorrectly for a supported FP16 output case.

2 open issues
3 resolved since last review

Review effort: Balanced

Comment thread aiter/ops/gemm_op_a8w8.py Resolved
Copilot AI balanced review requested due to automatic review settings November 4, 2026 06:22

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 gfx950 tuning additions and cross-architecture FP16 split-K changes still need GPU correctness and performance validation using CK/CK-Tile modules built from this revision, since supplied results used older prebuilt modules.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 4, 2026 06:32

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

Reported checks used older binaries, leaving GPU numerical and performance validation against source-built head CK/CK-Tile modules unverified for the new gfx950 rows and FP16 split-K changes affecting existing cross-architecture dispatch.

1 open issue

Review effort: Balanced

@xiaofei-zheng

Copy link
Copy Markdown
Contributor Author

@demonsan Could you take a look? Two open questions:

  1. Split-K adds partial sums atomically in the output dtype, so FP16 output overflows (Copilot's thread on the CSV). gemm_a8w8_blockscale now runs split-K CK/CK-Tile rows with splitK=0 when the output is not BF16. This also applies to the 761 split-K rows already on main; BF16 is unchanged. FP16 at splitK=0 has been run on real kernels only for this PR's gfx950 rows.
  2. The blockscale table key has no operand dtype, and CK-Tile does not check for E4M3. Five of the new rows at M >= 384 are CK-Tile where main used Triton, so E5M2 input would be misread there without an error; FlyDSL rows assert. Following [HIP] [CK] Honour row-strided out and route fp16 output off asm rows in a8w8 blockscale bpreshuffle GEMM #6934, I did not add a check. Should gemm_a8w8_blockscale assert E4M3 operands at entry?

The red CI is infrastructure: the py3.12 wheel build could not pull the docker.io/rocm/pytorch image, so no test ran. The last complete run, on 6f36d03, passed.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 09: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 cross-architecture FP16 split-K changes and gfx950 tuning rows still require GPU correctness and performance validation against main-built CK/CK-Tile modules, which static review and older-build results cannot establish.

1 open issue

Review effort: Balanced

@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

@demonsan
demonsan merged commit 98a9f16 into ROCm:main Nov 5, 2026
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