Repository navigation
[Triton/Gluon] gemm_a16w32: configs that fit the LDS on Triton 3.9 - #8701
Merged
Merged
Conversation
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]>
Contributor
There was a problem hiding this comment.
🟡 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
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
1 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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:#7770 added
gemm_a16w32with 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 keepsnum_stagescopies of it in LDS, in a padded layout:tt.load+local_allocasync_copy_global_to_localM_LEQ_256, fp32 weightM_LEQ_256,w_bf16x3weightA 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_bf16x3weights, 6 compute-bound buckets do not fit on Triton 3.9:GEMM-A16W32-N=128-K=6144.json:M_LEQ_256andany.DEFAULT.json:M_LEQ_256,M_LEQ_512,M_LEQ_1024andany.This PR replaces these buckets. The new values are measured on Triton 3.9 at N=128, K=6144 with the
w_bf16x3weights (MI355X):M_LEQ_256: the full sweep ofsweep_configs.py.M_LEQ_512,M_LEQ_1024andM_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.M_LEQ_512the 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.anyis a copy ofM_LEQ_8192, as the tuner writes it.GEMM-A16W32-N=128-K=6144.jsongets the newM_LEQ_512,M_LEQ_1024andM_LEQ_8192buckets.DEFAULT.jsongets the same values in its 4 buckets that overflowed. The other buckets do not change.test_gemm_a16w32_takes_w_bf16x3now runs one M for each bucket (1 to 8192), for the tuned shape (128, 6144) and for aDEFAULT.jsonshape (256, 3072). Before, it ran only 5 M values for one shape.Test plan
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.pyon Triton 3.8.0 and 3.9.0.harness.pyat M = 256, 512, 1024 and 8192 on both Triton versions.Test results
MI355X, vLLM nightly image (Triton 3.8.0) and the same image with the CI Triton 3.9.0 wheel.
test_gemm_a16w32.py: 89 passed on Triton 3.8.0, 89 passed on Triton 3.9.0.test_gemm_a16w32_takes_w_bf16x3cases fail (M = 256, 512, 1024 and 8192, both shapes).Time with the
w_bf16x3weights at N=128, K=6144 (us):PR Self-Review
Reviewed revision
165cb70
Behavior and intent
This PR changes only
gemm_a16w32configs and its test. On Triton 3.9, 6 compute-bound buckets need more LDS than gfx950 has when the caller gives thew_bf16x3weights, sogemm_a16w32fails withOutOfResources. 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).DEFAULT.jsonbuckets at shapes other than N=128, K=6144, and architectures other than gfx950. M from 1025 to 4096 keeps theM_LEQ_4096bucket ofDEFAULT.json, which fits (118,144 B) and does not change.PR-specific question
Only
gemm_a16w32reads these files. InGEMM-A16W32-N=128-K=6144.json,M_LEQ_256,M_LEQ_512,M_LEQ_1024,M_LEQ_8192andanychange or are new. InDEFAULT.json,M_LEQ_256,M_LEQ_512,M_LEQ_1024andanychange. 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 useDEFAULT.jsonand 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_bf16x3now runs one M for each bucket and also aDEFAULT.jsonshape. Thew_bf16x3weights need the most LDS, and the old 5 M values missed 5 of the 6 buckets that overflowed. No other test callsgemm_a16w32with thew_bf16x3weights.