Repository navigation
[FlyDSL] [gfx1250] Run a4w4 grouped MoE as a8w4 on gfx1250-strict (A0 has no wmma-f4-insts) - #8670
Conversation
… has no wmma-f4-insts) On MI450 A0 (gfx1250-strict) the strict target drops wmma-f4-insts (A0 errata). The fp4-activation branch of the grouped TDM GEMM always emits v_wmma_scale_f32_32x16x128_f4, so LLVM reports "requires target feature 'wmma-f4-insts'". FlyDSL does not fail the compile, and the kernel is built without its matmul, dispatched, and returns NaN. Every a4w4 MoE on A0 (e.g. DSV4-Flash) is affected. Refs #8527. Stop-gap until an A0-safe a4w4 kernel exists: - grouped_moe_gfx1250: on gfx1250-strict, run a4w4 as a8w4. Activations are quantized to fp8 and the GEMM uses the A0-legal 16x16x128 f8f6f4 scaled WMMA. Both formats use the same preshuffled mxfp4 weights and scales. Pre-quantized fp4 activations raise NotImplementedError. - mxfp4_preshuffle_gfx1250_tdm: build_gemm_a8w4_tdm_task raises when a_is_fp4 and the FlyDSL target is gfx1250-strict. No caller (grouped_gemm_mxfp4, mega_moe s1f_stage1) can then get the NaN kernel. Non-strict gfx1250 is unchanged. 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 |
grouped_moe_gfx1250 called get_gfx() in five places, all of them at call time: enabling grouped GEMM, keying the tuned-config lookup twice, and the two gfx1250 dispatch branches, including the a4w4-as-a8w4 fallback added in #8670 for the MI450 A0 errata. get_gfx() follows GPU_ARCHS and returns its last entry on a multi-target build, so it does not name the running GPU. Measured on an MI308X with GPU_ARCHS='gfx950;gfx1250-strict': live GPU gfx942 get_gfx() gfx1250-strict -> grouped GEMM on, strict fallback on get_gfx_runtime() gfx942 -> both off That fires the strict a4w4-as-a8w4 fallback on a GPU that has wmma-f4-insts, and the mirror case (an MI450 A0 whose build lists another arch last) skips the fallback the A0 errata needs, which is the NaN output #8670 fixes. Alias the import to get_gfx_runtime, as aiter/ops/gemm_op_a8w8.py and aiter/ops/gemm_op_a4w4.py already do, so all five call sites follow the live GPU. aiter/ops/rmsnorm.py already spells the same gfx1250 test with get_gfx_runtime(). No call site runs at import time or without a GPU, and get_gfx_runtime() keeps its AITER_AOT_REPLAY path for AOT processes. Tests: TestGroupedMoeArchSource in op_tests/test_gfx1250_strict_alias.py. Reverting the import alias fails test_dispatch_reads_the_runtime_arch. Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…250-strict (#9058) 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]>
Summary
Stop-gap for #8527. On MI450 A0 (
gfx1250-strict), the FlyDSL grouped MoE now runs a4w4 as a8w4 (fp8 activations, same mxfp4 weights). The fp4-activation TDM GEMM now refuses to build for gfx1250-strict instead of producing a kernel that outputs NaN.Motivation
gfx1250-stricttarget has nowmma-f4-insts(A0 errata).mxfp4_tdm_fp4_*) always emitsv_wmma_scale_f32_32x16x128_f4(mxfp4_preshuffle_gfx1250_tdm.pyL1505,WMMA_N = 32 if a_is_fp4at L315).requires target feature 'wmma-f4-insts', but FlyDSL does not fail the compile. The kernel is built without its matmul, dispatched, and the MoE output is NaN.wmma_scale_f32_16x16x128_f8f6f4(M=16), like Gluon_fp4_wmma_m(). It is requested from the kernel owner in [FlyDSL] [gfx1250-strict] grouped FP4 MoE (mxfp4_preshuffle_gfx1250_tdm) emits wmma_scale_f32_32x16x128_f4 on A0 — runtime JIT fails with "requires target feature 'wmma-f4-insts'" #8527, and this PR is meant to be replaced by it.Changes
aiter/ops/flydsl/grouped_moe_gfx1250.py(grouped_gemm_gfx1250_a8w4):q_dtype_abecomes fp8, and the CSV lookup uses the fp8 key.16x16x128 f8f6f4WMMA.NotImplementedErrorinstead of being re-quantized.aiter/ops/flydsl/kernels/mxfp4_preshuffle_gfx1250_tdm.py(build_gemm_a8w4_tdm_task):NotImplementedErrorwhena_is_fp4and the FlyDSL compile target (get_rocm_arch(), which AOT sets viaFLYDSL_GPU_ARCH) isgfx1250-*.grouped_gemm_mxfp4.py,mega_moe_gfx1250/s1f_stage1.py).Performance (if applicable)
On A0, fp8 activations move twice the activation bytes of fp4. That cost goes away once the A0-safe a4w4 kernel lands. Other archs are unchanged.
Testing
op_tests/flydsl_tests/test_flydsl_grouped_gemm.py(see below)gfx1250-strict) and on gfx1250 (non-strict)Documentation
The change is an internal dispatch fallback plus a build guard; both are explained in code comments.
Dependencies
Breaking Changes
None. Only gfx1250-strict behavior changes: a4w4 used to give NaN and now runs as a8w4. Pre-quantized fp4 activations on strict used to give NaN and now raise.
PR Self-Review
Reviewed revision
0f7682b
Behavior and intent
grouped_gemm_gfx1250_a8w4routes an a4w4 MoE to the a8w4 path.Validation and unverified scope
Command:
MI450 A0, native gfx1250-strict. Image
rocm/atom-dev:ub26-dcgpu-rk-10.3.0a20261117.bkc.20261117-pyt2.14.0-tri-main-a81d6911-atomsrc-gfx1250-b1120, HIP 7.18.26456, flydsl 0.5.3, 1 GPU.wmma-f4-instserrors,mxfp4_tdm_fp4_*dispatched, logits_diff NaN, FAILmxfp4_tdm_fp8_*+ fp8 quant dispatched, logits_diff 0 / 3.2e-5, PASSNotImplementedError; norequires target featurelinegfx1250 non-strict (ROCm 10.1, HIP 26315):
mxfp4_tdm_fp4_*), logits_diff 0 / 3.7e-6, identical to main. The fallback does not trigger.Lint: black and ruff are clean. The patch was validated on main
7c132b81and rebased onto7abfa2a8. That rebase only touched one Gluon util file, and both changed files are byte-identical to the validated ones.Unverified:
mega_moe s1f_stage1andgrouped_gemm_mxfp4callers; they are covered by the builder guard but were not run.aot/flydsl/moe.pystill skips strict fp4 rows, so the a8w4 fallback kernels are not precompiled. This is a follow-up.PR-specific question
The most important boundary is detecting strict. The fallback keys on
get_gfx(), the GPU_ARCHS-aware exact identity (gfx1250-strict;base_gfx_arch()folds it togfx1250). The builder guard keys on FlyDSL's actual compile target (get_rocm_arch()).gfx1250on A0 (old ROCr, orHSA_DISABLE_GFX12_STRICT=1), neither path triggers. Code then compiles for gfx1250 and runs the errata instruction, which is the pre-existing behavior and out of scope here.gfx1250-strict) and takes the fallback. Non-strict gfx1250 is byte-for-byte unchanged in kernels and numerics.Changed op tests
None.
Follow-ups (not in this PR)
🤖 Generated with Claude Code