Pull Request has been successfully merged by CANN-robot.
(Thank you for OblivionZHU's contribution.)变更摘要
该 PR 为 MegaMoe 算子新增了两种门控激活模式 swiglustep 和 swigluoai,并在 A5 (arch35) 平台上提供对应的 kernel 实现。同时,将原有的 ActivationFlowSwiGLU、ActivationFlowSiTU 及 COMPUTE_TANH_TWOPATH 宏从 block_epilogue_activation_mx_quant.h 重构提取到新文件 gated_activation.h 中,以改善代码组织。
主要改动
-
新增
swiglustep激活模式: 在 tiling 校验层(mega_moe_tiling.cpp)中增加对"swiglustep"字符串的识别,参数校验与swiglu一致(0 或 1 个 clamp 参数);tiling 数据中设定actMode=2、actSubMode=0;kernel 实现公式为min(SiLU(gate), clamp) × clip(up, ±clamp),与 SwiGLU 的区别在于 gate 不再做输入裁剪,而是对 SiLU 输出做上限裁剪。 -
新增
swigluoai激活模式: tiling 校验层要求swigluoai必须提供 3 个参数[clamp, alpha, beta],并对各参数进行有效性校验(clamp ≥ 0、alpha/beta 有限);tiling 数据中设定actMode=3,alpha/beta 从参数中取值;kernel 实现公式为(up + beta) × min(gate, clamp) × sigmoid(alpha × min(gate, clamp)),与 SwiGLU 的区别在于 up 裁剪后加上 beta,且 sigmoid 计算使用-alpha*gate替代-gate。 -
新增
ActMode枚举值: 在block_epilogue_activation_mx_quant.h的ActMode枚举中新增SWIGLU_STEP = 2和SWIGLU_OAI = 3,并在激活分派器VFDoActivationAndQuantForMX和运行时路由逻辑中增加对应的分支调用。 -
重构提取
gated_activation.h: 将COMPUTE_TANH_TWOPATH宏以及ActivationFlowSwiGLU、ActivationFlowSiTU的完整实现从block_epilogue_activation_mx_quant.h迁移至新文件gated_activation.h,并在该文件中新增ActivationFlowSwiGLUStep和ActivationFlowSwiGLUOai两个 kernel 函数,通过#include "gated_activation.h"在原有位置引入。 -
URMA 拓扑限制: 在 tiling 校验层增加拓扑类型检查——当
topoType为TOPO_TYPE_URMA时仅允许swiglu激活,禁止swiglustep、swigluoai等其他激活类型。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| mc2 | ✅ yangzeheng, luobaiqing (2/2) | ✅ yangzeheng (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
OblivionZHU, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/lgtm


/approve


描述
修改说明
本 PR 为 A5(arch35)MegaMoe 的激活与 MX 量化融合流程新增
swiglustep和swigluoai支持,并对现有激活代码进行模块化重构。主要修改
swiglustep、swigluoai激活识别、参数校验、默认值设置和 TilingData 赋值。MegaMoeActMode、MegaMoeActSubMode枚举,替代两侧分散维护的裸值0/1/2/3。TilingData 仍使用uint8_t,不改变现有布局。gated_activation.h,集中实现 SwiGLU、SwiGLU-Step、SwiGLU-OAI 和 SiTU 激活流程。VFDoActivation,使VFDoActivationAndQuantForMX仅负责组织激活和后续 MX 量化流程。激活参数约束
swiglu[clamp]clamp默认取 float 最大值,要求非负且非 NaNswiglustep[clamp]swiglu相同swigluoai[clamp, alpha, beta]clamp=float max、alpha=1.702、beta=1.0;alpha/beta要求为有限值situglu[beta]或[beta, linear_beta]兼容性说明
swiglu和situglu行为。swiglu,其他激活在 Tiling 阶段拦截,不修改 URMA Kernel。关联的Issue
3980[Requirement|需求建议]: MegaMoe建议新增激活方式
测试
二级冒烟、算子泛化等。
文档更新
类型标签