Repository navigation
[Config] [Perf] Retune DSV4 EP8 a8w4 fused-MoE rows for M 2-8 and 1024-8192 on gfx950 - #6928
Conversation
… gfx950 Replace seven rows of the 7168/3072, 48-expert, top-k 6 table (DeepSeek-V4 with 8-way expert parallelism, fp8 activations x MXFP4 weights). Each was timed as the whole aiter.fused_moe call on one EP rank, with routing drawn over all 384 experts and the 336 non-local ones masked, CUDA-graph replays for M <= 8192. M before after speedup 2 45.6 us 39.0 us 1.17x 4 49.1 us 37.9 us 1.30x 8 126.2 us 56.8 us 2.22x 1024 410.5 us 292.6 us 1.40x 2048 496.8 us 332.4 us 1.49x 4096 581.6 us 459.2 us 1.27x 8192 875.9 us 661.8 us 1.32x At M=8 the old stage-1 kernel (t32x128x256_w3_gui_xcd4) is slower than the untuned heuristic (58.0 us). Output error is unchanged (0.047-0.049 relative L2 against an fp32 reference, same as the rows replaced). us is the whole-call time; us1/us2/err1/err2 are left empty because the rows did not come from the per-stage tuner. Signed-off-by: Jon Belof <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
The gfx942 / 304 CU rows for model_dim 6144, inter_dim 256, 257 experts, top-9 -
the TP8 decode shape - select `fmoe_bf16_blockscaleFp8_g1u1_vs_silu_1tg_32x128`
and its `ps` variant at M = 1 and 2, then switch to
`fmoe_bf16_a16_blockscaleFp8_g1u1_vs_silu_1tg_16x128_flat_pf3` from M = 4 on.
The flat kernel is faster at M = 1 and 2 as well. Point those two rows at it.
One MI325X, stock aiter, same image and process throughout; the only variable is
this file. Weights rotate over 8 independent expert sets so a call does not
reread what the previous call left in cache. Median of 5 rounds:
M 32x128 (current) flat_pf3 (this change) speedup
1 99.16 us 60.30 us 1.64x
2 99.65 us 60.97 us 1.63x
4 64.39 us 64.53 us 1.00x
8 80.92 us 81.39 us 0.99x
16 69.87 us 71.46 us 0.98x
32 .. 2048 unchanged within 1%
Only M = 1 and 2 are touched: `get_padded_M()` rounds M up to the next power of
two, so 3-4 take the M = 4 row and 5-8 take M = 8. Everything from M = 4 up is
an untouched control, and the arms agree there to within 1%, which also bounds
the measurement noise.
Output against the current row, relative L2: 1.5e-2 at M = 1 and 1.7e-2 at M = 2.
The same comparison at M = 4 and 8, where both tables are identical and the same
kernel runs, gives 6.8e-3, so most of that is the kernel's own run-to-run
variation rather than the change.
`us` is the whole `fused_moe` call, so `us1`, `us2`, `err1` and `err2` are left
empty and `tflops` and `bw` are 0, following ROCm#6928.
Signed-off-by: Pham Binh <[email protected]>
…hem in test_moe_ep A caller behind an expert-parallel dispatch passes fused_moe an expert mask, and the launches it masks compile for the mask's length: the gfx950 masked stage-2 reduction and route-guarded GEMM2, the gfx1250 g2l route and bf16 gather-reduce. No tuned row records that length, so the AOT build never compiled them and EP serving JIT-compiled them on the request path. aiter/aot/flydsl/moe_ep_profiles.csv lists EP callers as what one rank passes fused_moe: local experts, routing columns, expert-mask length, largest M. moe.py replays each profile with the mask at both ends of every get_padded_M bucket up to that M (bisecting between them as for rows), with and without num_local_tokens, against the tuned tables serving reads, so a profile needs no tuned row. --ep-profile selects profile tables; without --csv and --ep-profile both defaults are replayed, and run_aot replays both. The default table covers gfx950 Kimi-K3 EP8, DeepSeek-V4-Pro EP8 (EPLB r0, r32, r64) and EP16, GLM-5.3-Flash EP8/EP4/EP2, and gfx1250 Kimi-K3 EP8/EP16 and DeepSeek-V4-Pro EP4, from the EP rows tuned in #5804, #6928, #6435, op_tests/test_moe_ep.py -t aot_ep_profiles, first in the defaults, runs every profile of the GPU's arch through the EP fused_moe call in FlyDSL run-only mode and requires logits_diff < 0.01. The MXFP4 cases now pin quant_dtype_a instead of setting env switches, accept SiTUv2, and compare against a stage-wise reference that quantizes a4w4 activations as the kernels do. Co-authored-by: Cursor <[email protected]>
The gfx942 / 304 CU rows for model_dim 6144, inter_dim 256, 257 experts, top-9 -
the TP8 decode shape - select `fmoe_bf16_blockscaleFp8_g1u1_vs_silu_1tg_32x128`
and its `ps` variant at M = 1 and 2, then switch to
`fmoe_bf16_a16_blockscaleFp8_g1u1_vs_silu_1tg_16x128_flat_pf3` from M = 4 on.
The flat kernel is faster at M = 1 and 2 as well. Point those two rows at it.
One MI325X, stock aiter, same image and process throughout; the only variable is
this file. Weights rotate over 8 independent expert sets so a call does not
reread what the previous call left in cache. Median of 5 rounds:
M 32x128 (current) flat_pf3 (this change) speedup
1 99.16 us 60.30 us 1.64x
2 99.65 us 60.97 us 1.63x
4 64.39 us 64.53 us 1.00x
8 80.92 us 81.39 us 0.99x
16 69.87 us 71.46 us 0.98x
32 .. 2048 unchanged within 1%
Only M = 1 and 2 are touched: `get_padded_M()` rounds M up to the next power of
two, so 3-4 take the M = 4 row and 5-8 take M = 8. Everything from M = 4 up is
an untouched control, and the arms agree there to within 1%, which also bounds
the measurement noise.
Output against the current row, relative L2: 1.5e-2 at M = 1 and 1.7e-2 at M = 2.
The same comparison at M = 4 and 8, where both tables are identical and the same
kernel runs, gives 6.8e-3, so most of that is the kernel's own run-to-run
variation rather than the change.
`us` is the whole `fused_moe` call, so `us1`, `us2`, `err1` and `err2` are left
empty and `tflops` and `bw` are 0, following ROCm#6928.
Signed-off-by: Pham Binh <[email protected]>
Summary
Seven rows of
dsv4_fp8fp4_tuned_fmoe.csvfor DeepSeek-V4 with 8-way expert parallelism (7168 / 3072,48 local experts, top-k 6, fp8 activations × MXFP4 weights) are replaced with faster kernel pairs. The
aiter.fused_moecall gets 1.17-2.22x faster at those M. At M = 8 the current stage-1 kernel is 2.2xslower than the untuned heuristic.
Motivation
These rows are hit on current main: since #5734 the runtime key for DSV4 EP8 is top-k 6, which is how the
table keys them. In an EP8 decode or prefill step every rank calls this shape once per MoE layer.
..._t32x128x256_w4_gui_fp8/layout_..._t32x128x256_reduce_nt_sbm32..._t32x64x256_w3_bnt0_gui_fp8/layout_..._t32x128x256_atomic_nt_sbm32..._t32x128x256_w4_gui_fp8/layout_..._t32x256x256_reduce_nt_sbm32..._t32x64x256_w3_bnt0_gui_fp8/layout_..._t32x128x256_atomic_nt_sbm32..._t32x128x256_w3_gui_xcd4/layout_..._t32x128x256_reduce_nt_sbm32..._t32x128x256_w3_gui_fp8/layout_..._t32x128x256_atomic_nt_sbm32..._t128x256x256_gui_fp8/layout_..._t128x256x128_reduce_nt_sbm128, bm 128..._t32x128x256_w3_gui_fp8/layout_..._t32x128x256_atomic_nt_sbm32, bm 32..._t128x256x256_w3_gui_fp8/layout_..._t128x256x256_reduce_sbm128, bm 128..._t64x256x256_w3_gui_fp8/layout_..._t64x256x256_atomic_nt_sbm64, bm 64..._t128x256x256_gui_fp8/layout_..._t128x256x256_reduce_sbm128..._t128x256x256_w3_gui_fp8/..._t64x256x256_atomic_sbm128..._t128x256x256_w3_bnt0_gui_fp8/layout_..._t128x256x256_reduce_sbm128..._t128x256x256_w2_bnt0_gui_fp8/..._t64x256x256_atomic_sbm128Kernel names are abbreviated: stage 1 is
flydsl_moe1_afp8_wfp4_bf16_…, stage 2flydsl_moe2_[layout_]afp8_wfp4_bf16_….At M = 8 the untuned heuristic takes 58.0 µs, so the current row's
t32x128x256_w3_gui_xcd4stage 1 is theregression.
Changes
aiter/configs/model_configs/dsv4_fp8fp4_tuned_fmoe.csv: seven rows of the 7168 / 3072 / E48 / top-k 6shape (M = 2, 4, 8, 1024, 2048, 4096, 8192) get new
kernelName1,kernelName2,block_mandus. Norows are added or removed.
usis the wholefused_moecall (below), sous1,us2,err1anderr2are empty andtflopsandbware 0, as in the existing M = 32768 and 131072 rows. Stage-2sbmmatchesblock_min every row.How the rows were found and measured
One MI355X runs one EP rank's call the way the serving engine makes it:
aiter.fused_moewithgate_mode="interleave",swiglu_limit=10,quant_dtype_a=fp8,expert_maskwith this rank's 48 of 384experts, and top-k 6 routing drawn uniformly over all 384 experts, so about one route in eight is local.
Three layers with different weights are called in turn, so weights are not reused from cache between
calls. Time per call is the median of CUDA-graph replays for M ≤ 8192 (eager above 1.5 ms). Candidates
were every kernel pair in AITER's own rows for this shape plus pairs from our serving tables, injected into
cfg_2stagesunder the exact lookup key, at every M. A candidate counts only if its output error is no worsethan the heuristic's. The rows proposed were then timed again alone, three repetitions each (the numbers
above).
This differs from the per-stage tuner, which times each stage with every route on a local expert (eight
times the per-rank work of uniform EP8 routing). That probably explains why it picked these rows.
Output error, relative L2 against an fp32 reference of the dequantized weights: 0.047-0.049 for both the
current and the new rows at every M (0 at M = 1).
Rows not changed
alternative as slower under its production load, so the row from [Config] [Perf] Tune DSV4 EP48 top-k 6 prefill shapes #5459 stays.
Testing
With this patch applied to 00feaa3 and nothing injected, AITER picks the new row at all seven M. In the same
run, the current rows injected back give:
At every other M AITER's choice is unchanged, within 2.5% of the current row.
python3 -m unittest op_tests.tuning_tests.test_csv_validation: 19 tests pass, including the stage-2 sortblock check and the duplicate-key check.
git diff --checkis clean.Performance benchmarks run
Unit tests added/updated: not applicable (table change)
Tested on MI250X / MI300X: not applicable, gfx950 rows
MI355X (gfx950, 256 CUs), torch 2.12.0+rocm7.14.0, FlyDSL 0.4.0, AITER 00feaa3.
Dependencies
Breaking Changes
None. Only the kernel choice for these seven buckets changes.