Repository navigation
[ASM] [HIP] Optimize gfx950 MXFP6 GEMMs for Ideogram DiT shapes - #7462
Conversation
Add tuned rows for M in {10240, 25600, 33280} with (N, K) in
{(4608, 4608), (12288, 4608), (4608, 12288)}. None of these shapes had a
tuned row, so dispatch used the default kernel.
Paired gain-guard speedups over the default kernel:
- A6W6: +2.2% to +4.7%; all 9 shapes switch kernels.
- A6W4: +4.1% to +9.3%; 8 of 9 shapes switch, 10240x4608x4608 keeps the
default.
Add 13 exact-shape A6W6/A6W4 kernels for the Ideogram DiT GEMMs
(M in {10240, 25600, 33280}, (N, K) in {(4608, 4608), (12288, 4608),
(4608, 12288)}) and retune those shapes. The kernels bake in the
physical shape, run a static K loop and use an XCD-aware grouped
raster; the A6W6 kernels also use MBLK=84, and two of them 16-byte
output stores. Shapes without a faster specialization keep their tuned
generic kernel. All kernels match the default kernel bit for bit.
Call-count-weighted DiT GEMM speedup over current main
on MI355X: A6W6 +4.3% to +5.9%, A6W4 +9.7% to +11.3%.
…ames f6gemm_dmabig_kernel_func and its swz0, grp16, grp64 and allk variants were the only gfx950 MXFP GEMM kernels whose names did not follow the _ZN5aiter<len><name>E convention, and an Ideogram tuned row selects the swz0 variant. Rebuild them from the same generator source under the mangled names, rename the code objects to <name>.co, and update the manifest, the default and fallback kernel names, the tuned rows and the tests. Instructions and kernel descriptors are byte-identical to the previous code objects. The A6W6 manifest test now checks the name and code-object name of every row. It only checked rows with exact_M/N/K set, so these five were never checked.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
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 |
There was a problem hiding this comment.
🔵 Needs a closer look
The new gfx950 kernels alter production dispatch, but GPU execution is unavailable and no head-matched report was supplied to validate numerical parity and paired base/head latency.
No open issues 🎉
What changed in this PR
Optimizes gfx950 MXFP6 GEMM dispatch for nine Ideogram DiT shapes, extending AITER’s existing A6W6 and A6W4 support with shape-specialized kernels and tuned selections.
Changes:
- Registers 13 specialized kernels and adds nine tuned configurations per family.
- Renames five existing A6W6 kernels and updates default, fallback, and tuned references.
- Updates test expectations for the expanded manifests and extends naming checks to every A6W6 manifest row.
| File | Description |
|---|---|
op_tests/tuning_tests/test_a6w6_tuning.py |
Updates kernel counts and checks naming across all manifest rows. |
op_tests/test_mxfp_exact_shape_dispatch.py |
Expands expected specialized-kernel counts. |
op_tests/test_mixed_mxfp_manifests.py |
Updates the expected A6W4 specialized-kernel count. |
op_tests/test_gemm_a6w6.py |
Uses renamed A6W6 kernels in existing tests. |
hsa/gfx950/f6gemm/f6gemm_bf16_per1x32Fp6.csv |
Registers five specializations and renames five existing entries. |
hsa/gfx950/f6f4gemm/f6f4gemm_bf16_per1x32Fp6Fp4.csv |
Registers eight A6W4 specializations. |
csrc/py_itfs_cu/asm_gemm_a6w6.cu |
Updates the native default kernel name. |
aiter/ops/gemm_op_a6w6.py |
Updates Python default and fallback kernel names. |
aiter/configs/a6w6_blockscale_tuned_gemm.csv |
Adds nine tuned selections and updates renamed references. |
aiter/configs/a6w4_asm_tuned_gemm.csv |
Adds nine tuned selections for Ideogram shapes. |
Review effort: Balanced
* [Config] Tune gfx950 MXFP6 A6W6 and A6W4 GEMMs for Ideogram DiT shapes
Add tuned rows for M in {10240, 25600, 33280} with (N, K) in
{(4608, 4608), (12288, 4608), (4608, 12288)}. None of these shapes had a
tuned row, so dispatch used the default kernel.
Paired gain-guard speedups over the default kernel:
- A6W6: +2.2% to +4.7%; all 9 shapes switch kernels.
- A6W4: +4.1% to +9.3%; 8 of 9 shapes switch, 10240x4608x4608 keeps the
default.
* [ASM] Add shape-specialized gfx950 MXFP6 GEMMs for Ideogram DiT shapes
Add 13 exact-shape A6W6/A6W4 kernels for the Ideogram DiT GEMMs
(M in {10240, 25600, 33280}, (N, K) in {(4608, 4608), (12288, 4608),
(4608, 12288)}) and retune those shapes. The kernels bake in the
physical shape, run a static K loop and use an XCD-aware grouped
raster; the A6W6 kernels also use MBLK=84, and two of them 16-byte
output stores. Shapes without a faster specialization keep their tuned
generic kernel. All kernels match the default kernel bit for bit.
Call-count-weighted DiT GEMM speedup over current main
on MI355X: A6W6 +4.3% to +5.9%, A6W4 +9.7% to +11.3%.
* [ASM] Rename the gfx950 A6W6 DMABIG kernels from #4859 to _ZN5aiter names
f6gemm_dmabig_kernel_func and its swz0, grp16, grp64 and allk variants were
the only gfx950 MXFP GEMM kernels whose names did not follow the
_ZN5aiter<len><name>E convention, and an Ideogram tuned row selects the swz0
variant. Rebuild them from the same generator source under the mangled
names, rename the code objects to <name>.co, and update the manifest, the
default and fallback kernel names, the tuned rows and the tests.
Instructions and kernel descriptors are byte-identical to the previous code
objects.
The A6W6 manifest test now checks the name and code-object name of every
row. It only checked rows with exact_M/N/K set, so these five were never
checked.
Summary
Add 13 shape-specialized gfx950 MXFP6 GEMM kernels (5 A6W6, 8 A6W4) and tuned configs for the 9 Ideogram DiT GEMM shapes: M in {10240, 25600, 33280} tokens per GPU, (N, K) in {(4608, 4608), (12288, 4608), (4608, 12288)}. Call-count-weighted DiT GEMM time improves by 4.3-5.9% for A6W6 and 9.7-11.3% for A6W4 over current main.
It also renames the five A6W6 kernels added in #4859 to the
_ZN5aiter<len><name>Enaming convention. Their code is unchanged.Motivation
None of these shapes had tuned rows, so dispatch used the default kernels:
f6gemm_dmabig_kernel_funcfor A6W6, and_ZN5aiter39f6f4gemm_bf16_per1x32Fp6Fp4_m32_s3_a4_tE(K=4608) or_ZN5aiter39f6f4gemm_bf16_per1x32Fp6Fp4_m32_s3_a5_tE(K=12288) for A6W4.f6gemm_dmabig_kernel_funcand its four variants were the only gfx950 MXFP GEMM kernels whose names did not follow the convention, and one of the new tuned rows selects theswz0variant.Changes
hsa/gfx950/f6gemm,hsa/gfx950/f6f4gemm: 13 new code objects and their manifest rows.aiter/configs/a6w6_blockscale_tuned_gemm.csv,aiter/configs/a6w4_asm_tuned_gemm.csv: tuned rows for the 9 shapes per family, produced bygemm_a6w6_tune.pyandgemm_a6w4_tune.pywith the new kernels as candidates. All other rows are unchanged apart from the rename below._ZN5aiter44f6gemm_bf16_per1x32Fp6_dmabig_m82_g64_dscaleE_ZN5aiter34f6gemm_bf16_per1x32Fp6_dmabig_swz0E_ZN5aiter44f6gemm_bf16_per1x32Fp6_dmabig_m82_g16_dscaleE_ZN5aiter44f6gemm_bf16_per1x32Fp6_dmabig_m82_all_dscaleE_ZN5aiter44f6f4gemm_bf16_per1x32Fp6Fp4_dmabig_m82_s0_ntEop_tests/test_mixed_mxfp_manifests.py,op_tests/test_mxfp_exact_shape_dispatch.py,op_tests/tuning_tests/test_a6w6_tuning.py: expected manifest row counts updated for the new kernels.hsa/gfx950/f6gemm: the code objects are rebuilt from the same source under the new symbols and renamed to<name>.co, and their manifest rows are updated. Instructions and kernel descriptors are byte-identical to the previous code objects.aiter/ops/gemm_op_a6w6.py,csrc/py_itfs_cu/asm_gemm_a6w6.cu: default and fallback kernel names.aiter/configs/a6w6_blockscale_tuned_gemm.csv: the 11 existing rows that select these kernels.op_tests/test_gemm_a6w6.py,op_tests/tuning_tests/test_a6w6_tuning.py: the new names, and the A6W6 manifest naming check now covers every row.f6gemm_dmabig_kernel_func_ZN5aiter29f6gemm_bf16_per1x32Fp6_dmabigEf6gemm_dmabig_swz0_kernel_func_ZN5aiter34f6gemm_bf16_per1x32Fp6_dmabig_swz0Ef6gemm_dmabig_grp16_kernel_func_ZN5aiter35f6gemm_bf16_per1x32Fp6_dmabig_grp16Ef6gemm_dmabig_grp64_kernel_func_ZN5aiter35f6gemm_bf16_per1x32Fp6_dmabig_grp64Ef6gemm_dmabig_allk_kernel_func_ZN5aiter34f6gemm_bf16_per1x32Fp6_dmabig_allkEThe kernels are generated by the DMABIG PyISA generators with new shape-specialization options:
Kernel suffixes:
x<G>XCD raster with group G,m84MBLK=84 BAR=16,w16-byte stores,ttemporal output stores,s0natural raster. Every new kernel produces output bit-identical to the default kernel.Performance
Before is current main's dispatch and After is this PR's dispatch. Change is the speedup of the DiT GEMM kernel time (main time / PR time - 1), weighted by Ideogram call counts per request: 1088 square, 544 FFN-up and 272 FFN-down GEMMs across both GPUs.
Per-shape speedup over main:
Method: GEMM kernel time with pre-quantized operands (activation quantization is not included), four rotating operand sets, median of 10 x 200 launches, each kernel paired against the main kernel in the same job.
The
us,tflopsandbwcolumns of the new tuned rows come from the tuning node, which ran below nominal clocks. Dispatch only useskernelName.Testing
The kernels are gfx950-only; everything was tested on MI355X (see "Validation and unverified scope").
Documentation
AITER does not document individual MXFP6 GEMM kernels.
Dependencies
Breaking Changes
The five A6W6 kernels from #4859 are renamed (see the table under Changes). Code that passes an old name as
kernelName, or lists one in its own tuned CSV, must use the new name. An old name now fails at launch withnot find kernel.PR Self-Review
Reviewed revision
392346f
Behavior and intent
For the 9 Ideogram DiT shapes,
gemm_a6w6andgemm_a6w4now dispatch to the 13 new kernels or, for the other 5 shape/family pairs, to existing kernels selected by new tuned rows, instead of the default kernels. Dispatch for every other shape is unchanged.The five #4859 A6W6 kernels keep their code and change only their names. The only Python and C++ changes are the default and fallback kernel names.
Validation and unverified scope
All on MI355X (gfx950):
pytest op_tests/test_gemm_a6w6.py op_tests/tuning_tests/test_a6w6_tuning.py op_tests/tuning_tests/test_csv_validation.py op_tests/test_mixed_mxfp_manifests.py: 46 passed, plus 48 subtests.pytest op_tests/test_mxfp_exact_shape_dispatch.py -k a6w6: 32 passed. Every non-Wan A6W6 kernel withexact_M/N/Kset, including the 5 new ones, is bit-identical to the renamed default kernel.pytest op_tests/test_mxfp_exact_shape_dispatch.py -k "10240x or 25600x or 33280x": 13 passed; every new kernel is bit-identical to the default kernel.gemm_a6w6andgemm_a6w4with the committed tuned CSVs for all 18 shape/family pairs. The expected kernel is selected and output is bit-identical to the default kernel.gemm_a6w6_tune.pyandgemm_a6w4_tune.pyon the 9 shapes with--all. Every selected kernel passed the gain guard against the default kernel..textand.rodata(kernel descriptor) bytes of the five renamed code objects are identical to the previous code objects, and their metadata differs only in the kernel name. An old name fails at launch withnot find kernel.Unverified:
test_mxfp_exact_shape_dispatch.pyfor the existing Flux kernels, which this PR does not change.PR-specific question
Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
hsa/gfx950/, and the new tuned rows are keyed bygfx950andcu_num=256, so other targets and CU counts never select them.mxfp6_c0c1_256_padk2,mxfp6_mxfp4_c0_256_padk2), and the launchers check the layout and reject any output other than bf16.exact_M/N/K, and the launcher rejects any other physical shape with anAITER_CHECK; the kernels also exit without writing if launched with a different M, N or K.test_mxfp_exact_shape_dispatch.pyruns every new kernel on its shape and requires output bit-identical to the default kernel. The five renamed kernels keep their code, kernel descriptors and manifest bounds, so only their names change.Changed op tests
op_tests/test_mixed_mxfp_manifests.py: the expected number of A6W4 manifest rows withexact_M/N/Kset goes from 25 to 33 for the 8 new rows. This test checks manifest and code-object consistency: mangled names, code objects present, and tuned kernels listed in the manifest.op_tests/test_mxfp_exact_shape_dispatch.py: the expected number of non-Wan manifest rows withexact_M/N/Kset goes to 32 for A6W6 (from 27) and 30 for A6W4 (from 22). The test runs each of those kernels on its shape and requires output bit-identical to the default kernel, so it now covers the 13 new kernels.op_tests/tuning_tests/test_a6w6_tuning.py: the expected number of A6W6 manifest rows withexact_M/N/Kset goes from 30 to 35. The_ZN5aiter<len><name>Eandco_namechecks now run on every A6W6 manifest row instead of only rows withexact_M/N/Kset; before, the five [ASM] [HIP] [CI] Mxfp6 gemms #4859 kernels were outside the check. Thegrp16lookup uses the new name.op_tests/test_gemm_a6w6.py: the five kernels are referenced by their new names. What the tests check is unchanged.