Skip to content

[Triton/Gluon] Unify afp8wfp8 GEMM kernels - #5862

Merged
vgokhale merged 7 commits into
mainfrom
alizaidy/gemm-afp8wfp8
Sep 26, 2026
Merged

vgokhale merged 7 commits into
mainfrom
alizaidy/gemm-afp8wfp8

Conversation

@azaidy

@azaidy azaidy commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Generalize gemm_afp8wfp8 to support compact E8M0 scales with activation groups of 32 or 128 and weight scale blocks of 1×32, 32×32, or 128×128.

This replaces the separate group32 kernel implementation with shared AFP8WFP8 execution paths, reducing duplicated kernel, dispatch, and tuning logic.

Implementation

  • Parameterize scale indexing and broadcasting by activation and weight scale-group sizes.
  • Support ordinary and packed-K execution, including fused split-K reduction, through configuration-based dispatch.
  • Keep separate configuration families for each scale layout and tune the gfx950 configurations.
  • Preserve the group32 entry point as a thin compatibility wrapper.
  • Remove the duplicate group32 kernels and obsolete configs.
  • Consolidate kernel tests and benchmarks into the AFP8WFP8 files, including an option to benchmark all 1,224 group32 PR shapes.

The existing preshuffle implementation remains available.

Performance

Measured on AMD Instinct MI355X / gfx950, using BF16 outputs and alternating baseline/shared-kernel CUDA graph timings.

Speedups are geometric means relative to the corresponding original implementation.

Path Cases Speedup Regressions
Group32 overall 1,224 1.0471× 1
Group32 ordinary 1,074 1.0547× 1
Group32 packed-K 150 0.9941× 0
Original AFP8 normal 64 1.1111× 0
Original AFP8 preshuffle 64 1.0003× 0

A regression is defined as:

shared latency > baseline latency × 1.05 + 0.5 µs

One group32 ordinary case exceeds this threshold:

M N K Baseline Shared Excess over threshold
64 16,384 1,280 4.805 µs 5.867 µs 0.322 µs

This regression reproduced in independent runs on two GPUs.

Validation

  • 1,224 group32 shapes and 128 original AFP8 cases passed numerical checks.
  • Group32 validation compares complete outputs against the preserved implementation and checks independent FP64 references—full for small shapes and sampled for large shapes.
  • Original AFP8 validation uses full dequantized FP32 references.
  • 346 correctness/interface tests passed; 14 architecture-specific tests skipped.
  • Performance coverage is limited to the listed shapes with BF16 outputs on gfx950.

@azaidy
azaidy requested review from a team and vgokhale September 25, 2026 20:17
@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
multigpu 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: 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 5862 --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 opt this PR out.

@github-actions github-actions Bot changed the title Unify afp8wfp8 GEMM kernels [Triton/Gluon] Unify afp8wfp8 GEMM kernels Sep 25, 2026

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.

Copilot review overview

🟡 Changes recommended

Resolve the configuration fallback and ownership issues, correct the architecture-aware benchmark import, and make tests use production config resolution.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Unifies AFP8WFP8 and group32 GEMM kernels, dispatch, tuning, tests, and benchmarks across supported architectures.

Changes:

  • Adds configurable activation and weight scale layouts.
  • Supports packed-K and fused split-K execution.
  • Converts group32 to a compatibility wrapper and removes duplicate implementations.
  • Consolidates tests and benchmarks.
File Summary
op_tests/​triton_tests/​gemm/​basic/​test_gemm_afp8wfp8.py Consolidated AFP8WFP8 and group32 tests.
op_tests/​triton_tests/​gemm/​basic/​test_gemm_a8w8_blockscale_group32.py Removed duplicate group32 tests.
op_tests/​op_benchmarks/​triton/​bench_gemm_afp8wfp8.py Added unified benchmarking and group32 sweeps.
op_tests/​op_benchmarks/​triton/​bench_gemm_a8w8_blockscale_group32.py Removed duplicate benchmark.
aiter/​ops/​triton/​gemm/​basic/​gemm_afp8wfp8.py Added shared dispatch and split-K handling.
aiter/​ops/​triton/​gemm/​basic/​gemm_a8w8_blockscale_group32.py Reduced group32 API to a compatibility wrapper.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8/​GEMM-AFP8WFP8-N=1280-K=8192.json Updated specialized tuning.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8/​DEFAULT.json Updated default tuning metadata.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8_a32_w32x32/​DEFAULT.json Added A32/W32x32 defaults.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8_a32_w1x32/​DEFAULT.json Added A32/W1x32 defaults.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8_a32_w128x128/​DEFAULT.json Added A32/W128x128 defaults.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8_a128_w32x32/​DEFAULT.json Added A128/W32x32 defaults.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp8wfp8_a128_w1x32/​DEFAULT.json Added A128/W1x32 defaults.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_a8w8_blockscale_group32/​GEMM-A8W8_BLOCKSCALE_GROUP32-N=5120-K=8192.json Removed obsolete tuning.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_a8w8_blockscale_group32/​GEMM-A8W8_BLOCKSCALE_GROUP32-N=5120-K=2048.json Removed obsolete tuning.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_a8w8_blockscale_group32/​GEMM-A8W8_BLOCKSCALE_GROUP32-N=4608-K=5120.json Removed obsolete tuning.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_a8w8_blockscale_group32/​DEFAULT.json Removed obsolete defaults.
aiter/​ops/​triton/​configs/​gfx942/​triton/​gemm/​gemm_afp8wfp8/​DEFAULT.json Updated gfx942 defaults.
aiter/​ops/​triton/​configs/​gfx942/​triton/​gemm/​gemm_afp8wfp8_a32_w32x32/​DEFAULT.json Added A32/W32x32 defaults.
aiter/​ops/​triton/​configs/​gfx942/​triton/​gemm/​gemm_afp8wfp8_a32_w1x32/​DEFAULT.json Added A32/W1x32 defaults.
aiter/​ops/​triton/​configs/​gfx942/​triton/​gemm/​gemm_afp8wfp8_a32_w128x128/​DEFAULT.json Added A32/W128x128 defaults.
aiter/​ops/​triton/​configs/​gfx942/​triton/​gemm/​gemm_afp8wfp8_a128_w32x32/​DEFAULT.json Added A128/W32x32 defaults.
aiter/​ops/​triton/​configs/​gfx942/​triton/​gemm/​gemm_afp8wfp8_a128_w1x32/​DEFAULT.json Added A128/W1x32 defaults.
aiter/​ops/​triton/​configs/​gfx1250/​triton/​gemm/​gemm_afp8wfp8/​DEFAULT.json Updated gfx1250 defaults.
aiter/​ops/​triton/​configs/​gfx1250/​triton/​gemm/​gemm_afp8wfp8_a32_w32x32/​DEFAULT.json Added A32/W32x32 defaults.
aiter/​ops/​triton/​configs/​gfx1250/​triton/​gemm/​gemm_afp8wfp8_a32_w1x32/​DEFAULT.json Added A32/W1x32 defaults.
aiter/​ops/​triton/​configs/​gfx1250/​triton/​gemm/​gemm_afp8wfp8_a32_w128x128/​DEFAULT.json Added A32/W128x128 defaults.
aiter/​ops/​triton/​configs/​gfx1250/​triton/​gemm/​gemm_afp8wfp8_a128_w32x32/​DEFAULT.json Added A128/W32x32 defaults.
aiter/​ops/​triton/​configs/​gfx1250/​triton/​gemm/​gemm_afp8wfp8_a128_w1x32/​DEFAULT.json Added A128/W1x32 defaults.
aiter/​ops/​triton/​_triton_kernels/​gemm/​basic/​gemm_afp8wfp8.py Generalized ordinary and packed kernels.
aiter/​ops/​triton/​_triton_kernels/​gemm/​basic/​gemm_a8w8_blockscale_group32.py Removed duplicate kernel implementation.

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

@vgokhale vgokhale 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.

Can you remove fp16 and fp32 as output dtype in the UTs?

@zufayu
zufayu requested review from a team and vgokhale September 26, 2026 00:18
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.

3 participants