Repository navigation
[FlyDSL] [gfx1250] MegaMoE: stage-1 fused kernel for DSV4.1 Flash EP2/EP4 - #5899
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
5534a53 to
2ed5925
Compare
There was a problem hiding this comment.
🟡 Changes recommended
An undefined decorator blocks compact-plan imports, and padding skips can deadlock M-cluster synchronization.
2 open issues
What changed in this PR
This PR reduces gfx1250 MegaMoE decode latency by overlapping the next layer’s compact plan with dispatch and sizing plan launches to the current route count.
Changes:
- Adds decode-specific stream coordination and adaptive compact-plan launch geometry.
- Allows smaller GEMM2 tiles with padding guards.
- Adds geometry-based VMM reservation sizing and CPU-only arena-bound tests.
| File | Description |
|---|---|
op_tests/multigpu_tests/test_mega_moe_vmm_bytes.py |
Tests VMM bounds across dispatch formats and configurations. |
aiter/ops/flydsl/kernels/mxfp4_preshuffle_gfx1250_tdm.py |
Adds alignment-aware padding guards to grouped GEMM. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/mega_moe.py |
Coordinates plan overlap, launch sizing, and VMM reservations. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/compact_plan.py |
Adds multi-block planning and generation-tagged histogram exchange. |
aiter/ops/flydsl/grouped_moe_gfx1250.py |
Enables narrower GEMM2 tiles and passes compact alignment. |
aiter/ops/flydsl/grouped_gemm_mxfp4.py |
Forwards alignment to the GEMM launcher. |
Review effort: Balanced
6e4a540 to
cab1e22
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Padding workgroups can cause cluster-barrier deadlocks and out-of-bounds index reads, while compact gather fails with existing incompatible tuned configurations.
6 open issues
Select gather-compatible wave ownership for compact GEMM1 tuning · New Guard index loads for inactive padded workgroups · New Compact GEMM1 forwards an incompatible A-gather prologue setting Prevent cluster_sync deadlock when tiles are narrower than m_align Add regression coverage for compact A-gather and tile padding Use runtime GPU architecture for compact arena tile selection
Review effort: Balanced
95944bb to
644bf9e
Compare
The probe recorded its result per exact recv bound. An eager prefill step carries a new token sum almost every time, so its first layer probed and ran dispatch + GEMM1 on every step. GEMM1 picks its CSV row by _get_padded_m(recv_bound), so the probe holds for the whole bucket.
…ompiledFunction Calling the @flyc.jit launcher directly rebuilt its cache key and checked its globals on every launch, about 110 us/layer of host time that left eager prefill host-bound at tpr 2048. Launch it through _run_compiled like the other grouped GEMM launches; its tensor arguments are layout-dynamic, so the dtype and rank of each pick the artifact.
|
Thanks for d84ec33. Keying the probe by the CSV bucket is what lets eager prefill steps run S1F in serving; we confirmed that end to end on DSV4.1-Flash DEP4 c1024 (MI455X). A follow-up suggestion: the probe result can be computed up front instead of observed.
|
#7600 routes the stage-1 launch through _run_compiled. Keep _run's specialization key so layout-dynamic tensor arguments still pick the cached CompiledFunction by dtype and rank. Co-authored-by: Cursor <[email protected]>
The stage-1 verdict waited for one eager probe per (align_m, CSV bucket) step, so a bucket first seen inside a graph capture recorded dispatch + GEMM1 for good, and every first eager step of a bucket ran the fallback. _compact_gemm_tiles resolves (tile_m, tile_m2, m_warp2) the way grouped_gemm_gfx1250_a8w4 does (CSV row, then AITER_TDM_* overrides) and _CompactStep carries GEMM1's clamped tile_m and GEMM2's quant WMMA repeat, so eligible() / step_will_run() decide from the step alone. The GEMM1 hook keeps rejecting a launch whose tile disagrees. The first eager S1F launch precompiles the launcher of every step bound that can fuse.
#7726 adds gemm_stage and replaces IGLP_PARAMS with HYPER_PARAMS. Keep that, and keep this branch's m_align guard that forces cluster_m to 1 so a padding skip cannot deadlock the M-cluster barrier. Co-authored-by: Cursor <[email protected]>
…age-1 (#7919) * Optimize FlyDSL grouped MoE kernels * improve test * support a preshuffle * add csv support * update quant and shuffle * update * update mega-moe * update * update csv * update * simplify code * fix accuracy drop * update csv * fix format * fix(flydsl): align A-preshuffle guards and AOT coverage * improve cs test * fix ruff * Tune conc16384 benchmark with WPT2 and cluster sync disabled * Add standalone conc16384 GEMM1 performance reproducer Rename the benchmark to reproduce.sh and pin the validated zero-input configuration. Include standalone activation/quantization dependencies and tests so the script does not rely on stashed implementation changes. Preserve unrelated work in stash. GPU timing was not rerun for this commit. * Tune grouped MoE LDS scheduling and prologue initialization Use normal WMMA order with operand B reuse and precomputed payload LDS bases. Initialize accumulators before the prologue TDM wait and select WPT1 for the conc16384 tuned configuration. Include the local benchmark scripts and the reproducer iteration update. * Pin FlyDSL WMMA scale registers to disjoint low VGPR slots * update * update * update * remove useless tests * add script * update script * update script and wheel * update * update1 * update * Fix LDS helper shadowing after GEMM task refactor * Simplify gfx1250 prefill scheduling and add reproducible MoE benchmarks * Keep local GPU benchmark scripts and microtests out of the branch * Restore LDS layout controls and decouple interleaving from scheduling * Fix strict VGPR pinning with FlyDSL 0.5.0 Resolve sched_vgpr through rocdl.experimental on FlyDSL 0.5.0 while retaining compatibility with the older public API. Keep strict placement enabled for prefill kernels. Validated DSV4 Pro conc16384 with three const/random runs at 32 iterations. Both GEMMs have zero scratch instructions and accumulator placement at physical v512-v1023; median const GEMM1/GEMM2 is 465.77/322.86 us. * update for ds flash v4.1 * Tune DSV4.1 Flash 8192 prefill configuration * update for release * add csv * update csv * update csv for dsr1 fused expert * Move DSR1 grouped MoE configs into a dedicated CSV * remove useless csv * update csv * [FlyDSL] Simplify prefill WMMA emission and barriers * Tune DSR1 65-expert (64 routed + 1 shared, topk 9) grouped MoE rows for 1-1024 tokens The single 16x256x256 four-wave as-prologue row left gemm1 at ~16 TB/s for decode-sized batches (three workgroup rounds, extra round at 4 tokens, and a 64-row tile that doubled weight reads at 1024 tokens). Re-swept tiles and knobs for this shape on gfx1250: narrower gemm1 tiles (tile_n 64/128) with deeper buffering for 1-32 tokens, as-prologue kept only at 64 and 256 tokens where it measures faster, and 128x256 tiles at 1024 tokens. gemm1+gemm2 vs the previous rows (test_flydsl_grouped_gemm, constant + uniform init): 1 tok 1.81x, 2 1.11x, 4 1.25x, 8-256 1.12-1.16x, 512 1.08x, 1024 1.38x; >= 2048 unchanged. * Simplify FlyDSL KSL0 fence configuration and kernel symbols * Merge PR #5899 (zxe/mega_stage1_compact_overlap) for local benchmarking Co-authored-by: Cursor <[email protected]> * mega: adapt S1F/GEMM2 to the MoE prefill path, tune DSV4.1 Flash EP4 buckets - Pin VGPRs only for the 2x2 256^3 tile; S1F's 1x4 256 variant overflowed the map. - S1F GEMM1 warp grid per tile_m (2x2 at 256, AITER_MEGA_S1F_WARPS override) and pass the GEMM kernel_attrs to the S1F launch. - DSV4.1 Flash E96 rows: GEMM2 next_stage_prefetch + lds_soa_load_interleave at 8192+, add the missing 131072 bucket (tpr 32768: 3783 -> 3258 us/layer). Co-authored-by: Cursor <[email protected]> * [FlyDSL] [gfx1250] Pack GEMM1 A inside mega stage-1 for large prefill buckets The stage-1 producer writes the M16 packed A layout, and the 256-row GEMM1 turns on a_preshuffle, lds_soa and next_stage_prefetch together with the grouped-MoE prefill schedule. This runs only when the recv bound is at least 65536, which for EP4 top-6 is tpr 16384 and 32768. Payload and scale use separate buffer resources so the masked store sentinel stays out of range. DSV4.1 Flash EP4, 8-layer graph: 1654 vs 1704 us/layer at tpr 16384 (-2.9%) and 3111 vs 3258 at tpr 32768 (-4.5%). Smaller buckets stay on the 128-tile path. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: yadaish <[email protected]> Co-authored-by: JiaoliangYu <[email protected]> Co-authored-by: lalala-sh <[email protected]> Co-authored-by: hyi <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: XingerZhu <[email protected]>


Two goals at the start: overlap the compact plan with as much of the layer as the dataflow allows, and dedup a token's routes to the same peer so the payload moves once. Where this head ended up: Flash EP2 / EP4 run the S1F kernel at every width, the compact plan runs in stream order, and the dedup is measured and left out (see below).
The compact path that predates #6564 already does both. The plan launch follows this step's route count, and a local scatter expands one payload per (token, peer) into expert order before a contiguous GEMM1. #6564 fuses dispatch and GEMM1 into one stage-1 (S1F) kernel, and a scatter between them would split the overlap that kernel exists for. This head therefore runs Flash EP2 and EP4 on the S1F kernel at every width, and drops the scatter there.
Stage-1 fused kernel on Flash EP2 / EP4
tile_m 16. Decode (tpr 8 / 64) tunes GEMM1 to 16 rows, which S1F did not support, so those steps used dispatch + scatter + GEMM1.
s1f_flag_mmakes a tile belowFLAG_M(64) its own flag tile. The compact plan and the producer pieces then use 16-row tiles. The 16-row variant uses 4 pipeline buffers and 2 CTAs/CU; three CTAs do not fit LDS (112 KB each, even with 3 buffers). The small-tile GEMM body (post-compute issue) now calls the S1Fdrain_starthook and uses the raw-drain fence.defer_c_waitstays off below 33 rows, because it needs the mid-loop fence.tile_m 32. EP2 tpr 256 / 512 tune GEMM1 to 32 rows, which had no S1F variant, so those steps also fell back to dispatch + scatter + GEMM1. The 32-row variant is its own flag tile and reuses the 16-row layout (4 buffers, 2 CTAs/CU). At tpr 512 the S1F kernel takes 160.6 µs, against 169.8 µs for dispatch + scatter + GEMM1.
Recv cap.
_S1F_MAX_RECV = 4096made tpr 4096 / 8192 fall back to dispatch + scatter + GEMM1.s1f_max_recv(world, topk)adds a per-shape default and anAITER_S1F_MAX_RECVoverride (0 = no cap). Flash on EP2 and EP4 defaults to no cap, both at top-6 and at top-7 (the shared expert fused into MegaMoE,--fused_shared_experts 1). Other shapes keep 4096. Past 4096 tokens this precompiles a few more plan widths, 7 instead of 4 per tile at 8192 tokens/rank. On EP2 at tpr 8192 the S1F kernel takes 411 µs, while dispatch (46) + scatter (27) + GEMM1 (404) took 477 µs.Plan in stream order. The compact plan used to launch on its own stream. That side stream no longer exists: the plan runs on the caller's stream, right before the step's dispatch (or S1F), and
next_topk_ids/prefetch_compact_planonly enqueue it earlier on that stream.forwardalready droppednext_topk_idsthere, and the side stream waited on the caller's stream and was waited on by it: a fork / join with no overlap.next_topk_ids), the plan used to overlap the previous expert GEMM, and decode started it right after routing. It now sits on the critical path there. Flash EP2 / EP4 never take that path.On Flash EP2 the change is within noise: 108.6 / 343.2 / 888.4 µs/layer at tpr 8 / 1024 / 8192, against 108.5 / 343.8 / 893.1 before.
Dedup inside the S1F producer: measured, not done. The S1F producer still ships one wire row per expert row (about 3 per token per peer on Flash EP2). An upper-bound test kept the per-rank load unchanged and cut remote rows from 3 to 1 per token. It routed each token to 5 local experts and 1 remote expert, against 3 + 3. The S1F kernel time did not move:
The S1F kernel is GEMM-bound and already hides the wire traffic. A staging + in-kernel expand would save at most about 1.5 µs/layer, and it would add a local copy to a persistent kernel that hangs if its CTAs are not all resident. The receiver-side expand is left out.
Grouped GEMM rows for the fused shared expert on EP4
With
--fused_shared_experts 1, each EP4 rank holds 96 routed experts plus one shared-expert replica, so the grouped GEMM lookup asks forexpert=97.dsv41_tuned_grouped_fmoe.csvonly hadexpert=96rows, so every bucket missed (grouped CSV config miss ... experts=97), and S1F and GEMM2 ran on the caller default (tile_m 64). The shared expert's 97th slot receives every local token, and each routed expert gets about 70 to 80 rows at tpr 1152. A 64-row tile splits most experts into two M tiles, so each expert's weights are read twice.2f81baa reuses the
expert=96fp4 rows forexpert=97, except for the 4096 bucket: there, the 96-expert row (tile 96) ran slower than the default tile 64 at tpr 1024 (319.6 against 291.8 µs/layer), so that bucket keeps the default. This is a config change only; no kernel or lookup code changes.The kernel breakdown and the sweep in this section ran on a local branch carrying this PR's S1F changes, with
AITER_S1F_MAX_RECV=6144 AITER_S1F_BLOCK_RUNS=4,2,8,8 AITER_S1F_ANY_TILE=1 AITER_TDM_COMPACT_ROUTE_UPTO=1024 AITER_TDM_COMPACT_ROUTE_SPEC=384,16. The table under Performance is this head with the PR command. At tpr 1152 (the token bucket is 8192, the row is tile 128x256x256 / 128x256x256, 3 / 3 buffers), the profile table goes from S1F 143.1 + GEMM2 91.0 µs to S1F 121.8 + GEMM2 77.1 µs. Plan and combine stay the same. A sweep around that row found nothing better. It covered tile_m 64 / 96 / 192 / 256, tile_n 512, tile_k 128, 2 / 4 buffers, cluster_m / cluster_n 2, next_stage_prefetch, a_preshuffle, tdm_b_th and waves_per_tensor_tdm. tile_m 96 and 192 (with tile_m2 128) exited with an error.persistent_workers2=1ran 18844 µs/layer.What this head does
_DECODE_PLAN_OVERLAP_TOKENSremoved).dsv41_tuned_grouped_fmoe.csv, as above.CompiledFunction, so every eligible step runs S1F (eager or captured, first time or not) without the per-launch JIT host cost.Performance
Hardware: 2x gfx1250. Setup:
bench_mega_moe.pywithAITER_MEGA_PLAN_PREFETCH=0, stage1_fused true, stage2_fused true, dispatch wire fp4, quant a4w4_mxfp4, hidden 5120, intermediate 2304, 384 experts, topk 6, 192 experts/rank, fused_shared_experts 0, 8 layers, warmup 3, iters 8. Values are median per-layer µs. main is 6d8c8e9 with the same command. The previous head is 891de7f. tpr 256 / 512 used iters 50 and alternate main / this head runs, averaged over two rounds, since the gap is close to run-to-run noise; the previous head was not run there.Flash EP4 (4x gfx1250, 96 experts/rank, same command with
--nproc_per_node=4). The previous head kept the 4096 recv cap here, so 4096 / 8192 ran dispatch + scatter + GEMM1, and the scatter (14 / 24 µs) cost more than the dedup saved, with about 2.5 peers per token:Flash with the shared expert fused (
--fused_shared_experts 1, so MegaMoE runs topk 7 over 385 experts). Before this head's last commit, (2, 7) / (4, 7) were not in the cap table, so tpr 4096 / 8192 fell back to dispatch + GEMM1. "4096 cap" below is that fallback, reproduced withAITER_S1F_MAX_RECV=4096(the log printsS1F falls back to dispatch + GEMM1); "this head" is the default:EP2 "this head" at 8192 ran with
AITER_S1F_MAX_RECV=0, which is the same path the default now takes; at 4096 the default gives 693.5 and the env override 695.5. At tpr 8 top-7 already ran S1F (EP4 110.6 µs/layer).EP4 kernels at 8192 tokens/rank: S1F 370.7 µs, against dispatch 130.7 + scatter 23.8 + GEMM1 363.4 on the previous head. S1F producers stay at 64. 32 and 96 run 918.4 and 1008.7 µs/layer at 8192.
Grouped GEMM rows for 97 experts/rank (2f81baa), EP4 (4x gfx1250),
--fused_shared_experts 1, same command with--iters 20. "before" is 94cb8f5. Each tpr alternates before / after for two rounds; the value is the mean of the two. The first before round at tpr 256 / 512 ran 245.0 / 246.5 and is left out as a cold start. At tpr 8192 both sides ran four rounds and the value is the median: one after round ran 1168.0 against 994.4 / 996.3 / 1003.2 for the others.tpr 1024 lands on the 4096 bucket, which keeps the default tile, so it does not move. tpr 1152 to 2048 land on the 8192 bucket.
Prefill with a recv cap. The serving recipe below sets
AITER_S1F_MAX_RECV=6144. ATOM bounds a step's receive count by the token sum over all DP ranks, and a c1024 prefill step carries about 14.5K tokens, so every prefill step ran dispatch + GEMM1 instead of S1F. This head has no cap for this shape. EP4 (4x gfx1250),--fused_shared_experts 1 --routing zipf --zipf_s 0.2 --iters 20, on the local integration branch with this head's S1F defaults set by env (AITER_S1F_BLOCK_RUNS=4,2,2,8 AITER_S1F_SHARED_FIRST=1 AITER_PLAN_SHAGG=1) and the recipe's other S1F settings. "6144 cap" setsAITER_S1F_MAX_RECV=6144; the bench bounds receives by tpr x 4, so every row logsS1F falls back to dispatch + GEMM1. "no cap" sets 0, which is what this head does by default. Each tpr alternates the two for two rounds; the value is the mean, and the two rounds agree within 3.2%:The end-to-end runs below kept the 6144 cap, so their prefill steps did not run S1F. Without the cap, the first layer of an eager prefill step still ran dispatch + GEMM1. The GEMM1 probe was keyed by the exact recv bound, and a prefill step's token sum is new almost every time. ATOM, like the bench, shares one MegaMoE op across layers, so the other layers reused that layer's probe. d84ec33 keys the probe by the CSV token bucket,
_get_padded_m(recv_bound), which is what GEMM1 looks its row up by.6eacb1c drops the probe. Even keyed by bucket, the first step of each bucket ran dispatch + GEMM1, and a bucket first seen inside a graph capture recorded that fallback into the graph for good.
_compact_gemm_tilesnow resolves(tile_m, tile_m2, m_warp2)the waygrouped_gemm_gfx1250_a8w4does (CSV row for_get_padded_m(recv_bound), then theAITER_TDM_*overrides)._CompactStepcarries GEMM1's clamped tile_m and GEMM2's quant WMMA repeat, soeligible()andstep_will_run()decide from the step alone. The GEMM1 hook still rejects a launch whose tile disagrees. The first eager S1F launch precompiles the launcher of every step bound that can fuse, so a capture does not JIT-compile it. Steps over the recv cap and configs S1F does not support still run dispatch + GEMM1.With graph capture as the first forward (no eager warmup), tpr 2048:
The S1F kernel also cost host time. Its
@flyc.jitlauncher was called directly, so every launch rebuilt the FlyDSL cache key and checked the captured globals. Under cProfile that was about 370 of the 416 µs the S1F GEMM1 hook took per layer step. The non-S1F GEMM launches go throughtensor_shim._run_compiled, which calls the cachedCompiledFunction. c782790 launches the S1F kernel the same way. Its tensor arguments are layout-dynamic, so the cache is keyed by their dtype and rank.Eager passes over 8 layers, each pass with a different recv bound inside one bucket (tpr x 4 minus 0 to 255), EP4 top-7, zipf 0.2, 24 passes, median µs/layer. S1F off is the mean of two or three runs. The output with each bound matches the unbounded run bit for bit with S1F on:
With the exact-bound key, 169 of the 192 layer steps at tpr 2048 ran S1F; with the bucket key all 192 did. Before the cached launch, the S1F path enqueued more host work per layer than its GPU work at tpr 2048 (376 µs in the graph), so that eager pass was host-bound and ran 2.8% slower than S1F off. The graph timing does not move with the cached launch (tpr 2048: 374.3 against 376.4 µs/layer). A serving forward also enqueues attention between MoE layers; how much of the host time shows there was not measured.
End to end, DSV4.1 Flash on 4x gfx1250, ATOM EP4 + DP attention, FP4 index cache, FP8 KV cache, dspark speculative decoding (5 draft tokens), MLPerf agentic dataset, endpoints client at concurrency 1024 with a 600 s issue window. Both runs used the same recipe and environment (
AITER_MEGA_S1F=1 AITER_MEGA_PLAN_PREFETCH=0 AITER_S1F_MAX_RECV=6144 AITER_S1F_BLOCK_RUNS=4,2,8,8 AITER_S1F_ANY_TILE=1 AITER_TDM_COMPACT_ROUTE_UPTO=1024 AITER_TDM_COMPACT_ROUTE_SPEC=384,16), on the same machine, one after the other. They ran on a local integration branch carrying this PR's commits (43abbc846), against the same branch plus the 13 rows from 2f81baa (9427f02fa). Both commits add the same rows. One run each:The before run reproduced a run from the previous day, on the same commit and environment, within 0.02% (14285.20).
The serving step timer, averaged over each run's issue window, shows where the change lands:
The MoE kernels are about a third of a decode forward (40 layers x about 270 µs at tpr 1152, against 32.5 ms). Each decode step also spends about 5.4 ms outside the forward. The 13% MoE kernel gain in the bench therefore shows up as -2.4% on the decode forward, -1.2% on the step period and +1.37% on throughput. The decode forward gained less than the bench's MoE share would predict (about -4.4%), and that gap is not resolved here. The bench uses uniform routing, and serving decode steps at or below 1024 tokens/rank land on the 4096 bucket, which this commit leaves on the default tile.
EP2 kernel table (
--profile_table 1, avg µs per call):No step runs a separate ep_dispatch_tdm or moe_scatter_copy_compact kernel.
Testing
--fused_shared_experts 1): EP2 tpr 8192 (0.0422), EP4 tpr 8 (0.0427) and tpr 8192 (0.0422). With the 97-expert rows (2f81baa), EP4 top-7: tpr 1152 (0.0423) and tpr 8192 (0.0422), the same diffs as 94cb8f5. EP4 top-7, zipf 0.2,AITER_S1F_MAX_RECV=0: tpr 2048 / 4096 / 6144 (0.0423 / 0.0422 / 0.0422). With the bucket-keyed probe (d84ec33), and again with the cached S1F launch (c782790), EP4 top-7, zipf 0.2: tpr 8 (0.0432) and tpr 2048 (0.0423).Documentation
AITER_S1F_MAX_RECVis a tuning override.Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
6eacb1c (GEMM1 tile resolved statically, probe removed) on top of the main merge d9da0c7, run with flydsl 0.5.0 and the bench's default 61 layers, zipf 0.2,
--fused_shared_experts 1. EP4 graph at tpr 8 / 2048 / 6144: 125.0 / 370.1 / 781.6 µs/layer. The eager varying-bound passes ran S1F on every step (1464/1464) at EP4 tpr 2048 and EP2 tpr 256 / 2048 / 6144. EP2 graph ran at tpr 8 / 1152 / 2048 / 6144, and graph capture as the first forward at EP2 tpr 8 / 2048 and EP4 tpr 2048. All passed MEGA-CHECK without a fallback. A check over experts 48 / 96 / 97 / 192 / 384, both wires and buckets 1 to 131072 found_compact_gemm_tilesmatching GEMM1's CSV resolution.test_grouped_ep_fused_lookup.py,ruff checkandblack --checkpassed. Later EP4 reruns hit a memory access fault on d9da0c7, 6eacb1c and S1F off alike while another container held GPU2, so those were not counted.c782790 (S1F kernel launched through its cached CompiledFunction) on top of d84ec33. c782790 ran the eager varying-bound passes at tpr 2048 / 6144 against S1F off, and 2-layer accuracy at tpr 8 / 2048 (0.0432 / 0.0423).
ruff checkandblack --checkpassed on s1f_ctl.py.d84ec33 (GEMM1 probe keyed by the CSV token bucket) on top of the main merge 7fc819a. d84ec33 ran the eager varying-bound passes above at tpr 2048 / 6144 against S1F off, at tpr 2048 against the exact-bound key, and 2-layer accuracy at tpr 8 / 2048 (0.0432 / 0.0423). After 7fc819a it reran the varying-bound pass and the 2-layer accuracy at tpr 2048, and the accuracy at tpr 8. The earlier main merge a955bda ran tpr 8 / 1152 / 2048 against dc5ef4e (107.2 / 294.8 / 371.3 against 107.3 / 291.7 / 373.6 µs/layer, two rounds each), plus 2-layer accuracy at tpr 8. tpr 6144 aborted on both sides of that comparison while another container held GPU memory, and was not rerun.
dc5ef4e (S1F shared expert first, wave-aggregated plan tally) on top of 2f81baa. The prefill recv-cap table ran EP4
--fused_shared_experts 1with zipf 0.2 at tpr 2048 / 3072 / 4096 / 6144,AITER_S1F_MAX_RECV=6144against 0, with dc5ef4e's S1F defaults set by env on the local integration branch, plus 2-layer accuracy at tpr 2048 / 4096 / 6144 with no cap.2f81baa (grouped GEMM rows for 97 experts/rank) on top of 94cb8f5. 2f81baa ran EP4
--fused_shared_experts 1at tpr 256 / 512 / 1024 / 1152 / 1536 / 2048 / 4096 / 8192 against 94cb8f5, plus 2-layer accuracy at tpr 1152 / 8192, as listed above. It only adds CSV rows forexpert=97, so top-6 and EP2 (which look up 96 / 192 / 193 experts) were not rerun. It also ran a DSV4.1 Flash c1024 end-to-end A/B on a local integration branch, one run each, as listed under Performance.5f87064 (no recv cap for Flash top-7 on EP2 / EP4) on top of 8cf0c8c. 5f87064 ran EP2 tpr 4096 / 8192 and EP4 tpr 8 / 4096 / 8192 with
--fused_shared_experts 1, againstAITER_S1F_MAX_RECV=4096, plus 2-layer accuracy as listed under Testing. Top-6 was not rerun for 5f87064: it does not change the top-6 path.8cf0c8c (compact plan in stream order) on top of 1380871. 8cf0c8c reran on EP2 at tpr 8 / 1024 / 8192 for performance, with 2-layer accuracy at tpr 8 / 8192, plus 2-layer accuracy with
AITER_MEGA_PLAN_PREFETCH=1at tpr 8 (S1F) and at tpr 8 / 1024 withAITER_S1F_MAX_RECV=1forcing the non-S1F compact dispatch. A trace of the latter shows every kernel on one stream. EP4 was not rerun for 8cf0c8c.1380871, on top of the main merge 45676c8. 1380871 adds the tile_m 32 variant on top of 1fc42c3; its EP2 numbers above were measured on 1fc42c3 plus that change. The merge 45676c8 brings in #5815 and #7323, which touch no MegaMoE file (quant_utils.py only gains new helpers), and was not re-benchmarked. Before it, on the main merge e16149f, EP4 reran at tpr 8 / 4096 / 8192 (106.9 / 538.2 / 895.6 µs/layer), and 2-layer accuracy passed again at tpr 8 and 8192. EP4 was not rerun with the tile 32 variant; Flash EP4 at tpr 256 / 512 may now pick it.
Behavior and intent
A compact plan consumes the current layer topk_ids. On Flash EP2 and EP4 (top-6, or top-7 with the shared expert fused), every step now runs the S1F kernel: tile 16 for decode, and tiles 64 / 128 up to 8192 tokens/rank with no recv cap. Other shapes keep the 4096 cap, and their S1F tile set changes only by the added 16-row variant. The shared GEMM body change touches only the post-compute (tile_m <= 32 or <= 2 buffers) branch when S1F hooks are passed (
raw_drainis S1F-only). Without hooks it is unchanged.Validation and unverified scope
Command, from outside the repo:
AITER_MEGA_PLAN_PREFETCH=0 HIP_VISIBLE_DEVICES=0,1 torchrun --standalone --nproc_per_node=2 op_tests/multigpu_tests/bench_mega_moe.py -q a4w4_mxfp4 -e 384 -k 6 -hd 5120 -id 2304 --fused_shared_experts 0 --layers 8 --stage2_fused true --dispatch_wire fp4 --stage1_fused true --profile_table 0 --acc_verify 0 --warmup 3 --iters 8 -tpr 8192EP4 used
HIP_VISIBLE_DEVICES=0,1,2,3 --nproc_per_node=4. The same command was also run at-tpr 8,64,256,512,1024and4096, with--profile_table 1for the kernel table, with--layers 2 --acc_verify 1for accuracy, and with--fused_shared_experts 1for the top-7 table.ruff checkandblack --checkpassed on the edited files.Unverified:
--stage1_fused false: the local mori lacks feat(ep/v2): plans report the arena and staging sizes they need (info + describe) mori#844, so that run stops at arena setup, independent of this PRChanged op tests
None. This revision does not change any file under op_tests/.