Skip to content

MegaMoE on Gfx950 - #876

Merged
coderfeli merged 42 commits into
mainfrom
mega_moe_v1
Jul 31, 2026
Merged

MegaMoE on Gfx950#876
coderfeli merged 42 commits into
mainfrom
mega_moe_v1

Conversation

@GwilliamHu

@GwilliamHu GwilliamHu commented Jul 21, 2026

Copy link
Copy Markdown
Member

Motivation

Reduce A8W4 expert-parallel MoE latency by overlapping communication with computation and eliminating intermediate kernel launches.

Technical Details

  • Add MegaMoEV2 with per-1x32 quantization, fused dispatch/sort/GEMM1, and fused GEMM2/weighted P2P combine.
  • Support fixed-slot and compact dispatch with static MI355X configurations selected from the runtime token count and max_tok_per_rank (MTPR).
  • No online collective autotuning, tuning artifacts, or FLYDSL_AUTOTUNE environment variable is required.

Usage Notes

  • MTPR must be a positive power of two and cover the largest per-rank token count for the operator instance.
  • For decode/CUDA graphs, use the smallest power of two covering the graph batch, normally the graph batch itself:
    • MTPR <= 128 selects the low-latency fixed-slot path.
    • MTPR >= 256 selects the compact path.
  • Setting MTPR to 8192 for a small decode batch is valid, but forces compact mode and loses the fixed-slot latency advantage.
  • For prefill or chunked prefill, use the smallest power of two covering the maximum per-rank chunk.
  • Runtime token counts do not need to be powers of two; the nearest static token bucket is selected automatically.
  • All ranks in an EP group must use the same MTPR and collective call order. Multiple graph capacities should use corresponding operator instances
    consistently on every rank.

Test Plan

  • Run 8-GPU MI355X v4_pro A8W4 EP8 accuracy and performance sweeps for 1–32768 tokens per rank.
  • Run static-configuration unit tests, standalone GEMM checks, and Python style checks.

GwilliamHu and others added 23 commits July 29, 2026 02:30
Rebased onto latest main as a single commit:
- MegaMoE fused stage1/stage2 + dispatch/combine, packaged as kernels/moe/mega_moe
- merge-import fixes (kernels.common.mma, gemm_common_utils)
- fix MEGA_TUNING_DIR after packaging (parent.parent.parent) so autotune finds kernels/comm/mega_moe_tuning_config (restores tuned tile_m; ~12% small-batch perf)

Co-authored-by: Cursor <cursoragent@cursor.com>
Formatting-only; fixes the Run ./.github/scripts/check_python_style.sh CI gate
(black --check). No functional change.
Faithful FlyDSL port of aiter mxmoe_gemm_v2 (runtime K-loop + C-carry + B-streaming
+ spart/bhoist/ascale_pf/SBM/has_pad) split into gemm2_compute_v2 feeding our P2P
scatter combine. gemm2 wired to the full flydsl Autotuner (disk-cached best config,
per-M key, collective cross-rank bench), matching stage1. bs=8/64/512 PASS.
Add persist=True configs to the fp8 gemm2 autotune space (was fp4-only per aiter's
guard, which does not apply to our own compile_mega_moe_stage2 persist branch --
verified correct, relL2 ~2.8e-3). Persist closes the large-M gap vs the V1
mixed_moe_gemm2 (bs=1024 stage2 0.335->0.288ms, ~19%->~3%); the per-M autotune
picks persist at large M and non-persist at small M.
Reduce quantized scatter overhead and apply FP8 only to large batches. Align the rebased V2 path with current FlyDSL APIs and remove the obsolete mixed MoE implementation.
@GwilliamHu GwilliamHu changed the title MegaMoEV1 on Gfx950 MegaMoE on Gfx950 Jul 29, 2026
@coderfeli
coderfeli merged commit dc8e153 into main Jul 31, 2026
12 of 14 checks passed
@coderfeli
coderfeli deleted the mega_moe_v1 branch July 31, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants