Repository navigation
[FlyDSL] [gfx1250][MoE] Row-major A1 e8m0 scale store for decode MoE (drop scattered preshuffle) - #6357
Conversation
…ttered preshuffle) The decode MoE A1 scale-preshuffle (moe_fused_quant_preshuffle_routeks, the prequantized full-row copy path) scattered each row's e8m0 scales into the GEMM's 16-row-interleaved layout at a stride of wmma_rep*16 dwords -- one dword per cache line. gemm1 already supports reading A-scales row-major (row_major_ascale, used by the compact-dispatch path), so on the mori dispatch path we now write each grouped row's scales contiguously (row*K/32 + g) and let gemm1 do the 16-row interleave on its LDS->register read instead. This removes the uncoalesced scale scatter from the decode preshuffle: moe_fused_quant_preshuffle_routeks_fd7168_r8 ... 28.3 us -> 8.35 us/call with FC1/FC2 unchanged (bit-exact GEMM output, max abs diff 0). Gated to the decode kernel (tile_m>=256) and token_num>=1024: the prefill tile (tile_m=64, m_warp=1) and tiny decode batches regress because gemm1's row-major A-scale ds_read is a strided 2-way-bank-conflict read that costs more than the preshuffle saves once M is large / the GEMM is compute-bound. Prefill keeps the original interleaved store untouched. Env kill-switch AITER_TDM_ROW_MAJOR_A1_SCALE=0; floor override AITER_TDM_ROW_MAJOR_A1_MIN_TOKENS. No new kernel launches: reuses the existing row_major_ascale gemm1 argument and the existing prequant full-row copy kernel (new _rm module-name variant so the interleaved and row-major builds do not share a JIT binary). Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
Black wants the env-var membership test on one line, and ruff SIM102 rejects the nested row_major_scale guard. Those two Checks failures were also failing check-signal and the Aiter Test Gate. Co-authored-by: Cursor <[email protected]>
On the gfx1250 EP MoE decode path (mori FP4 dispatch), the A1 scale-preshuffle
kernel (
moe_fused_quant_preshuffle_routeks, the prequantized full-row copybranch) scattered each grouped row's e8m0 scales into gemm1's 16-row-interleaved
layout at a stride of
wmma_rep*16dwords — i.e. one dword per cache line.gemm1already supports reading A-scales row-major (row_major_ascale,used today by the compact-dispatch path). This PR makes the mori-dispatch decode
path write each grouped row's scales contiguously (
row*(K/32) + g) and letsgemm1do the 16-row interleave on its LDS→register read instead, removing theuncoalesced scale scatter.
Gating (no other kernels impacted)
Row-major is enabled only for the decode kernel:
_prequantized and not _compact and not _fuse_ep_route_quant and ep_psum_params is None and tile_m >= 256 and token_num >= 1024.The prefill tile (
tile_m=64, m_warp=1) and tiny decode batches regress —gemm1's row-major A-scaleds_readis a strided read with a 2-way LDS bankconflict that costs more than the preshuffle saves once M is large / the GEMM is
compute-bound. Those cases keep the original interleaved store untouched
(verified in the server trace: decode preshuffle becomes
..._r8_..._rm,prefill stays
..._r4_..., same binary).AITER_TDM_ROW_MAJOR_A1_SCALE=0AITER_TDM_ROW_MAJOR_A1_MIN_TOKENS(default 1024)row_major_ascalegemm1 argand the existing prequant full-row copy kernel (new
_rmmodule-name variantso interleaved and row-major builds don't share a JIT binary).
Microbenchmark (4× MI455X / gfx1250, exact production geometry)
bench_mega_moe.py -q a4w4_mxfp4 -tpr 1536 -hd 7168 -id 2048 -e 260 -k 9 --shared_experts 0 --dispatch_backend mori --stage1_fused 0 --dispatch_wire fp4 --combine fused --combine_quant none, 4-layer A/B (AITER_TDM_ROW_MAJOR_A1_SCALE0 vs 1):Isolated gemm1 output is bit-exact between interleaved and row-major scales
(max abs diff 0).
Prefill tile check (
tile_m=64, 4096 tokens): row-major preshuffle 73→17.7 µsbut gemm1 356→420 µs (+18%), net +9 µs/layer → gated off, confirming the
tile_m>=256gate.Profile (serving, 1k4k ISL=1024/OSL=4096 conc=6144, MLPerf-aligned flags)
DSR1 EP4 DP-attn,
max_num_seqs=1536, steady-state decode (bs≈1473–1536),dp0 torch-profiler trace, per-call GPU time:
≈20 µs/layer × 58 MoE layers ≈ ~1.16 ms saved per decode step. Prefill
t64/r4preshuffle unchanged (gate off).Accuracy (MLPerf DSR1 offline accuracy harness, 4388 samples, patch on, 2×)