Skip to content

[Triton/Gluon] Add Split-K Variant of A8W8 BMM with Fused Reduce Quant - #6727

Merged
azaidy merged 8 commits into
mainfrom
farlukas/bmm-reduce-fused-quant
Nov 3, 2026
Merged

azaidy merged 8 commits into
mainfrom
farlukas/bmm-reduce-fused-quant

Conversation

@farlukas

@farlukas farlukas commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Add split-k variant of a8w8 batched GEMM with fused reduce + quant.

Test Plan

pytest -xv op_tests/triton_tests/gemm/batched/test_batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py

Test Result

All tests passed.

Submission Checklist

@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 (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 6727 --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.

@farlukas
farlukas force-pushed the farlukas/bmm-reduce-fused-quant branch from dbf61d1 to 7c507a1 Compare October 20, 2026 16:15
@farlukas
farlukas marked this pull request as ready for review October 20, 2026 18:10
@farlukas
farlukas requested a review from a team October 20, 2026 18:10
@github-actions github-actions Bot changed the title Add Split-K Variant of A8W8 BMM with Fused Reduce Quant [Triton/Gluon] Add Split-K Variant of A8W8 BMM with Fused Reduce Quant Oct 20, 2026
@azaidy
azaidy self-requested a review October 20, 2026 22:24
@azaidy azaidy self-assigned this Oct 20, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 20, 2026 22: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.

🟡 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_scale option.
  • 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 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.

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

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.

azaidy
azaidy previously approved these changes Oct 27, 2026

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

@farlukas please resolve conflicts.

azaidy
azaidy previously approved these changes Oct 27, 2026

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

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 benchmark accepts an unsupported Gluon and quantized-output flag combination that fails at the wrapper assertion.

1 open issue
2 resolved since last review

Review effort: Balanced

@farlukas
farlukas force-pushed the farlukas/bmm-reduce-fused-quant branch 2 times, most recently from 349bf76 to 6af4130 Compare October 29, 2026 16:51
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 458f3d65df8e · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/triton_tests/gemm/batched/test_batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@farlukas
farlukas force-pushed the farlukas/bmm-reduce-fused-quant branch from 6af4130 to 458f3d6 Compare November 2, 2026 15:55

@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 bdc20d0 into main Nov 3, 2026
@azaidy
azaidy deleted the farlukas/bmm-reduce-fused-quant branch November 3, 2026 10:33
mengfei-jiang added a commit to lijinpei-amd/aiter that referenced this pull request Nov 16, 2026
… 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]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
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
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