Skip to content

[Triton/Gluon] gemm_a16w32: configs that fit the LDS on Triton 3.9 - #8701

Merged
azaidy merged 1 commit into
mainfrom
vinayak/gemm-a16w32-lds
Nov 25, 2026
Merged

azaidy merged 1 commit into
mainfrom
vinayak/gemm-a16w32-lds

Conversation

@vgokhale

Copy link
Copy Markdown
Contributor

Motivation

Since the Triton 3.9 bump (#8266), test_gemm_a16w32_takes_w_bf16x3[256] fails on main and in the Triton shard of each PR:

triton.runtime.errors.OutOfResources: out of resource: shared memory, Required: 168832, Hardware limit: 163840

#7770 added gemm_a16w32 with configs that were tuned and tested on Triton 3.8. It merged after #8266, so these configs did not run on Triton 3.9 before the merge.

Technical details

Triton 3.9 also pipelines a load through LDS when its tile feeds more than one tt.dot. Triton 3.8 loads such a tile into registers and writes one copy to LDS. The bf16x3 kernel feeds the x tile to 3 dots (one for each bf16 term of the weight), so Triton 3.9 keeps num_stages copies of it in LDS, in a padded layout:

Triton 3.8 Triton 3.9
x tile (64 x 256 bf16) 1 buffer, tt.load + local_alloc 2 buffers, async_copy_global_to_local
LDS, M_LEQ_256, fp32 weight 98,304 B 133,088 B
LDS, M_LEQ_256, w_bf16x3 weight 134,048 B 168,832 B (limit 163,840)

A minimal kernel shows the same change: when the A tile feeds 1 dot, both versions pipeline it. When it feeds 2 or 3 dots, only Triton 3.9 does.

With the w_bf16x3 weights, 6 compute-bound buckets do not fit on Triton 3.9:

  • GEMM-A16W32-N=128-K=6144.json: M_LEQ_256 and any.
  • DEFAULT.json: M_LEQ_256, M_LEQ_512, M_LEQ_1024 and any.

This PR replaces these buckets. The new values are measured on Triton 3.9 at N=128, K=6144 with the w_bf16x3 weights (MI355X):

  • M_LEQ_256: the full sweep of sweep_configs.py.
  • M_LEQ_512, M_LEQ_1024 and M_LEQ_8192: the 100 fastest configs at M=256 and a grid of larger tiles (BM 64 to 256, BN 32 and 64, BK 64 to 256, split-K 1 to 8), 388 configs for each M, and a final round of the 10 fastest on one GPU.
  • For M_LEQ_512 the second-best config on Triton 3.9 is used (11.74 us, best 11.69 us). The best one takes 17.35 us on Triton 3.8.
  • any is a copy of M_LEQ_8192, as the tuner writes it.

GEMM-A16W32-N=128-K=6144.json gets the new M_LEQ_512, M_LEQ_1024 and M_LEQ_8192 buckets. DEFAULT.json gets the same values in its 4 buckets that overflowed. The other buckets do not change.

test_gemm_a16w32_takes_w_bf16x3 now runs one M for each bucket (1 to 8192), for the tuned shape (128, 6144) and for a DEFAULT.json shape (256, 3072). Before, it ran only 5 M values for one shape.

Test plan

  • Compile each compute-bound bucket of both files for gfx950 on Triton 3.8.0 and 3.9.0 (the CI wheel 3.9.0+amd.rocm7.2.0.git24d5394c) with both weight forms. Read the shared memory from the compiled kernel.
  • pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w32.py on Triton 3.8.0 and 3.9.0.
  • Time the old and new configs with harness.py at M = 256, 512, 1024 and 8192 on both Triton versions.
  • Run the new test with the configs of main on Triton 3.9.

Test results

MI355X, vLLM nightly image (Triton 3.8.0) and the same image with the CI Triton 3.9.0 wheel.

  • All buckets fit on both versions. The largest is 135,040 B on Triton 3.9.
  • test_gemm_a16w32.py: 89 passed on Triton 3.8.0, 89 passed on Triton 3.9.0.
  • With the configs of main on Triton 3.9, 8 of the 16 test_gemm_a16w32_takes_w_bf16x3 cases fail (M = 256, 512, 1024 and 8192, both shapes).

Time with the w_bf16x3 weights at N=128, K=6144 (us):

M Triton 3.8, old Triton 3.8, new Triton 3.9, old Triton 3.9, new
256 10.52 9.43 OutOfResources 8.86
512 11.85 12.02 OutOfResources 11.74
1024 16.91 16.45 OutOfResources 15.88
8192 58.67 57.55 OutOfResources 53.17

PR Self-Review

Reviewed revision

165cb70

Behavior and intent

This PR changes only gemm_a16w32 configs and its test. On Triton 3.9, 6 compute-bound buckets need more LDS than gfx950 has when the caller gives the w_bf16x3 weights, so gemm_a16w32 fails with OutOfResources. The new buckets fit on Triton 3.8 and 3.9. No kernel or wrapper code changes.

Validation and unverified scope

  • pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w32.py: 89 passed on Triton 3.8.0 and 89 passed on Triton 3.9.0 (MI355X).
  • With the old configs on Triton 3.9, the new test cases fail for each bucket that overflowed (8 of 16).
  • The shared memory of each compute-bound bucket is below 163,840 B on both versions (largest 135,040 B).
  • Unverified: the time of the DEFAULT.json buckets at shapes other than N=128, K=6144, and architectures other than gfx950. M from 1025 to 4096 keeps the M_LEQ_4096 bucket of DEFAULT.json, which fits (118,144 B) and does not change.

PR-specific question

Only gemm_a16w32 reads these files. In GEMM-A16W32-N=128-K=6144.json, M_LEQ_256, M_LEQ_512, M_LEQ_1024, M_LEQ_8192 and any change or are new. In DEFAULT.json, M_LEQ_256, M_LEQ_512, M_LEQ_1024 and any change. All other buckets keep their values, so M up to 128 and M from 1025 to 4096 keep their previous selection. Shapes without a tuned file use DEFAULT.json and get the new values only in these 4 buckets. No other op reads these files.

Changed op tests

  • op_tests/triton_tests/gemm/basic/test_gemm_a16w32.py: test_gemm_a16w32_takes_w_bf16x3 now runs one M for each bucket and also a DEFAULT.json shape. The w_bf16x3 weights need the most LDS, and the old 5 M values missed 5 of the 6 buckets that overflowed. No other test calls gemm_a16w32 with the w_bf16x3 weights.

Triton 3.9 also pipelines the x tile through LDS when the tile feeds
more than one dot. The bf16x3 kernel feeds it to 3 dots, so each config
needs about 34.8 KB more LDS. With the w_bf16x3 weights, 6 compute-bound
buckets then need more than 160 KiB and fail with OutOfResources, for
example M_LEQ_256 with 168,832 B. Since the Triton 3.9 bump (#8266),
test_gemm_a16w32_takes_w_bf16x3[256] fails on main.

The new buckets are measured on Triton 3.9 at N=128, K=6144 with the
w_bf16x3 weights. M_LEQ_256 comes from a full sweep. M_LEQ_512,
M_LEQ_1024 and M_LEQ_8192 come from the 100 fastest configs at M=256 and
a grid of larger tiles. For M_LEQ_512 the second-best config on Triton
3.9 is used, because the best one is 46% slower on Triton 3.8. "any" is
a copy of M_LEQ_8192. DEFAULT.json gets the same values in the 4 buckets
that overflowed. All buckets fit on Triton 3.8 and 3.9.

test_gemm_a16w32_takes_w_bf16x3 now runs one M for each bucket, for the
tuned shape and for a DEFAULT.json shape. With the configs of main on
Triton 3.9, 8 of its 16 cases fail.

Signed-off-by: Vinayak Gokhale <[email protected]>
@vgokhale
vgokhale requested a review from a team November 25, 2026 15:54
@vgokhale vgokhale self-assigned this Nov 25, 2026
@vgokhale
vgokhale requested a review from azaidy November 25, 2026 17:38
@Boss2002n
Boss2002n requested a balanced review from Copilot November 25, 2026 18:33

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 LDS test comment in test_gemm_a16w32.py exceeds Triton’s two-sentence limit and should be shortened while preserving the test’s rationale.

1 open issue
What changed in this PR

This PR updates gfx950 configurations for gemm_a16w32 to address shared-memory overflows exposed by Triton 3.9 when using pre-split bf16 weights. Kernel and wrapper code remain unchanged.

Changes:

  • Retunes affected buckets in the shape-specific and default configurations.
  • Expands pre-split-weight tests across more M values and both configuration paths.
File Description
op_tests/​triton_tests/​gemm/​basic/​test_gemm_a16w32.py Expands regression coverage for tuned and default shapes.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_a16w32/​GEMM-A16W32-N=128-K=6144.json Replaces overflowing settings and adds larger-M buckets.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_a16w32/​DEFAULT.json Updates four affected fallback buckets.

Review effort: Balanced

@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 165cb70dde47 · 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 PR changes only `gemm_a16w32` configs and its test. On Triton 3.9, 6 compute-bound buckets need more LDS than gfx950 has when the caller gives the `w_bf16x3` weights, so `gemm_a16w32` fails with `OutOfResources`. The new buckets fit on Triton 3.8 and 3.9. No kernel or wrapper code changes.

Validation and unverified scope

- `pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w32.py`: 89 passed on Triton 3.8.0 and 89 passed on Triton 3.9.0 (MI355X).
- With the old configs on Triton 3.9, the new test cases fail for each bucket that overflowed (8 of 16).
- The shared memory of each compute-bound bucket is below 163,840 B on both versions (largest 135,040 B).
- Unverified: the time of the `DEFAULT.json` buckets at shapes other than N=128, K=6144, and architectures other than gfx950. M from 1025 to 4096 keeps the `M_LEQ_4096` bucket of `DEFAULT.json`, which fits (118,144 B) and does not change.

PR-specific question

Only `gemm_a16w32` reads these files. In `GEMM-A16W32-N=128-K=6144.json`, `M_LEQ_256`, `M_LEQ_512`, `M_LEQ_1024`, `M_LEQ_8192` and `any` change or are new. In `DEFAULT.json`, `M_LEQ_256`, `M_LEQ_512`, `M_LEQ_1024` and `any` change. All other buckets keep their values, so M up to 128 and M from 1025 to 4096 keep their previous selection. Shapes without a tuned file use `DEFAULT.json` and get the new values only in these 4 buckets. No other op reads these files.

Changed op tests

- `op_tests/triton_tests/gemm/basic/test_gemm_a16w32.py`: `test_gemm_a16w32_takes_w_bf16x3` now runs one M for each bucket and also a `DEFAULT.json` shape. The `w_bf16x3` weights need the most LDS, and the old 5 M values missed 5 of the 6 buckets that overflowed. No other test calls `gemm_a16w32` with the `w_bf16x3` weights.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • FAIL — an active Copilot finding has no substantive reply from the PR author

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.

@azaidy azaidy 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!

@azaidy
azaidy merged commit 76f19a0 into main Nov 25, 2026
59 of 60 checks passed
@azaidy
azaidy deleted the vinayak/gemm-a16w32-lds branch November 25, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants