[CK][MoE] Add swiglu_oai (OAI SwiGLU) activation to XDL 2-stage MoE epilogue#8749
Open
LJ-underdog wants to merge 1 commit into
Open
[CK][MoE] Add swiglu_oai (OAI SwiGLU) activation to XDL 2-stage MoE epilogue#8749LJ-underdog wants to merge 1 commit into
LJ-underdog wants to merge 1 commit into
Conversation
03150bb to
7994abc
Compare
1 task
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for the OAI-form SwiGLU activation (swiglu_oai_and_mul) to the Composable Kernel XDL 2-stage MoE epilogue so OAI/gpt-oss style MoE models can use this path.
Changes:
- Extend the shared
Activationenum withswiglu_oai_and_mul = 3. - Introduce
apply_swiglu_oai_activation(gate, up)implementinggate * sigmoid(1.702 * gate) * (up + 1)with the specified clamps. - Wire the new activation into the four MoE epilogue paths (quant/non-quant ×
Run/Run_2Lds).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| projects/composablekernel/include/ck/tensor_operation/gpu/grid/gridwise_moe_gemm.hpp | Adds the OAI SwiGLU helper and integrates the new activation into all relevant epilogue branches. |
| projects/composablekernel/include/ck/tensor_operation/gpu/grid/gridwise_gemm_xdl_cshuffle_common.hpp | Extends the shared activation enum to include the new OAI SwiGLU option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+314
to
+317
| // sigmoid(alpha*gate) = 1 / (1 + exp(-alpha*gate)); to bit-match flatmm float path use | ||
| // __builtin_amdgcn_rcpf(1.0f + math::exp(kSwiGluOaiAlpha * -gate)) instead of 1.0f/(...). | ||
| const float sig = 1.0f / (1.0f + math::exp(kSwiGluOaiAlpha * -gate)); | ||
| return gate * sig * (up + 1.0f); // OAI form |
Comment on lines
31
to
35
| gelu_and_mul = 0, | ||
| silu_and_mul = 1, | ||
| swiglustep_and_mul = 2 | ||
| swiglustep_and_mul = 2, | ||
| swiglu_oai_and_mul = 3 | ||
| }; |
7994abc to
57a4302
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Enable the OAI-form SwiGLU activation (
swiglu_oai,gate * sigmoid(1.702 * gate) * (up + 1), gpt-oss style) in the Composable Kernel XDL 2-stage MoE path. The MoE gridwise kernel epilogue currently supports only silu/gelu; this adds swiglu_oai so OAI-style MoE models can use this path.Technical Details
gridwise_gemm_xdl_cshuffle_common.hpp: addActivation::swiglu_oai_and_mul = 3.gridwise_moe_gemm.hpp: add theapply_swiglu_oai_activationhelper (gate * sigmoid(1.702 * gate) * (up + 1), clampgate <= 7andup in [-7, 7], OAI/gpt-oss form) and wire it into all 4 epilogue paths (quant + non-quant xRun/Run_2Lds).Test Plan
Validate the new epilogue branch against a torch fp32 OAI-SwiGLU reference through the aiter per-token fp8 MoE path (op-isolate on gfx942 / MI308X).
Test Result
cos_sim = 0.999993 vs the torch fp32 OAI-SwiGLU reference; no NaN. Confirmed the per-token fp8 path dispatches to this
GridwiseMoeGemmkernel (rocprofv3) and runs the swiglu_oai epilogue branch.Submission Checklist