Repository navigation
[Triton/Gluon] Add Split-K Variant of A8W8 BMM with Fused Reduce Quant - #6727
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
dbf61d1 to
7c507a1
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new path lacks required benchmark coverage and does not follow the shared-kernel reuse requirements.
4 open issues
What changed in this PR
Adds an optional Triton split-K path to A8W8 batched GEMM, with fused reduction and per-token FP8 output quantization.
Changes:
- Adds split-K and fused reduction kernels through the
y_scaleoption. - Adds gfx950 default and shape-specific configurations.
- Extends correctness tests for quantized output.
| File | Description |
|---|---|
op_tests/triton_tests/gemm/batched/test_batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py |
Tests quantized output after dequantization. |
aiter/ops/triton/gemm/batched/batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py |
Validates buffers and launches the new path. |
aiter/ops/triton/configs/gfx950/triton/gemm/batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant_y_per_token_quant/DEFAULT.json |
Supplies default split-K and reduction settings. |
aiter/ops/triton/configs/gfx950/triton/gemm/batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant_y_per_token_quant/BATCHED_GEMM-A8W8-A_PER_TOKEN_GROUP_PREQUANT_W_PER_BATCHED_TENSOR_QUANT-Y_PER_TOKEN_QUANT-B=16-N=128-K=512.json |
Supplies shape-specific settings. |
aiter/ops/triton/_triton_kernels/gemm/batched/batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py |
Implements split-K computation and fused output quantization. |
Review effort: Balanced
azaidy
left a comment
There was a problem hiding this comment.
MAJOR - the reduce tile is next_power_of_2(B * N) with no cap batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py:253 sets BLOCK_SIZE_N = triton.next_power_of_2(B * N), and every config bucket sets REDUCE_BLOCK_SIZE_M: 1 with REDUCE_num_warps 4 or 8. At B=16, N=8192 that is 131072 fp32 per workgroup, which is 512 fp32 per lane on 4 wave64 warps - more than the whole register file, before the loaded chunk and y are counted. 18 of the 49 shapes in get_x_vals() land there once y_per_token_quant=True is parametrized; the one tuned shape, B=16, N=128, K=512, needs only 8. Suggested fix: tile N in the reduce kernel and carry a running max, or assert a tested bound on B * N and skip the larger shapes in the test.
MAJOR - no benchmark for either new kernel bench_batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py:63-74 never passes y_scale, so do_bench still times the old kernel only. The PR body also carries no speedup table, no baseline commit and no Triton version. Suggested fix: add a --y-per-token-quant flag that allocates an FP8 YQ and an fp32 y_scale, sets transpose_bm=True, and fixes mem_write.
MAJOR - the split-K GEMM is 78 % a copy of the kernel above it difflib over kernel lines 36-207 against 238-395 gives 124 identical lines of 158. Three siblings already fold split-K into one kernel with a constexpr branch: batched_gemm_a16wfp4.py:129, batched_gemm_afp4wfp4.py:139, gemm_a8w8_blockscale.py:117. Suggested fix: add NUM_KSPLIT and SPLITK_BLOCK_SIZE to the existing kernel and branch on NUM_KSPLIT == 1 at the store, following batched_gemm_a16wfp4.py.
MAJOR - the new path is gfx950-only and dies with a bare assert elsewhere The base family ships DEFAULT.json on gfx942, gfx950, gfx1201 and gfx1250; ..._y_per_token_quant ships on gfx950 only. resolve_config_dir never probes, so any other arch hits AssertionError: Required config file doesn't exist. The test skip at line 204 hides it. Suggested fix: copy DEFAULT.json into the other three trees, or add an explicit arch check with a message that names the family.
MINOR - rule 6, two helpers re-inlined pid_grid (common/pid_preprocessing.py:58) at kernel line 314, and the FP8 per-token quant (quant/fused_fp8_quant.py:26, _fp8_quant_op) at kernel lines 485-488.
MINOR - a docstring shape is wrong Kernel line 279 says the partial sums are (NUM_KSPLIT, B, M, N); wrapper line 193 allocates (num_ksplit, M, B, N).
MINOR - the two new JSON files are byte-identical (md5 2672f23a3827349bf37bf77c7738a9b5, one git blob 00b890fb1). Neither sets DEFAULT_FALLBACK, so the B=16-N=128-K=512 file replaces DEFAULT.json with the same table and changes nothing.
MINOR - y_scale is an input in batched_gemm_a16wfp4 and an output here. Consider y_scale_out.
@farlukas please revise
a89d0db to
67f9f02
Compare
349bf76 to
6af4130
Compare
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
6af4130 to
458f3d6
Compare
… 3.9 Two changes in the K loop path of _batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant_kernel: 1. Use tl.fma for `accumulator += tl.dot(a, b) * a_scale`. Triton 3.9 does not fuse mul and add by default, so the old expression gave separate mul and add instructions (24 FMA vs. 60 on 3.8). 2. With NUM_KSPLIT == 1, skip the split-K range math added in ROCm#6727. SPLITK_BLOCK_SIZE >= K in that case, so k_span is always K and the result does not change. On 3.9 the extra scalar code moved the K loop by 20 bytes, so the loop spans 26 instead of 25 64-byte fetch blocks. With this change the loop is at the same place as before ROCm#6727. gfx950, bench default shapes (B=16, N=1280, K=8192), TFLOPS: M 3.8.0 3.9 before 3.9 after 64 226.8 224.6 243.8 128 456.5 441.7 478.5 192 619.3 570.2 605.1 256 508.6 494.9 518.4 All other default shapes are 2.8% to 8.1% faster than 3.8.0 on 3.9. On 3.8.0 the change is neutral (-0.9% to +0.1%). M=192 is still 2.3% below 3.8.0; this gap also shows before ROCm#6727 with FP fusion on. Co-Authored-By: Claude <[email protected]>
ROCm#6727) * Added split-k version of a8w8 BMM quant * Addressed comments * Renamed y_scale * Added default configs * Added default configs for gfx950 * Added BLOCK_SIZE_K to configs * Added guard for gluon * Ran black



Motivation
Add split-k variant of a8w8 batched GEMM with fused reduce + quant.
Test Plan
Test Result
All tests passed.
Submission Checklist