Skip to content

feat(moe): FlyDSL MegaMoE fused EP-MoE integration (mega_moe_v1 @8acf…#1666

Draft
JiaoliangYu wants to merge 1 commit into
ROCm:mainfrom
JiaoliangYu:jiaolyu/megamoe-fused-integration
Draft

feat(moe): FlyDSL MegaMoE fused EP-MoE integration (mega_moe_v1 @8acf…#1666
JiaoliangYu wants to merge 1 commit into
ROCm:mainfrom
JiaoliangYu:jiaolyu/megamoe-fused-integration

Conversation

@JiaoliangYu

@JiaoliangYu JiaoliangYu commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

ATOM_USE_FLYDSL_FUSED=1 replaces the EP experts step (dispatch+gemm1+quant+ gemm2+combine) with FlyDSL MegaMoE. Adapted from PR yanbo/mega to the current mega_moe_v1 tip (post kernels refactor #807):

  • fp4_utils module removed -> import gemm_common_utils (e8m0_shuffle/ shuffle_scale_w4 live there now)
  • w1/w1_scale use shuffle_weight_w4/shuffle_scale_w4(gate_up=True, moe_gemm= True) to match the a8w4 INTERLEAVE(g1u1) gate_mode default; the generic shuffle_weight is the SEPARATED layout and mispairs gate/up in swiglu (gsm8k ~0.017)
  • stash layer._mega_local_E at build; do NOT infer expert count from the shuffled _mega_w1 shape (shuffle_weight_w4 + view(-1) breaks the old shape[0]//(2*inter) inference -> experts blows up -> ~76GB mori buffer -> shmem_malloc failed)
  • per-layer weight swap targets mega._s1_w1/_s1_w1_scale (fused stage-1 runtime pointers); forward_bf16 is aliased to forward
  • build MegaMoE and run forward under inference_mode(False)+no_grad so its persistent mori buffers are normal tensors (cudagraph capture does in-place .zero_() outside inference mode)
  • empty_cache after weight build; warmup/dummy token scatter

Validated on DeepSeek-V4-Pro a8w4, 8x MI355X (gfx950), fused ON / EPLB OFF: gsm8k 3-shot flexible=strict=0.9424 (on par with mori/EPLB baseline ~0.95).

Runtime env: ATOM_USE_FLYDSL=1 ATOM_USE_FLYDSL_FUSED=1 ATOM_FLYDSL_KERNELS_PATH=; launch with --max-num-batched-tokens 8192 (keeps mtpr<=8192; larger overflows a stage2 int32 kernel arg).

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

…56d)

ATOM_USE_FLYDSL_FUSED=1 replaces the EP experts step (dispatch+gemm1+quant+
gemm2+combine) with FlyDSL MegaMoE. Adapted from PR yanbo/mega to the current
mega_moe_v1 tip (post kernels refactor ROCm#807):

- fp4_utils module removed -> import gemm_common_utils (e8m0_shuffle/
  shuffle_scale_w4 live there now)
- w1/w1_scale use shuffle_weight_w4/shuffle_scale_w4(gate_up=True, moe_gemm=
  True) to match the a8w4 INTERLEAVE(g1u1) gate_mode default; the generic
  shuffle_weight is the SEPARATED layout and mispairs gate/up in swiglu
  (gsm8k ~0.017)
- stash layer._mega_local_E at build; do NOT infer expert count from the
  shuffled _mega_w1 shape (shuffle_weight_w4 + view(-1) breaks the old
  shape[0]//(2*inter) inference -> experts blows up -> ~76GB mori buffer ->
  shmem_malloc failed)
- per-layer weight swap targets mega._s1_w1/_s1_w1_scale (fused stage-1
  runtime pointers); forward_bf16 is aliased to forward
- build MegaMoE and run forward under inference_mode(False)+no_grad so its
  persistent mori buffers are normal tensors (cudagraph capture does in-place
  .zero_() outside inference mode)
- empty_cache after weight build; warmup/dummy token scatter

Validated on DeepSeek-V4-Pro a8w4, 8x MI355X (gfx950), fused ON / EPLB OFF:
gsm8k 3-shot flexible=strict=0.9424 (on par with mori/EPLB baseline ~0.95).

Runtime env: ATOM_USE_FLYDSL=1 ATOM_USE_FLYDSL_FUSED=1
ATOM_FLYDSL_KERNELS_PATH=<FlyDSL mega_moe_v1>; launch with
--max-num-batched-tokens 8192 (keeps mtpr<=8192; larger overflows a stage2
int32 kernel arg).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Run after the PR is approved and Pre Checkin passes
  • ✅ Run immediately when an approval review is submitted
  • ✅ Can be requested before approval with labels
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, and SGLang
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests

Heavy jobs are skipped when the PR is not approved and no matching ci:* label is present.
Add labels via the sidebar or gh pr edit 1666 --add-label <label>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant