Repository navigation
[FlyDSL] [JIT] mega_moe_tp optimizations - #8270
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
MiniMax-M3.1 `--moe-backend mega` on pure TP now runs the 128 MXFP4 routed experts, the MXFP8 shared expert (kept MXFP8, AITER MegaMoeTP `w1_shared`, ROCm/aiter#8270) and the all-reduce in one AITER launch per MoE layer. The shared expert is no longer fused into the MXFP4 experts. - Per-step decision in custom ops (`tp_mega_moe_forward`, `tp_mega_add_norm[_quant]`, `tp_mega_layer_output`), all keyed on `MiniMaxM3MoE.tp_mega_serves(rows)`: a compiled forward cannot branch on the symbolic row count (the custom dispatcher drops Dynamo guards). A served step's output is all-reduced in the kernel and the next norm runs without an all-reduce; every other step runs the standard block, TP-partial, into the next fused all-reduce + norm (reduce_results stays False), so the MoE output is reduced exactly once a step. - Shared expert layout: `MiniMaxM3MoE.process_weights_after_loading` (the loader processes a parent before its children) converts the row-major MXFP8 bytes with `shuffle_weight_mega_fp8` + `e8m0_shuffle`. - Routing: one `topk_gating` into a per-row-count [rows, top_k + 1] buffer (routed scale folded, the shared expert appended at weight 1). - Dispatch range from the per-layer table: 1..6144 rows but 897..1024, and AITER's big-M path from 8192 rows (eager steps only; never in a captured graph). Co-Authored-By: Claude <[email protected]>
…w-sharded eager steps (ATOM_KIMI_K3_MEGA_MOE_PREFILL, off) With ATOM_KIMI_K3_MEGA_MOE_PREFILL=1, an eager row-sharded step of at least ATOM_KIMI_K3_MEGA_MOE_PREFILL_MIN_TOKENS rows (4096) runs the router and the latent down projection on this rank's rows only (the merged front weight's last rows), the top-k on those rows, and one MegaMoeTP launch per layer (ROCm/aiter#8270, comm_mode ag_rs, comm_dtype bf16): the kernel gathers the MXFP4 rows, runs both expert GEMMs, combines in BF16 and reduce-scatters the BF16 latent to this rank's rows. That replaces the front all-gather, the replicated fused_moe and the routed reduce-scatter; the shared partial is reduce-scattered alone. atom/model_ops/fused_moe/tp_mega_moe.py holds the shared runtime (built on the first step it takes, which is the warmup's dummy prefill, so the KV budget sees its memory), the layer check and the per-layer launch. Only big-M batches are taken (every kernel compiled by prepare at build). The kernel is persistent and needs the whole GPU, so ATOM_KIMI_K3_ROW_SHARD_SIDE_RS is not used on the steps it takes. row_sharded_moe's native body moved unchanged into _native_row_sharded_sum. Precision: MXFP4 dispatch and activations as fused_moe's a4w4, BF16 combine and reduce-scatter (week-1 policy). The MXFP4 rounding points differ from fused_moe's: against a bf16-activation fp32 reference both are at rel L2 0.218 (MEGAMOE micro-benchmark round 2). Tests: tests/model_ops/test_tp_mega_moe.py (gate, routing, launch, timeout bits) and three cases in tests/models/test_kimi_k3_row_tail.py (the layer sums as the replicated row tail with a CPU stand-in for MegaMoeTP; no front gather; unmerged front keeps the native path).
* support m3 and dsv4.1 * update optimizations * merge small m path code * update * optimnization * optimizations * optimizations * update * update * update * update * update * update * optimizations * optimizations * optimizations (cherry picked from commit 908934d)
Summary
mega_moe_tp optimizations