Skip to content

[FlyDSL] [JIT] mega_moe_tp optimizations - #8270

Merged
binding7012 merged 17 commits into
mainfrom
mega_moe_tp_opt_1115
Nov 26, 2026
Merged

binding7012 merged 17 commits into
mainfrom
mega_moe_tp_opt_1115

Conversation

@binding7012

Copy link
Copy Markdown
Contributor

Summary

mega_moe_tp optimizations

@binding7012
binding7012 requested a review from a team November 19, 2026 06:30
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8270 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot changed the title mega_moe_tp optimizations [FlyDSL] [JIT] mega_moe_tp optimizations Nov 19, 2026
@aiter-bot

aiter-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision f83715ed49bb · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/multigpu_tests/test_mega_moe_tp.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@binding7012
binding7012 merged commit 908934d into main Nov 26, 2026
60 checks passed
@binding7012
binding7012 deleted the mega_moe_tp_opt_1115 branch November 26, 2026 06:59
ganyi1996ppo added a commit to ROCm/ATOM that referenced this pull request Nov 26, 2026
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]>
whx-sjtu pushed a commit to whx-sjtu/ATOM that referenced this pull request Dec 1, 2026
…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).
whx-sjtu pushed a commit to whx-sjtu/aiter that referenced this pull request Dec 1, 2026
* 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)
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.

5 participants