Repository navigation
perf(fused): MoE stage1 gemm tile-loop changes behind --tile-opt (driven by mori-harness) - #1069
Draft
kawhil-amd wants to merge 1 commit into
Draft
kawhil-amd wants to merge 1 commit into
kawhil-amd wants to merge 1 commit into
Conversation
… (driven by mori-harness) The gated ready-first GEMM1 of example 13 gets an opt-in set of tile-loop changes, same results (every checked call == aiter after stage2): - hoist_prologue: the next tile's ready-queue read, rowmap words, A k-step 0 and A scales are issued inside the current tile (tile_hoist.py: aiter's do_tile cut into phases, same MFMA order) - kpipe 1 / a_dbuf 1: A k-step through registers (no LDS-DMA alias wait), A operand double-buffered - xcd_order / xcd_steal 2: per-XCD work lists so an expert slice stays in one L2, steal at the end - fin_off: opaque final-step A parity, so LLVM does not hoist + spill 32 ds_read addresses - sbm 64: kunroll 2 (two-step K-loop body, no loop-carried B copies) - sbm 128: sa_pack (A scales one ds_read_b128 per k-step), epi_remat (no epilogue lane-constant spills) V4.1-Flash EP8, same process, 20 interleaved graph rounds: -3.9% (bs 512), -10.7% (1024), -13.2% (2048), -12.3% (4096), -12.3% (8192), faster in 20/20 rounds at each. Found with the mori-harness loop: a loop-nest performance model ranks levers and prices costs by single removal, the cco-fusion agent implements, ISA-checks and A/B-tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
GPU CI for Lanes follow the changed files. Adding |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Example 13 (mega-MoE stage1: SDMA dispatch + gated GEMM1) gets a new opt-in switch,
--tile-opt(with--ready-first). It changes only the GEMM1 tile loop. The output is unchanged: every checked call equals aiter after stage2.V4.1-Flash EP8 end to end, measured in one process (upstream ready-first vs
--tile-opt, 20 interleaved graph rounds): -3.9% at bs 512, -10.7% at 1024, -13.2% at 2048, -12.3% at 4096 and -12.3% at 8192.--tile-optwas faster in 20/20 rounds at every batch size.The changes were found with the mori-harness self-driven optimisation loop. A loop-nest performance model of the kernel (the
kernel-roofline-modelskill) finds the critical path, ranks the levers and registers a prediction before each run. It prices each cost by removing that cost alone (a probe build). The cco-fusion agent builds each change, reads the ISA, and A/B-tests the change on the GPU. The loop stopped when the model reported that the MFMA pipe binds. At that point the bandwidth ceilings (B from L2, A from LDS) were measured below the MFMA time, and the remaining items were structural (2 waves per SIMD), numerics changes, or under 2%.Changes
All the changes are in
examples/cco/python/13_flydsl_mega_moe_stage1_sdma/. With--tile-optoff, the kernel is the same as before. Each change is a keyword ofcompile_gemm1_sdma;--tile-optturns on the set that pays at the shape'ssort_block_m.hoist_prologuekpipe=1ds_write, notbuffer_load ... lds. LLVM's waitcnt pass made each step's first Ads_readwait for the outstanding LDS DMA, because it cannot prove the two A buffers disjoint.a_dbuf=1ds_readpair is issued before group g's MFMAs, fenced withsched_barrier.xcd_order,xcd_steal=2fin_offdo_tilehas the same spill.kunroll=2vmcnt(0)at the loop head.sa_packds_read_b128, not 16ds_read_u8with 8 seriallgkmcnt(0).epi_remat=1vmcntwaits.New file
tile_hoist.py: aiter's GEMM1do_tile(aiter 849f711d3) cut into prologue /tile_main/ epilogue. The MFMAs, their order and the arithmetic are unchanged.sdma_dispatch.py: the scheduler wave optionally appends published work items to the 8 XCD lists.run_stage1.py:--tile-opt.How each change was found (model vs agent):
hoistrewrite of the loop-carried tile edge.nosaprobe priced the A-scale chain at 6.9 us/tile at sbm 128. This falsified the model's earlier assumption that single K-loop overheads are hidden.Results
8x MI355X, V4.1-Flash, EP8,
--network flash --ready-first --stress 3, same process: upstream vs--tile-opt, 20 interleaved rounds x 30 CUDA-graph replays, median.--tile-optWhere the gain comes from at bs 4096, from incremental end-to-end A/Bs: fin-off ~61%, sa-pack ~21% (-19.8 us), a-dbuf ~8%, epi-remat ~8%, the sbm-64-era switches ~2%. At bs 2048, hoist + kpipe + xcd-order + xcd-steal alone give -47.5 us (-9.9%).
Correctness
--stress 3) equals aiter's output after stage2, on all 8 ranks, for both arms at every batch size above. The stage1 bytes themselves are not a gate: the layout is in arrival order, and the padding rows differ between runs of the upstream kernel too.--tile-opt) is identical to the measured build at bs 2048 (sbm 64) and bs 4096 (sbm 128), all 8 rank kernels (kernel names aside), and both pass--stress 3.Test plan
run_stage1.py --network flash --ready-first --tile-opt --stress 3at bs 2048 (sbm 64) and 4096 (sbm 128): all calls == aiter after stage2🤖 Generated with Claude Code