Repository navigation
[FlyDSL] MegaMoEV2: SwiGLU-OAI GEMM1 activation - #8916
MengqingCao wants to merge 1 commit into
Conversation
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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
|
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. |
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 positiveswiglu_limit: the gate is clamped above, the up projection to plus or minus the limit, then gate * sigmoid(1.702 * gate) * (up + 1).gated_act_f32ingemm_util.py, serves both GEMM1 epilogues:SiluQuantEpilogue(staged route) andmake_ring_gemm1(fused small-input kernel). The small-input kernel name carries the activation.m31network and an MX rounding emulation (_reference(quantize=...)).Review focus
gated_act_f32reusesact.swiglu_mul_batch, the activation's existing FlyDSL definition, so it matchesaiter.fused_moe'sswiglu.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
combine_wire: [FlyDSL] MegaMoEV2: combine_wire option that every route honours #8918.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'saiter/ops/flydsl,aiter/aot,aiter/utility,op_tests/multigpu_testsandtestsover the image's aiter. Fromop_tests/multigpu_tests: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_gemm1given "silu" instead ofact) gave 55 of 64 cases FAIL.🤖 Generated with Claude Code