Skip to content

[Triton][gfx1151] Enable GEMM-A16W16 - #4814

Closed
tangzzycc wants to merge 1 commit into
ROCm:mainfrom
tangzzycc:feat/gfx1151-gemm-a16w16
Closed

tangzzycc wants to merge 1 commit into
ROCm:mainfrom
tangzzycc:feat/gfx1151-gemm-a16w16

Conversation

@tangzzycc

Copy link
Copy Markdown
Contributor

Motivation

Enable the Triton GEMM-A16W16 path on gfx1151.

Before this change, calling gemm_a16w16 on a gfx1151 device failed during config resolution because no architecture-specific default config existed:

AssertionError: Required config file doesn't exist:
.../aiter/ops/triton/configs/gemm/gfx1151-GEMM-A16W16.json

This prevented BF16 A16W16 GEMMs from using the existing Triton kernel on gfx1151. The goal of this PR is to provide a robust generic default config so the public wrapper works without adding architecture-specific kernel code.

Related gfx1151 enablement precedent: #3917.

Technical Details

Added the gfx1151 Triton default config using the current nested config layout:

aiter/ops/triton/configs/gfx1151/triton/gemm/gemm_a16w16/DEFAULT.json

The default is split into three M ranges based on correctness and performance screening across synthetic and representative LLM shapes:

M range Tile (BM, BN, BK) Warps Waves/EU B-load cache policy
M <= 256 (32, 16, 256) 2 1 default
257 <= M <= 1024 (32, 32, 256) 4 1 default
fallback (64, 64, 256) 4 2 .cg

All entries use GROUP_SIZE_M=1, num_stages=2, matrix_instr_nonkdim=16, and NUM_KSPLIT=1.

The small-M config favors decode and small-batch projection workloads. The middle bucket avoids regressions observed when extending the small tile to M=512/1024. The fallback prioritizes stable performance across larger M and mixed N/K shapes.

This PR changes only JSON tuning data. It does not modify the kernel, config resolver, dispatcher, or public API.

Test Plan

Test environment:

  • GPU: AMD Radeon 8060S (gfx1151, 40 CUs)
  • ROCm: 7.2
  • PyTorch: 2.12.1+rocm7.2
  • Triton: 3.7.1
  • Input/output dtype: BF16

Run the existing real-shape GEMM correctness coverage for the Triton backend:

pytest -q \
  op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16 \
  -k 'bandwidth_bound and triton and (7168 or 2880)'

Run representative performance measurements through the existing benchmark:

python op_tests/op_benchmarks/triton/bench_gemm_a16w16.py \
  --shape M N K --metric time --backend triton

Performance screening used triton.testing.do_bench with 25 warmup iterations and 100 measured iterations. AITER and torch.addmm both used preallocated BF16 outputs and included bias. Each candidate config was checked against torch.nn.functional.linear before timing.

Representative shapes were taken from GPT-OSS 120B, DeepSeek-R1/Kimi-K2, and Llama 3 8B projection/FFN layers, covering decode, small-batch, and prefill M ranges.

Test Result

Existing pytest coverage:

16 passed, 16 skipped, 68 deselected in 5.20s

Additional public-wrapper correctness validation passed for all 16 tested model shapes, including both config boundaries and the fallback range.

Representative BF16 latency results:

Workload Shape (M, N, K) AITER torch.addmm Speedup
GPT-OSS attention projection (1, 128, 2880) 21.96 us 78.24 us 3.56x
GPT-OSS dense projection (256, 2880, 4096) 488.18 us 846.07 us 1.73x
DeepSeek/Kimi projection (64, 256, 7168) 65.90 us 361.01 us 5.48x
DeepSeek/Kimi projection (1024, 256, 7168) 388.73 us 455.06 us 1.17x
Llama 3 8B FFN down (64, 4096, 14336) 1.167 ms 1.842 ms 1.58x
Llama 3 8B FFN down (1024, 4096, 14336) 8.535 ms 10.471 ms 1.23x
Llama 3 8B FFN down (2048, 4096, 14336) 13.771 ms 14.796 ms 1.07x

AITER was faster than torch.addmm on 12 of the 16 representative model shapes, with up to 5.69x speedup on small-M projection workloads. This config is intended as a robust generic default; additional N/K-specific tuning can be added separately for workloads that benefit from specialized configs.

Submission Checklist

@tangzzycc
tangzzycc requested review from a team and a lite review from Copilot August 18, 2026 03:39
@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; 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 4814 --add-label <label>

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.

Pull request overview

Adds the missing gfx1151 Triton tuning defaults needed for get_gemm_config("GEMM-A16W16", ...) to resolve successfully on gfx1151, enabling the existing gemm_a16w16 Triton path without changing kernel or resolver code.

Changes:

  • Add nested-layout default config for gfx1151 Triton GEMM-A16W16 under .../gfx1151/triton/gemm/gemm_a16w16/DEFAULT.json.
  • Provide three M buckets via M_LEQ_256, M_LEQ_1024, and any, including required config fields (BLOCK_SIZE_*, GROUP_SIZE_M, num_warps, num_stages, waves_per_eu, matrix_instr_nonkdim, cache_modifier, NUM_KSPLIT).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026
azaidy pushed a commit that referenced this pull request Oct 9, 2026
* [Triton] [Config] Seed gfx1150 (RDNA3.5) configs from gfx1151

gfx1150 ships no table for MHA, unified_attention, conv_3x3_nchw,
gemm_a8w8, gemm_a8w8_blockscale and gemm_afp4wfp4, so flash_attn_func
and the three GEMMs fail at config resolution on that arch.

Seed them from gfx1151, as configs/CLAUDE.md describes for an arch
without tuning: 15 files, each a byte-identical copy of the same path
under gfx1151/triton/. gfx1150 and gfx1151 are both RDNA3.5; this is a
placeholder, not tuning.

- unified_attention_utils.py: drop the gfx1150 entry from _ARCH_ALIAS,
  so the new gfx1150 file is the one read. Its content is identical.
- gemm_afp4wfp4.py: the triton-backend exception to is_fp4_avail()
  admits gfx1150 beside gfx1151. Other FP4 entry points are unchanged.
- configs/CLAUDE.md: list gfx1151 -> gfx1150 among the seeding rules.

Signed-off-by: Martin Domanský <[email protected]>

* [Triton] [Config] Seed gfx1150 gemm_a16w16 config from #4814

gemm_a16w16 has no RDNA3.5 table on main yet. Copy the gfx1151 table
proposed in #4814 (head df9d0a8) byte-identical to gfx1150, so
gemm_a16w16 and fused_gemm_a16w16_quant_x resolve a config there.

Co-authored-by: tangzzycc <[email protected]>
Signed-off-by: Martin Domanský <[email protected]>

---------

Signed-off-by: Martin Domanský <[email protected]>
Co-authored-by: tangzzycc <[email protected]>
@tangzzycc tangzzycc closed this Oct 10, 2026
klin-amd added a commit that referenced this pull request Oct 19, 2026
…kets

The M_LEQ_1024 tile from #4814 (32x32x256) is slow for large N and K on
gfx1151. For example, 666 x 9728 x 2432 ran at 7.2 TFLOPS.

- M_LEQ_64: the #4814 M_LEQ_256 tile (32x16x256, 2 warps). It is the best
  or near the best for M <= 64.
- M_LEQ_256: 64x64x128, 4 warps (new).
- M_LEQ_1024: 128x64x64, 4 warps (new).

Over 10 shapes for each bucket, which include the LLM shapes of #4814, the
geomean goes from 17.0 to 27.1 TFLOPS for 256 < M <= 1024. No shape is
slower than with the #4814 tile.

Co-authored-by: tangzzycc <[email protected]>
Co-Authored-By: Claude <[email protected]>
azaidy pushed a commit that referenced this pull request Oct 21, 2026
* [Triton/Gluon] [Config] Add gfx1151 gemm_a16w16 DEFAULT.json

On gfx1151, gemm_a16w16 stops before it compiles a kernel, because there
is no configs/gfx1151/triton/gemm/gemm_a16w16/DEFAULT.json.

The M_LEQ_256 and M_LEQ_1024 buckets are the gfx1151 table from #4814
(@tangzzycc), the same values that #5997 seeded into gfx1150. The "any"
bucket (M > 1024) changes from 64x64x256 to 128x128x64: over 12 large-M
shapes on gfx1151 it measured 32.4 TFLOPS geomean against 25.3.

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

* [Triton/Gluon] [Config] gfx1151 gemm_a16w16: retune the M <= 1024 buckets

The M_LEQ_1024 tile from #4814 (32x32x256) is slow for large N and K on
gfx1151. For example, 666 x 9728 x 2432 ran at 7.2 TFLOPS.

- M_LEQ_64: the #4814 M_LEQ_256 tile (32x16x256, 2 warps). It is the best
  or near the best for M <= 64.
- M_LEQ_256: 64x64x128, 4 warps (new).
- M_LEQ_1024: 128x64x64, 4 warps (new).

Over 10 shapes for each bucket, which include the LLM shapes of #4814, the
geomean goes from 17.0 to 27.1 TFLOPS for 256 < M <= 1024. No shape is
slower than with the #4814 tile.

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

---------

Co-authored-by: tangzzycc <[email protected]>
@tangzzycc
tangzzycc deleted the feat/gfx1151-gemm-a16w16 branch November 28, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale The PR hasn't been updated in 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants