Repository navigation
[FlyDSL] [Perf] MegaMoE stage1: fold the ready-order tile wait into the scheduler block - #6431
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
ROCm#6259 fixed a race on the compact ready-order path (a consumer could read per-tile metadata before the planner's store was visible) by making every compact work item run tid0 wait(tile_ready) + barrier + fence_system_acquire. On the ready-order path that is a second barrier + system acquire per work item, on top of the ones the scheduler block already does after popping the ready queue. Do the tile_ready wait in the scheduler block instead (tid0, right after reading the queued tile, before the existing barrier and system acquire), and keep the per-work-item wait only for the sequential path. The ordering guarantee is unchanged: every thread's system acquire still follows tid0 observing tile_ready for the tile it is about to read. DSv4-Pro EP8 a8w4, MTPR 8192, 392 experts / topk 7, skewed routing: 1024 tok/rank 1334.7 -> 1271.7 us (41630d0: 1269.4 us); 2x skew 64/256/1024 tok/rank +4.6/+5.8/+6.1% -> -1.3/+0.3/-0.6% vs 41630d0. Uniform routing unchanged; outputs identical. test_mega_moe_v2.py (v4_pro compact/fixed-slot/uneven ranks/burst 2000, kimi_k3_route incl. --force-fanout-boundary + burst 2000) passes. Co-authored-by: Duyi-Wang <[email protected]>
b63dfdc to
8a7db10
Compare
Motivation
#6259 fixed a race on the compact ready-order path of MegaMoE V2 Stage1 by making every compact work item run tid0
wait(tile_ready)+ barrier +fence_system_acquire. On the ready-order path the scheduler block already runs a barrier and a system acquire after popping the ready queue, so each work item now pays for them twice. Under skewed routing this costs 5-6%.Technical Details
tile_readyin the scheduler block, right after it reads the queued tile and before the existing barrier and system acquire.Ordering is the same as in #6259: every thread's system acquire still follows tid0 observing
tile_readyfor the tile it reads. A work batch never crosses an m-tile (N_TILES % WORK_BATCH == 0), so one wait per pop covers the batch.Test Plan
op_tests/multigpu_tests/test_mega_moe_v2.pyon MI355X, EP4 and EP8, main (6bf550b) vs this PR:v4_pro(at EP8 on fixed-slot with the default MTPR and on compact with MTPR 8192),kimi_k3_route(incl.--force-fanout-boundary), uneven ranks, burst 2000. Plus expert-skewed routing to exercise the ready-order path: therank-balanced-hotroute ofbench_mega_moe_v2.py, where each slot lands on its rank's expert 0 with probability 0.6 or 0.9 (hot share); bs 1-4096, accuracy checked at every bs.bench_mega_moe_v2.py --mega-only(rank-balanced-hot,hot-rank0,uniform)..github/scripts/aiter_test.sh).Test Result
All accuracy checks pass at EP4 and EP8 (relL2 0.050-0.059), on fixed-slot and on both compact orders; CUDA Graph replay is bit-exact, and bursts complete.
DSv4-Pro EP8, fused op time, skewed routing:
With 2x the skew, relative to 41630d0:
Uniform routing is unchanged and the outputs are identical.
EP8, skewed routing (
test_mega_moe_v2.py, 7168x3072, 392 experts, topk 7, MTPR 8192), main -> this PR, rank-mean time per call, mean of 2 rounds. Stage1 order is what every rank ran, read back from the workspace (max_expert_tiles * 4 >= num_m_tilesselects ready-order):EP8,
bench_mega_moe_v2.py --mega-only --hot-bias 0.6(392 experts, topk 7, MTPR 8192), main -> this PR, mean of 2 rounds:rank-balanced-hotrank-balanced-hotrank-balanced-hothot-rank0hot-rank0hot-rank0uniformuniformuniformAt EP8, wherever Stage1 runs the ready-order path this PR is 1.7-6.5% faster end to end (3.5-8.7% in Stage1); the sequential-path, rank-skewed (
hot-rank0) and uniform cases are within 0.4% end to end.EP4, skewed routing (7168x3072, 384 experts, topk 4, MTPR 8192), main -> this PR, rank-mean time per call, mean of 6 rounds (hot share 0.6) or 2 rounds (0.9), Stage1 order read back as above:
The sequential rows are noise: at bs 64 and 256, main's per-round times span 3.3% and 2.6%, and this PR's fall inside that range.
EP4, uniform routing (
v4_pro, topk 6, MTPR 8192), main -> this PR, mean of 3 rounds:Co-authored-by: @Duyi-Wang