Repository navigation
[FlyDSL] [gfx1250] Split 32x16x128 f4 WMMA into two 16x16x128 on gfx1250-strict - #9058
Conversation
…250-strict gfx1250-strict (MI450 A0 errata) has no wmma-f4-insts. The fp4-activation grouped TDM GEMM emits v_wmma_scale_f32_32x16x128_f4, which LLVM drops on that target after printing "requires target feature 'wmma-f4-insts'", leaving a kernel without the matmul (NaN output, #8527). When the FlyDSL target is gfx1250-strict, emit each 32x16x128 f4 WMMA as two v_wmma_scale_f32_16x16x128_f8f6f4 with FP4 operands, one per 16-row half of the weight operand and the accumulator, following the lowering proposed in llvm/llvm-project#246606. The weight scale VGPR is shared, with ROW0/ROW1 selecting each half. The activation scale select stays wm % 2; forcing ROW0 as the LLVM lowering does reads the wrong lanes for odd wm (rel_l2 6.4e-2 vs 2.7e-3 with per-token-varying scales on A0). This replaces the NotImplementedError guard from #8670. The plain gfx1250 target is unchanged (same 32x16x128 f4 instructions, bit-identical results). Co-Authored-By: Claude Opus 5.5 <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
Resolve the conflict in mxfp4_preshuffle_gfx1250_tdm.py: keep this branch's VGPR-partition / preshuffled-output setup and main's split_f4_wmma (gfx1250-strict, #9058); both sit in the same prologue and are independent.
Summary
On gfx1250-strict (MI450 A0), the FlyDSL grouped a4w4 MoE GEMM now emits each
v_wmma_scale_f32_32x16x128_f4as twov_wmma_scale_f32_16x16x128_f8f6f4with FP4 operands, so the fp4-activation kernel compiles and computes correctly on A0. Kernel side of #8527.Motivation
gfx1250-strict has no
wmma-f4-insts(A0 errata).mxfp4_preshuffle_gfx1250_tdm.pyalways emits the 32x16x128 f4 WMMA for fp4 activations. On a strict target, LLVM printsrequires target feature 'wmma-f4-insts', drops the matmul and still returns a kernel. On A0 that kernel outputs NaN (#8527: 80 such errors,logits_diff=nan).#8670 contained this two ways:
NotImplementedErrorin the kernel builder;grouped_moe_gfx1250.py.Neither runs fp4 activations on A0.
Changes
aiter/ops/flydsl/kernels/mxfp4_preshuffle_gfx1250_tdm.py:split_f4_wmmais set when the FlyDSL target isgfx1250-*(strict) and activations are fp4.fmtA=fmtB=FP4, following the lowering proposed in [AMDGPU] Lower unsupported 16x16x128 FP8 and 32x16x128 F4 WMMAs on gfx1250-strict llvm/llvm-project#246606:ROW0/ROW1selects each half;NotImplementedErrorguard from [FlyDSL] [gfx1250] Run a4w4 grouped MoE as a8w4 on gfx1250-strict (A0 has no wmma-f4-insts) #8670.wm % 2; the LLVM lowering forcesROW0.wmma_m_rep > 1, activation scales are loaded 32 rows per VGPR, so oddwmreads lanes 16:31.ROW0gives rel_l2 6.4e-2 instead of 2.7e-3 once per-token scales differ (see Validation). That still passes the test's 0.01 logits_diff gate.gfx1250target is unchanged.Not in this PR (follow-up):
grouped_moe_gfx1250.py;aot/flydsl/moe.pyandaot/flydsl/common.py(_STRICT_ERRATA_KERNEL_RE).On a box that reports
gfx1250-strict, the fallback still runs a8w4 until it is removed.Performance (if applicable)
Hardware: MI450 A0 (ASIC rev 0), 1 GPU.
Workload:
op_tests/flydsl_tests/test_flydsl_grouped_gemm.py --scenario kernel --data-format {a4w4,a8w4} --experts 256 --topk 6 --model-dim 4096 --inter-dim 512 --act silu, data/scale init uniform/auto. Kernel time in µs, gemm1 + gemm2, single run.How to read the table:
gfx1250, and the 32x16 f4 code object runs through the HSA B0-to-A0 translator (libhsa_hotswap_rocjitsu.so).Testing
Documentation
Internal codegen change; the comments at the call site describe it.
Dependencies
Breaking Changes
None. On gfx1250-strict, a direct fp4-activation build that used to raise
NotImplementedErrornow builds a correct kernel.PR Self-Review
Reviewed revision
66b7932
Behavior and intent
On a gfx1250-strict FlyDSL target, the fp4-activation TDM GEMM emits two
v_wmma_scale_f32_16x16x128_f8f6f4(FP4 x FP4) per formerv_wmma_scale_f32_32x16x128_f4. Before this change it either compiled to a matmul-less NaN kernel (before #8670) or raisedNotImplementedError(after #8670). Neither ran fp4 activations on A0.Other targets emit the same code as before.
Validation and unverified scope
MI450 A0, 1 GPU, aiter main
163947e79+ this commit, flydsl 0.5.3. This box's ROCm reportsgfx1250, so strict was forced:Dispatch reads the hardware arch (
gfx1250), so the a8w4 fallback does not trigger and the fp4 kernel itself is compiled for strict and run.requires target feature, logits_diff NaNNotImplementedErrormach 0x4eb): the K4096 / K512 fp4 kernels have 64 / 96v_wmma_scale_f32_16x16x128_f8f6f4withMATRIX_FMT_FP4. Each of the four A/B scale-select combinations appears 16 times in the K4096 kernel. That is 2x the 32 / 48 32x16 instructions it replaces.mach 0x449): still 32 / 48v_wmma_scale_f32_32x16x128_f4.ROW0gives 2.0748e-03 / rel_l2 6.44e-02.Unverified:
gfx1250-strict(ROCm 10.3 image).launch_gemm_a8w4_tdmcallers:grouped_gemm_mxfp4.pyandmega_moe_gfx1250/s1f_stage1.py. They share the code path but were not run separately.op_tests/.PR-specific question
Most important boundary: which instruction the strict target gets.
split_f4_wmmakeys on the FlyDSL compile target (get_rocm_arch().startswith("gfx1250-")), not the runtime arch, so it follows the code object that is actually built.requires target featureerrors, and the disassembly.Main failure mode: the activation scale select. Choosing the wrong lane half is silent and still passes the 0.01 gate. It is covered by the per-token-varying-scale comparison above:
wm % 2is bit-identical to native,ROW0is 24x worse in rel_l2.Changed op tests
None.
🤖 Generated with Claude Code