Skip to content

MegaMoE mori path: follow mori#726, size fp4 combine flags, zero-copy combine input - #6272

Closed
jhchouuu wants to merge 5 commits into
ROCm:yanbo/megafrom
jhchouuu:jhchou/mega-mori-combine-fixes
Closed

jhchouuu wants to merge 5 commits into
ROCm:yanbo/megafrom
jhchouuu:jhchou/mega-mori-combine-fixes

Conversation

@jhchouuu

@jhchouuu jhchouuu commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes and one optimization for MegaMoE's mori path (stage1_fused / stage2_fused off), found running DSR1 (EP4, topk 9 with the fused shared expert) against mori main.

Fixes (each from driving mori's plans without its op layer):

  • dispatch: gfx1250 EPv2: EP4 topk-9 geometry; selfFirst follows MORI_EP_TOKOFF_EXT mori#726 replaced the plan's self_first with tok_off_ext, and self_first_enabled() is gone, so building the dispatch fails with an ImportError. Pass tok_off_ext when mori takes it; older mori keeps its current path.
  • tuning lookup: keyed on "bf16" whatever the wire. mori keys an fp4 dispatch as "fp4_disp_bf16_comb" (its op layer's dtype_str), so topk 9 matched nothing and dispatch and the fp4 combine both fell back to the single-shot default. The key now lives on _DispatchWire.
  • comb_inp: missed the overlapped fp4 combine's u64 flag per landing row (four ranks up). Its 24-warp geometries write those past the region, which is the arena's last: a GPU page fault at 16384 tokens a rank, a hang or silent corruption at smaller sizes.
  • close(): synchronize before freeing, so an in-flight launch does not read a freed window.

Zero-copy: with stage2_fused off, fused_moe's rows went to a fresh tensor and were then copied into mori's staging (inside the bf16 combine kernel, or by a host-issued copy for fp4 whenever the recv bound is below max_recv, i.e. every decode step under ATOM). fused_moe now writes them there directly: fused_moe(output=) is threaded down the gfx1250 grouped path to the gather-reduce, which it previously ignored.

Test

4x gfx1250, mori main (066fd10e), DSR1 shape (-e 256 -k 8 --fused_shared_experts 1):

  • bench_mega_moe.py, all-mori mode, tokens/rank 512/1536/4096, bf16 and mxfp4 combine: accuracy PASS; bf16 combine kernel faster with the copy gone
  • bench_mega_moe.py, all three modes at 1536 / mxfp4: PASS (fused paths unchanged)
  • ATOM DSR1 serving (ISL 1024 / OSL 4096 / conc 6144), mori dispatch + mori MXFP4 combine: no faults; throughput above the fused-combine baseline
  • gsm8k (3-shot, real routing): matches the expected range for this model

🤖 Generated with Claude Code

yanboshao and others added 5 commits October 8, 2026 04:22
Four fixes to the mori dispatch/combine path (stage1_fused/stage2_fused
off), each from driving mori's plans without its op layer:

- dispatch: since ROCm/mori#726 the plan takes tok_off_ext and derives
  selfFirst itself; self_first_enabled() is gone, so importing it fails.
- tuning lookup: key it on the dispatch wire the way mori's op layer
  does ("fp4_disp_bf16_comb" for fp4). Under the hard-coded "bf16" key
  topk 9 matched no entry and both dispatch and the fp4 combine fell
  back to the single-shot default.
- comb_inp: add the overlapped fp4 combine's u64 flag per landing row
  (four ranks up). Its 24-warp geometries write them past the region,
  i.e. past the arena: a page fault at 16384 tokens a rank.
- close(): synchronize first, so a launch still in flight does not read
  a window that has been freed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With stage2_fused off, fused_moe's rows went into a fresh tensor and then
into mori's staging rows (comb_inp): the bf16 combine copied them in its
own kernel, the fp4 one through a host-issued copy whenever the recv bound
was below max_recv -- every decode step under ATOM.

Have fused_moe write them there directly. fused_moe(output=) already
existed but the gfx1250 grouped path ignored it and copied at the end;
thread it down to the gather-reduce. mori's bf16 combine then sees its
input at the staging base and skips the copy, and the fp4 send reads the
staging rows in place.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

4 participants