Repository navigation
[FlyDSL] [gfx1250] Optimize grouped MoE prefill and DSR1 EP tuning - #7726
Merged
Merged
Conversation
# Conflicts: # aiter/configs/tuned_grouped_fmoe.csv
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.
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.
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
…or 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.
Boss2002n
pushed a commit
that referenced
this pull request
Nov 13, 2026
#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]>
3 of 10 tasks
vpietila-amd
pushed a commit
that referenced
this pull request
Nov 13, 2026
…7726) * Optimize FlyDSL grouped MoE kernels --------- Co-authored-by: JiaoliangYu <[email protected]> Co-authored-by: lalala-sh <[email protected]>
JiaoliangYu
added a commit
to JiaoliangYu/aiter
that referenced
this pull request
Nov 16, 2026
…d=1 row Replace the ep_fused=1 token=32768 row from ROCm#7726 (hand-set 128x256x256, w1x4, no measurement) with a measured one: 256x256x256 w2x2, 4/4 buffers, cluster_n 4, waves 2/1, prefetch, LDS SoA interleave, A preshuffle. 4-GPU EP4 MegaMoE layer (12288 tokens/rank): 2361 -> 1994.5 us, bit-identical.
amirumoAMD
added a commit
that referenced
this pull request
Nov 16, 2026
Resolve conflicts with main's grouped-MoE rework (#7726), the tiled TDM atom interface (#7655), the FlyDSL 0.5 bump (#7600) and the shared-expert byte model in the grouped GEMM test. - tdm kernel: keep main's HYPER_PARAMS scheduler, tiled TDM loads and k_step WMMA ordering; reapply ds_first_n (now overriding ds_first_group), mma_prio, N-partitioned LDS loads, resident-B skip, split-K offsets and the per-feature kernel-name tags on top. - grouped_gemm_mxfp4: main's gemm_stage and m_align cluster handling, then decode static M. - grouped_moe_gfx1250: keep both new helpers and both sets of gemm1 kwargs. - tuned_grouped_fmoe.csv: drop the DSR1 rows main moved to model_configs/, take main's 96-expert 16384-token update, keep the Kimi K2 a8w4 rows. - moe_contiguous_psum: drop the HERD import main removed. - test: main's byte model plus the AITER_MOE_NUM_EXPERT_ACTIVATED cap.
Contributor
|
The tuned grouped MXFP4 MoE rows added here make gfx1250 build |
This was referenced Nov 18, 2026
JiaoliangYu
added a commit
that referenced
this pull request
Nov 23, 2026
…rows (#8002) (#8262) * [FlyDSL] [gfx1250] [MoE] DeepSeek-R1 EP4 MegaMoE grouped FMoE rows: ep_fused=1 buckets and tuned 8192 MegaMoE looks the grouped GEMM up with ep_fused=1 (GEMM2 does the EP scatter). For DeepSeek-R1 EP4 (model_dim 7168, inter_dim 2048, 65 experts per rank, topk -1) the table had ep_fused=1 rows only for tokens 1024, 2048, 4096 and 32768, and the ep_fused=0 rows do not serve the fused path, so the other buckets missed and kept the caller's default tile. - tokens 8..512 and 16384: the existing ep_fused=0 rows, with ep_fused=1. - token 8192: the ep_fused=0 row's tiles with persistent_workers2=512 (233.57 us). * [FlyDSL] [gfx1250] [MoE] DeepSeek-R1 EP4 MegaMoE: tuned 32768 ep_fused=1 row Replace the ep_fused=1 token=32768 row from #7726 (hand-set 128x256x256, w1x4, no measurement) with a measured one: 256x256x256 w2x2, 4/4 buffers, cluster_n 4, waves 2/1, prefetch, LDS SoA interleave, A preshuffle. 4-GPU EP4 MegaMoE layer (12288 tokens/rank): 2361 -> 1994.5 us, bit-identical. * Update fused-EP config tests and initialize the CPU allreduce fixture --------- Co-authored-by: [email protected] <[email protected]>
zufayu
pushed a commit
that referenced
this pull request
Nov 25, 2026
…le exceeds the VGPR partition (#8540) 256x256x256 grouped MoE tiles pin each k128 prefetch slot to 128 VGPRs (v256-v511) and the accumulators to 512 (from v512) whenever FlyDSL exposes sched_vgpr. Wave grids that need more, such as a4w4 1x4 (160 per slot) or a8w4 2x2 (192), hit `assert slot_width <= 128` in make_rmem_slot. Tuned rows from #7726 select them, so 36 gfx1250 FlyDSL MoE AOT replay jobs fail and run_aot() aborts. Enable the explicit partition only when the tile fits, using the same arithmetic as the assertion; otherwise keep compiler allocation, as every non-prefill tile does. Tiles that fit build exactly as before. Add an a4w4 1x4 regression test. a8w4 on these tiles is tracked in #8539. Co-authored-by: Claude <[email protected]>
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
Optimize gfx1250 FlyDSL grouped MoE prefill scheduling and add tuned DeepSeek-R1 and DeepSeek-V4.1 Flash configurations. The prefill path uses strict VGPR placement with FlyDSL 0.5, initializes accumulators while prologue tensor loads are outstanding, and schedules existing WMMAs around LDS prefetch and signal/wait regions to cover pipeline waits.
For DSR1 with 65 local experts, the measured EP4 GEMM1+GEMM2 sum falls by 18–27% at global raw tokens 16,384–32,768 versus the tested main revision. Separate 64-expert EP CSV alignment reduces the measured sum by 18–20% at raw tokens 16,384. These are sums of isolated local kernels, not end-to-end or communication-inclusive MoE speedups. Full stage data and exceptions are below.
Motivation
The existing prefill schedule leaves useful computation outside tensor/LDS wait regions, and legacy register-placement controls do not use FlyDSL 0.5's scheduling API. DSR1 also needs separate tuning for routed-only and shared-expert workloads, with EP configurations compared against the matching local workload rather than the same raw token count.
Changes
rocdl.experimental.sched_vgpr(..., soft=False)for strict consumer placement on supported 256×256×256 prefill tiles. Apply the occupancy attribute per kernel so ordinary tiles do not inherit the high-VGPR occupancy target.HYPER_PARAMS: A4W4 prefill uses the 2×4 WMMA order, MMA groups of 2, DS groups of 3, KSL0 prefix/tail counts of 2/4, and KSL1 prefix/in-barrier counts of 4/4. Validate emitted WMMA ranges; the counts partition existing computation.source_token = actual_EP_raw_token // ep_world_sizebefore EP CSV bucketing; retain existing settings when direct reuse does not improve performance.Performance
Method and provenance
2.11.0+rocm10.1.0a20260811-bkc.20260820.Tmatch EP4 global/raw tokens4*T. Sweep: non-EP 1–16,384 and EP4 raw 4–65,536, powers of two. EP raw 32,768 and 65,536 share CSV bucket 32,768.73739369f6b26977dd69886ab0ad3235d91a4992(fetched November 12, 2026) versus625aa919726d1011095c412c347fa83764059dcdplus the measured CSV changes. PR headf423da9fa14693c6333df9532911b5a8ed9b8e26has identical kernel/test sources; its 65-expert rows match that measurement and its full DSR1 CSV matches the final 64-expert validation snapshot.65 local experts: main versus this PR
Non-EP: 64 routed + 1 shared expert, top-k 9 including the shared expert. EP4: 256 global routed experts, routed top-k 8,
shared_E=1,ep_mode=real,ep_fused=0.All timings are microseconds.
G1 / G2lists the two stages separately. Positive reduction means a lower G1+G2 sum.Variability and regressions: At EP raw 65,536 constant, main GEMM1 was 857.80 µs initially and 1,140.72 µs on repeat; PR GEMM1 was 598.74 and 595.76 µs. The initial percentage is not a precise stable speedup. The random repeat measured main 944.76 / 570.83 µs and PR 601.47 / 514.02 µs. At small non-EP sizes, GEMM2 regresses at T=1/2 and GEMM1 regresses at T=4; EP GEMM2 is about 3–5% slower at raw 1,024/2,048. These changes do not improve every stage at every size.
All 60 main/PR pairs, including small-token regressions
An additional non-EP T=1,024 constant repeat measured main 113.25 / 57.39 µs and PR 105.17 / 56.83 µs. Repeat observations are kept separate from the original sweep.
64 local routed experts: EP CSV tuning on this branch
This is a CSV-only before/after comparison on the same branch, not another main comparison. Non-EP uses 64 experts/top-k 8 and no shared expert; EP4 uses 256 global routed experts/top-k 8 and
shared_E=0.Direct non-EP-row reuse was evaluated using actual raw tokens divided by 4. Seven EP rows were added and three replaced. Existing settings were retained for raw 4, 2,048, 4,096 and the shared 32,768/65,536 bucket. Both large sizes were tested with both candidate source rows before retaining that shared bucket. The 65-expert, non-EP and
ep_fused=1rows were preserved during this tuning step.At raw 1,024, interleaved repeats confirmed the modest GEMM2 improvement: 30.24→28.53 µs constant and 31.48→29.67 µs random, with GEMM1 unchanged. At raw 8, the lower total includes a GEMM2 regression; both stage timings are shown above.
All 30 final 64-expert validation points
Rows marked “No” use identical before/after settings; their differences are run-to-run variation. In particular, raw 65,536 constant GEMM1 varied from 477.97 to 531.90 µs without a configuration change.
Testing
All 60 main/PR comparison pairs and three repeat pairs passed the numerical checks. All 30 final 64-expert EP token/initialization cases passed after consolidating the selected CSV. Validation uses the native harness numerical checks, including
logits_diff < 0.01.Reproduction settings:
Non-EP entry point:
op_tests/flydsl_tests/test_flydsl_grouped_gemm.py,--scenario kernel --data-format a4w4 --experts 65 --shared-experts 1 --topk 9 --model-dim 7168 --inter-dim 2048 --act silu --no-bias --balanced-routing --warmup 5 --iters 128 --seed 0 --no-check-aot-cache --data-init constant uniform --scale-init constant auto, sweeping the tokens listed above. Use experts 64, shared experts 0 and top-k 8 for the routed-only workload.EP entry point:
op_tests/test_moe_ep.py::test_fmoe_ep_mxfp4('a4w4_mxfp4', 4*T, 7168, 2048, 256, 8, shared_E=1, ep=4, ep_mode='real', const_init=0.5 or None), with nativerun_perftestset to warmup 5 / iterations 128; useshared_E=0for 64 local experts. The paired driver snapshots the harness for both revisions and selects each revision's own CSV.The final-head data above covers DSR1 A4W4 with fused GEMM1 activation/requantization on gfx1250. DSV4 Pro/Flash, A8W4, optional activation relocation, other activations, and other architectures were not rerun in this final comparison. No distributed communication validation is claimed.
Documentation
The kernel comments explain the scheduling sequence and instruction budgets; wrapper/test documentation describes activation relocation and shared-expert semantics.
Dependencies
Uses the existing FlyDSL dependency; measurements use 0.5.0. Strict prefill placement is gated on availability of
rocdl.experimental.sched_vgpr.Breaking Changes
The Python call additions are optional, but experimental environment controls change: per-field IGLP overrides,
AITER_FLYDSL_EXPLICIT_VGPR_PARTITION,LDS_SOA_LOAD_INTERLEAVE,AITER_FLYDSL_FORCE_1X4_CLUSTER, andAITER_FLYDSL_DISABLE_CLUSTER_SYNCare removed from this kernel. UseHYPER_PARAMSfor instruction scheduling and CSV fields for launch/layout tuning.AITER_FLYDSL_PLANAR_LDSandAITER_FLYDSL_INTERLEAVED_LDS_LOADremain; the latter explicitly overrides the CSV, including when set to zero. DSR1 configurations now live inaiter/configs/model_configs/dsr1_tuned_grouped_fmoe.csv; callers explicitly selecting the old generic CSV should select the model CSV for these rows.PR Self-Review
Reviewed revision
f423da9fa14693c6333df9532911b5a8ed9b8e26. The description and performance provenance were checked against this head; this is not a claim of exhaustive independent code review.Behavior and intent
The optimized prefill schedule partitions existing WMMAs into prefix, signal/wait coverage and ordinary IGLP regions, while strict consumer VGPR placement controls the operand layout. CSV tuning selects launch parameters for the actual local workload, and shared-expert accounting prevents overstating active weight traffic. The intent is to reduce local compute latency without treating EP raw tokens as non-EP local tokens.
Validation and unverified scope
See the workload, revision, numerical-check and measurement details above. Tables preserve slower cases and variable samples. No final-state claim is made for MI250X/MI300X, distributed communication, or workload/features outside the listed DSR1 sweep.
PR-specific question
No automated path-specific self-review question was present when this description was updated.
Changed op tests
op_tests/flydsl_tests/test_flydsl_grouped_gemm.py: adds shared-expert CLI/routing support, checks that shared outputs have unit weight without changing routed normalization, and verifies active-expert byte accounting across A4W4/A8W4 and fused/unfused output modes. These cases cover shared routing and metrics that the previous routed-only harness did not exercise.