Skip to content

[FlyDSL] MegaMoEV2: SwiGLU-OAI GEMM1 activation - #8916

Closed
MengqingCao wants to merge 1 commit into
ROCm:mainfrom
MengqingCao:mengqing/main-megamoe-swiglu-oai
Closed

MengqingCao wants to merge 1 commit into
ROCm:mainfrom
MengqingCao:mengqing/main-megamoe-swiglu-oai

Conversation

@MengqingCao

@MengqingCao MengqingCao commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review. No blocking issues. First of a stack of three: #8917 and #8918 build on this branch.

Why

MiniMax-M3.1's experts use SwiGLU-OAI, but MegaMoEV2 accepts only SiLU or SiTUv2 as its gated activation. An M3.1 caller cannot run its experts through MegaMoEV2 with the right numerics.

What changed

  • MegaMoEV2(act="swigluoai") with a positive swiglu_limit: the gate is clamped above, the up projection to plus or minus the limit, then gate * sigmoid(1.702 * gate) * (up + 1).
  • One helper, gated_act_f32 in gemm_util.py, serves both GEMM1 epilogues: SiluQuantEpilogue (staged route) and make_ring_gemm1 (fused small-input kernel). The small-input kernel name carries the activation.
  • Test: the fp32 reference gains the activation, an m31 network and an MX rounding emulation (_reference(quantize=...)).

Review focus

  • gated_act_f32 reuses act.swiglu_mul_batch, the activation's existing FlyDSL definition, so it matches aiter.fused_moe's swiglu.

Testing

The staged route at M3.1 shapes matches the fp32 SwiGLU-OAI reference, both quants. The fused route uses it in the next PR of the stack.
mengqing/main-megamoe-combine-wire @ ef6599c43 (this branch plus the next two): M3.1 size suite bs 1/104/512 relL2 0.053, graph replay PASS. ruff, black clean.

Follow-ups

Dev record

Found. none

Decided. The large-input kernel's epilogue stays SiLU only: no fused layout needs another activation there.

Surprised. none

Left undone. This commit alone was not run on GPU; the stack head was, and it contains this commit unchanged. Not run: MI300X, MI250X, EP8.

Evidence

4 x MI355X (gfx950), image mengqing-108/agx:c2f06e01-mega-a40489a9e (FlyDSL 0.5.3), the stack head's aiter/ops/flydsl, aiter/aot, aiter/utility, op_tests/multigpu_tests and tests over the image's aiter. From op_tests/multigpu_tests:

torchrun --nproc-per-node 4 test_mega_moe_v2.py --network m31 --bs-list 1,104,512 --accuracy-max-bs 512
[MEGA-V2] bs=1 relL2=0.053168 path=compact graph_replay=PASS p2p_quant=none
[MEGA-V2] bs=104 relL2=0.053423 path=compact graph_replay=PASS p2p_quant=none
[MEGA-V2] bs=512 relL2=0.053476 path=compact graph_replay=PASS p2p_quant=none

SwiGLU-OAI on the ring GEMM1 (from the next PR's routes suite): every fused call equals the staged route at relL2 0.000000 (a8w4). The pre-merge revert-red on the same code (make_ring_gemm1 given "silu" instead of act) gave 55 of 64 cases FAIL.

🤖 Generated with Claude Code

MiniMax-M3.1's experts use SwiGLU-OAI: the gate clamped above and the
up projection to +-swiglu_limit, then gate * sigmoid(1.702 * gate) *
(up + 1). MegaMoEV2 accepts act="swigluoai" (with a positive
swiglu_limit) and applies it in both GEMM1 epilogues through one helper,
gated_act_f32: the shared SiluQuantEpilogue (staged route) and the ring
GEMM1 of the fused small-input kernel, which takes act and keys its
kernel name on it.

The test reference gains the activation, an "m31" network and an MX
rounding emulation (_reference(quantize=(input, hidden))) for an error
check against the op's own quantization.

Co-Authored-By: Claude <[email protected]>
@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 8916 --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.

@MengqingCao

Copy link
Copy Markdown
Contributor Author

Superseded by #8920: the same commit, reopened from a ROCm/aiter branch so the three PRs form a stack (stack #8923) and each shows only its own diff.

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