| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Co-authored-by: boes129<chenqi185@huawei.com> # message auto-generated for no-merge-commit merge: !7492 merge feature/swiglu_step into master [activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Created-by: boes129 Commit-by: boes129 Merged-by: cann-robot Description: ## 描述 本 PR 新增 experimental/activation/swiglu_clamp 算子 —— silu+clamp+mul 融合激活(SwigluClamp 顺序: **silu 在前、clamp 上限在后**;区别于本仓现有的 clipped_swiglu 的 clamp-then-silu 顺序)。用于 Step-3.7-Flash 等 MoE 模型的 FFN 专家层激活,已在 910B / 910C 完成端到端推理 + 精度验证。 数学: gate = x[..., :N], up = x[..., N:] out = silu(gate).clamp(max=limit) * up.clamp(min=-limit, max=limit) 输入 x[..., 2N] → 输出 [..., N],dtype 同输入;limit 为标量属性(默认 7.0)。中间升 fp32 计算,store 前降精度。 **交付件**(对齐 experimental/activation/mish 模板): | 目录 | 内容 | | --------------- | ------------------------------------------------------------ | | op_host/ | OpDef 注册 + InferShape(末维减半,奇数拒绝) + Tiling(dtype-aware bufferCoefficient) | | op_kernel/ | AscendC 实现: sigmoid / silu / clamp(Mins/Maxs) / Mul,中间升 fp32,bf16/fp16 经 Cast 路径,bf16 同 else 分支 | | op_api/aclnn/ | 两段式接口(.cpp/.h),ACLNN_CMD dlsym,无需头 include | | tests/ut/ | op_host: Infershape 5 case + Tiling 3 dtype; op_kernel: 1 case(gen_data/compare_data,rtol=1e-4,tikicpulib CPU 仿真); 910B / 910C 双 SoC 均 5/5 + 1/1 PASS | | examples/ | ACLNN 调用示例(bf16 + fp32) | | README.md | 算子说明(接口/数学/精度/dtype/平台) | **附带 torch_extension/cann_ops_nn PTA binding**: - csrc/activation/swiglu_clamp.cpp: ACLNN_CMD + PYBIND11,torch.ops.cann_ops_nn.swiglu_clamp 调用链 - ops/activation/swiglu_clamp.py: OpBuilder schema + register_meta(末维减半) + PrivateUse1 - ops/__init__.py: 注册链 from . import activation ## 关联的Issue https://gitcode.com/cann/ops-nn/issues/3913 ## 测试 **双 SoC 真机验证**(910B + 910C,均通过 SIG 评审前全量验证): | 验证项 | 910B(AT800T,CANN 9.0.1) | 910C(Atlas A3 / AT900A3,CANN 9.0.0) | | ------------------------------------------------ | ------------------------------ | ------------------------------------------- | | 编译 / 安装(--experimental) | ✅ | ✅(交叉编译 ascend910_93 kernel,3 个 .o) | | ophost UT(infershape + tiling) | ✅ 5/5 | ✅ 5/5 | | op_kernel UT(tikicpulib CPU 仿真,fp32,rtol=1e-4) | ✅ 1/1 | ✅ 1/1 | | ACLNN example(端到端) | ✅ bf16 / fp32 / fp16 | ✅ bf16 / fp32 | | PTA binding torch.ops.cann_ops_nn.swiglu_clamp | ✅ [4,32]→[4,16] + clamp 定点 | ✅ 同 | **双 SoC 输出逐位一致**:910B / 910C 的 aclnn example 共享定点 result[22] 完全相同 —— **bf16 -2.859375、fp32 -2.857722**(= 手算 silu(3) × clamp(-1,±7) = 2.857722 × (-1)),两 SoC 分毫不差,跨平台数值行为确定、无 SoC 相关偏移。 **精度**(60 case = 5 shape × 4 输入模式 × 3 dtype,主矩阵在 910B,910C 定点逐位复验): - BFLOAT16(Step-3.7 实际使用 dtype):**20/20 全 PASS**(MERE+MARE) - FLOAT32:**20/20 全 PASS**(近乎精确,MERE ~1e-8) - FLOAT16:20/20 MERE PASS;MARE 15 case 超标 → 根因 IEEE 754 fp16 denormal 表示极限(silu(深负gate) 下溢到 ~1e-8),**非算子缺陷**;过滤 ~1% 病态点后 MARE 4.88e-4 低于单倍阈值,达标 **性能**(详见 swiglu_clamp-performance-report.md):融合算子相对 torch 拆开(silu+clamp+clamp+mul,~4 个 aclnn)—— bf16 prefill(eager 大档)**5.4–7.5×**、decode(graph)**2.1–3.6×**;端到端 msprof 实测 prefill bf16 **6.20×**,与算子级 bench 吻合。 精度标准对标[生态算子开源精度标准(experimental_standard.md)](https://gitcode.com/cann/opbase/blob/master/docs/zh/ops_precision_standard/experimental_standard.md)。 ## 文档更新 - 新增 experimental/activation/swiglu_clamp/README.md(算子说明: 接口/数学/精度/dtype/平台/编译/运行) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!7492 | 6 天前 | |
[activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Co-authored-by: boes129<chenqi185@huawei.com> # message auto-generated for no-merge-commit merge: !7492 merge feature/swiglu_step into master [activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Created-by: boes129 Commit-by: boes129 Merged-by: cann-robot Description: ## 描述 本 PR 新增 experimental/activation/swiglu_clamp 算子 —— silu+clamp+mul 融合激活(SwigluClamp 顺序: **silu 在前、clamp 上限在后**;区别于本仓现有的 clipped_swiglu 的 clamp-then-silu 顺序)。用于 Step-3.7-Flash 等 MoE 模型的 FFN 专家层激活,已在 910B / 910C 完成端到端推理 + 精度验证。 数学: gate = x[..., :N], up = x[..., N:] out = silu(gate).clamp(max=limit) * up.clamp(min=-limit, max=limit) 输入 x[..., 2N] → 输出 [..., N],dtype 同输入;limit 为标量属性(默认 7.0)。中间升 fp32 计算,store 前降精度。 **交付件**(对齐 experimental/activation/mish 模板): | 目录 | 内容 | | --------------- | ------------------------------------------------------------ | | op_host/ | OpDef 注册 + InferShape(末维减半,奇数拒绝) + Tiling(dtype-aware bufferCoefficient) | | op_kernel/ | AscendC 实现: sigmoid / silu / clamp(Mins/Maxs) / Mul,中间升 fp32,bf16/fp16 经 Cast 路径,bf16 同 else 分支 | | op_api/aclnn/ | 两段式接口(.cpp/.h),ACLNN_CMD dlsym,无需头 include | | tests/ut/ | op_host: Infershape 5 case + Tiling 3 dtype; op_kernel: 1 case(gen_data/compare_data,rtol=1e-4,tikicpulib CPU 仿真); 910B / 910C 双 SoC 均 5/5 + 1/1 PASS | | examples/ | ACLNN 调用示例(bf16 + fp32) | | README.md | 算子说明(接口/数学/精度/dtype/平台) | **附带 torch_extension/cann_ops_nn PTA binding**: - csrc/activation/swiglu_clamp.cpp: ACLNN_CMD + PYBIND11,torch.ops.cann_ops_nn.swiglu_clamp 调用链 - ops/activation/swiglu_clamp.py: OpBuilder schema + register_meta(末维减半) + PrivateUse1 - ops/__init__.py: 注册链 from . import activation ## 关联的Issue https://gitcode.com/cann/ops-nn/issues/3913 ## 测试 **双 SoC 真机验证**(910B + 910C,均通过 SIG 评审前全量验证): | 验证项 | 910B(AT800T,CANN 9.0.1) | 910C(Atlas A3 / AT900A3,CANN 9.0.0) | | ------------------------------------------------ | ------------------------------ | ------------------------------------------- | | 编译 / 安装(--experimental) | ✅ | ✅(交叉编译 ascend910_93 kernel,3 个 .o) | | ophost UT(infershape + tiling) | ✅ 5/5 | ✅ 5/5 | | op_kernel UT(tikicpulib CPU 仿真,fp32,rtol=1e-4) | ✅ 1/1 | ✅ 1/1 | | ACLNN example(端到端) | ✅ bf16 / fp32 / fp16 | ✅ bf16 / fp32 | | PTA binding torch.ops.cann_ops_nn.swiglu_clamp | ✅ [4,32]→[4,16] + clamp 定点 | ✅ 同 | **双 SoC 输出逐位一致**:910B / 910C 的 aclnn example 共享定点 result[22] 完全相同 —— **bf16 -2.859375、fp32 -2.857722**(= 手算 silu(3) × clamp(-1,±7) = 2.857722 × (-1)),两 SoC 分毫不差,跨平台数值行为确定、无 SoC 相关偏移。 **精度**(60 case = 5 shape × 4 输入模式 × 3 dtype,主矩阵在 910B,910C 定点逐位复验): - BFLOAT16(Step-3.7 实际使用 dtype):**20/20 全 PASS**(MERE+MARE) - FLOAT32:**20/20 全 PASS**(近乎精确,MERE ~1e-8) - FLOAT16:20/20 MERE PASS;MARE 15 case 超标 → 根因 IEEE 754 fp16 denormal 表示极限(silu(深负gate) 下溢到 ~1e-8),**非算子缺陷**;过滤 ~1% 病态点后 MARE 4.88e-4 低于单倍阈值,达标 **性能**(详见 swiglu_clamp-performance-report.md):融合算子相对 torch 拆开(silu+clamp+clamp+mul,~4 个 aclnn)—— bf16 prefill(eager 大档)**5.4–7.5×**、decode(graph)**2.1–3.6×**;端到端 msprof 实测 prefill bf16 **6.20×**,与算子级 bench 吻合。 精度标准对标[生态算子开源精度标准(experimental_standard.md)](https://gitcode.com/cann/opbase/blob/master/docs/zh/ops_precision_standard/experimental_standard.md)。 ## 文档更新 - 新增 experimental/activation/swiglu_clamp/README.md(算子说明: 接口/数学/精度/dtype/平台/编译/运行) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!7492 | 6 天前 | |
[activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Co-authored-by: boes129<chenqi185@huawei.com> # message auto-generated for no-merge-commit merge: !7492 merge feature/swiglu_step into master [activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Created-by: boes129 Commit-by: boes129 Merged-by: cann-robot Description: ## 描述 本 PR 新增 experimental/activation/swiglu_clamp 算子 —— silu+clamp+mul 融合激活(SwigluClamp 顺序: **silu 在前、clamp 上限在后**;区别于本仓现有的 clipped_swiglu 的 clamp-then-silu 顺序)。用于 Step-3.7-Flash 等 MoE 模型的 FFN 专家层激活,已在 910B / 910C 完成端到端推理 + 精度验证。 数学: gate = x[..., :N], up = x[..., N:] out = silu(gate).clamp(max=limit) * up.clamp(min=-limit, max=limit) 输入 x[..., 2N] → 输出 [..., N],dtype 同输入;limit 为标量属性(默认 7.0)。中间升 fp32 计算,store 前降精度。 **交付件**(对齐 experimental/activation/mish 模板): | 目录 | 内容 | | --------------- | ------------------------------------------------------------ | | op_host/ | OpDef 注册 + InferShape(末维减半,奇数拒绝) + Tiling(dtype-aware bufferCoefficient) | | op_kernel/ | AscendC 实现: sigmoid / silu / clamp(Mins/Maxs) / Mul,中间升 fp32,bf16/fp16 经 Cast 路径,bf16 同 else 分支 | | op_api/aclnn/ | 两段式接口(.cpp/.h),ACLNN_CMD dlsym,无需头 include | | tests/ut/ | op_host: Infershape 5 case + Tiling 3 dtype; op_kernel: 1 case(gen_data/compare_data,rtol=1e-4,tikicpulib CPU 仿真); 910B / 910C 双 SoC 均 5/5 + 1/1 PASS | | examples/ | ACLNN 调用示例(bf16 + fp32) | | README.md | 算子说明(接口/数学/精度/dtype/平台) | **附带 torch_extension/cann_ops_nn PTA binding**: - csrc/activation/swiglu_clamp.cpp: ACLNN_CMD + PYBIND11,torch.ops.cann_ops_nn.swiglu_clamp 调用链 - ops/activation/swiglu_clamp.py: OpBuilder schema + register_meta(末维减半) + PrivateUse1 - ops/__init__.py: 注册链 from . import activation ## 关联的Issue https://gitcode.com/cann/ops-nn/issues/3913 ## 测试 **双 SoC 真机验证**(910B + 910C,均通过 SIG 评审前全量验证): | 验证项 | 910B(AT800T,CANN 9.0.1) | 910C(Atlas A3 / AT900A3,CANN 9.0.0) | | ------------------------------------------------ | ------------------------------ | ------------------------------------------- | | 编译 / 安装(--experimental) | ✅ | ✅(交叉编译 ascend910_93 kernel,3 个 .o) | | ophost UT(infershape + tiling) | ✅ 5/5 | ✅ 5/5 | | op_kernel UT(tikicpulib CPU 仿真,fp32,rtol=1e-4) | ✅ 1/1 | ✅ 1/1 | | ACLNN example(端到端) | ✅ bf16 / fp32 / fp16 | ✅ bf16 / fp32 | | PTA binding torch.ops.cann_ops_nn.swiglu_clamp | ✅ [4,32]→[4,16] + clamp 定点 | ✅ 同 | **双 SoC 输出逐位一致**:910B / 910C 的 aclnn example 共享定点 result[22] 完全相同 —— **bf16 -2.859375、fp32 -2.857722**(= 手算 silu(3) × clamp(-1,±7) = 2.857722 × (-1)),两 SoC 分毫不差,跨平台数值行为确定、无 SoC 相关偏移。 **精度**(60 case = 5 shape × 4 输入模式 × 3 dtype,主矩阵在 910B,910C 定点逐位复验): - BFLOAT16(Step-3.7 实际使用 dtype):**20/20 全 PASS**(MERE+MARE) - FLOAT32:**20/20 全 PASS**(近乎精确,MERE ~1e-8) - FLOAT16:20/20 MERE PASS;MARE 15 case 超标 → 根因 IEEE 754 fp16 denormal 表示极限(silu(深负gate) 下溢到 ~1e-8),**非算子缺陷**;过滤 ~1% 病态点后 MARE 4.88e-4 低于单倍阈值,达标 **性能**(详见 swiglu_clamp-performance-report.md):融合算子相对 torch 拆开(silu+clamp+clamp+mul,~4 个 aclnn)—— bf16 prefill(eager 大档)**5.4–7.5×**、decode(graph)**2.1–3.6×**;端到端 msprof 实测 prefill bf16 **6.20×**,与算子级 bench 吻合。 精度标准对标[生态算子开源精度标准(experimental_standard.md)](https://gitcode.com/cann/opbase/blob/master/docs/zh/ops_precision_standard/experimental_standard.md)。 ## 文档更新 - 新增 experimental/activation/swiglu_clamp/README.md(算子说明: 接口/数学/精度/dtype/平台/编译/运行) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!7492 | 6 天前 | |
[activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Co-authored-by: boes129<chenqi185@huawei.com> # message auto-generated for no-merge-commit merge: !7492 merge feature/swiglu_step into master [activation] 新增 experimental 算子 swiglu_clamp + cann_ops_nn PTA binding Created-by: boes129 Commit-by: boes129 Merged-by: cann-robot Description: ## 描述 本 PR 新增 experimental/activation/swiglu_clamp 算子 —— silu+clamp+mul 融合激活(SwigluClamp 顺序: **silu 在前、clamp 上限在后**;区别于本仓现有的 clipped_swiglu 的 clamp-then-silu 顺序)。用于 Step-3.7-Flash 等 MoE 模型的 FFN 专家层激活,已在 910B / 910C 完成端到端推理 + 精度验证。 数学: gate = x[..., :N], up = x[..., N:] out = silu(gate).clamp(max=limit) * up.clamp(min=-limit, max=limit) 输入 x[..., 2N] → 输出 [..., N],dtype 同输入;limit 为标量属性(默认 7.0)。中间升 fp32 计算,store 前降精度。 **交付件**(对齐 experimental/activation/mish 模板): | 目录 | 内容 | | --------------- | ------------------------------------------------------------ | | op_host/ | OpDef 注册 + InferShape(末维减半,奇数拒绝) + Tiling(dtype-aware bufferCoefficient) | | op_kernel/ | AscendC 实现: sigmoid / silu / clamp(Mins/Maxs) / Mul,中间升 fp32,bf16/fp16 经 Cast 路径,bf16 同 else 分支 | | op_api/aclnn/ | 两段式接口(.cpp/.h),ACLNN_CMD dlsym,无需头 include | | tests/ut/ | op_host: Infershape 5 case + Tiling 3 dtype; op_kernel: 1 case(gen_data/compare_data,rtol=1e-4,tikicpulib CPU 仿真); 910B / 910C 双 SoC 均 5/5 + 1/1 PASS | | examples/ | ACLNN 调用示例(bf16 + fp32) | | README.md | 算子说明(接口/数学/精度/dtype/平台) | **附带 torch_extension/cann_ops_nn PTA binding**: - csrc/activation/swiglu_clamp.cpp: ACLNN_CMD + PYBIND11,torch.ops.cann_ops_nn.swiglu_clamp 调用链 - ops/activation/swiglu_clamp.py: OpBuilder schema + register_meta(末维减半) + PrivateUse1 - ops/__init__.py: 注册链 from . import activation ## 关联的Issue https://gitcode.com/cann/ops-nn/issues/3913 ## 测试 **双 SoC 真机验证**(910B + 910C,均通过 SIG 评审前全量验证): | 验证项 | 910B(AT800T,CANN 9.0.1) | 910C(Atlas A3 / AT900A3,CANN 9.0.0) | | ------------------------------------------------ | ------------------------------ | ------------------------------------------- | | 编译 / 安装(--experimental) | ✅ | ✅(交叉编译 ascend910_93 kernel,3 个 .o) | | ophost UT(infershape + tiling) | ✅ 5/5 | ✅ 5/5 | | op_kernel UT(tikicpulib CPU 仿真,fp32,rtol=1e-4) | ✅ 1/1 | ✅ 1/1 | | ACLNN example(端到端) | ✅ bf16 / fp32 / fp16 | ✅ bf16 / fp32 | | PTA binding torch.ops.cann_ops_nn.swiglu_clamp | ✅ [4,32]→[4,16] + clamp 定点 | ✅ 同 | **双 SoC 输出逐位一致**:910B / 910C 的 aclnn example 共享定点 result[22] 完全相同 —— **bf16 -2.859375、fp32 -2.857722**(= 手算 silu(3) × clamp(-1,±7) = 2.857722 × (-1)),两 SoC 分毫不差,跨平台数值行为确定、无 SoC 相关偏移。 **精度**(60 case = 5 shape × 4 输入模式 × 3 dtype,主矩阵在 910B,910C 定点逐位复验): - BFLOAT16(Step-3.7 实际使用 dtype):**20/20 全 PASS**(MERE+MARE) - FLOAT32:**20/20 全 PASS**(近乎精确,MERE ~1e-8) - FLOAT16:20/20 MERE PASS;MARE 15 case 超标 → 根因 IEEE 754 fp16 denormal 表示极限(silu(深负gate) 下溢到 ~1e-8),**非算子缺陷**;过滤 ~1% 病态点后 MARE 4.88e-4 低于单倍阈值,达标 **性能**(详见 swiglu_clamp-performance-report.md):融合算子相对 torch 拆开(silu+clamp+clamp+mul,~4 个 aclnn)—— bf16 prefill(eager 大档)**5.4–7.5×**、decode(graph)**2.1–3.6×**;端到端 msprof 实测 prefill bf16 **6.20×**,与算子级 bench 吻合。 精度标准对标[生态算子开源精度标准(experimental_standard.md)](https://gitcode.com/cann/opbase/blob/master/docs/zh/ops_precision_standard/experimental_standard.md)。 ## 文档更新 - 新增 experimental/activation/swiglu_clamp/README.md(算子说明: 接口/数学/精度/dtype/平台/编译/运行) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!7492 | 6 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 6 天前 | ||
| 6 天前 | ||
| 6 天前 | ||
| 6 天前 |