| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[Feature][ops]Add norm_rope_concat fused operator Co-authored-by: zhangtian6691844<zhangtiantian5@huawei.com> # message auto-generated for no-merge-commit merge: !455 merge feat/norm_rope_concat_dev into dev [Feature][ops]Add norm_rope_concat fused operator Created-by: zhangtian6691844 Commit-by: zhangtian6691844 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20251224 --> # Which issue(s) this PR fixes or accomplishes > **如问题已解决,按照下方示例附上ISSUE单号 / Apply bug or request issue as follow if the solved**\ > Fixes #ISSUE ID\ > **Fixes关键字会自动关闭issue,如问题部分解决请不要使用Fixes,可以用下方标签替代\ > Fixes will automatically close issue, please use the following tag if only part of the issue is solved**\ > Fix part of #ISSUE ID N/A — 新增特性,非问题修复。 # Purpose 为 MindIE-SD 新增 **NormRopeConcat 融合算子**,将三个高频操作(LayerNorm/RMSNorm、RoPE 旋转位置编码、KV Concat)融合为一个 AscendC 自定义算子,减少显存访问次数和 kernel launch 开销,提升大模型推理性能。 **算子功能:** - 对 Query/Key 输入执行 LayerNorm 或 RMSNorm(可选 affine) - 对 Query/Key 执行 RoPE 旋转位置编码(支持 interleave / half 两种模式) - 将 encoder KV 与当前 KV concat 拼接(支持 encoder 在前或在后) - 支持训练模式,输出 norm 的 mean/rstd 用于反向传播 - 支持 16 个输入、11 个输出,全部可选张量自动处理 **变更范围(18 files, +3819/-6 lines):** | 模块 | 文件 | 说明 | |------|------|------| | AscendC Host | csrc/ops/norm_rope_concat/op_host/ (6 files) | 算子定义、Shape/Dtype 推导、Tiling 策略 | | AscendC Kernel | csrc/ops/norm_rope_concat/op_kernel/ (4 files) | NPU 核函数实现 | | PyTorch 插件 | csrc/plugin/norm_rope_concat.{cpp,h} (2 files) | 插件适配层,调用 ACLNN 接口 | | 构建集成 | build/build_ops.sh, csrc/CMakeLists.txt, csrc/plugin/register_ops.cpp | 算子注册与编译 | | 单元测试 | tests/ops/norm_rope_concat/ (3 files) | Python 功能测试 + C++ Kernel UT | # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. **编译验证** - AscendC 算子编译(ascend910_93 / ascend910b / ascend950 三芯片) - PyTorch 插件编链(libPTAExtensionOPS.so) - 构建环境:CANN 9.1.T560 + bisheng + PyTorch 2.x 2. **单元测试(Python)** - test_norm_rope_concat.py:覆盖 norm_type (NONE/LAYER_NORM/RMS_NORM)、rope_type (NONE/INTERLEAVE/HALF)、concat_order (BEFORE/AFTER)、训练模式等组合 - run_simple_test.py:快速冒烟测试 3. **C++ Kernel UT** - test_norm_rope_concat_kernel.cpp:验证 Tiling 数据传递与 kernel 逻辑正确性 4. **回归验证** - 已有算子(LA、AdaLA、RainFusionAttention 等)编译不受影响 - build_ops.sh 中 norm_rope_concat 作为 ascendc_ops 之一参与构建 # Test Report | 测试项 | 芯片 | 结果 | |--------|------|------| | AscendC 编译 (op_host_aclnn) | - | ✅ PASS | | AscendC 编译 (opsproto) | - | ✅ PASS | | AscendC 编译 (optiling) | - | ✅ PASS | | AscendC Kernel 生成 | ascend910_93 | ✅ PASS | | AscendC Kernel 生成 | ascend910b | ✅ PASS | | AscendC Kernel 生成 | ascend950 | ✅ PASS | | CANN-custom_ops .run 打包 | - | ✅ PASS | | PyTorch 插件编译链接 | - | ✅ PASS (100%) | | 已有算子兼容性 | - | ✅ 无影响 | **测试环境:** CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 See merge request: Ascend/MindIE-SD!455 | 12 天前 | |
[Feature][ops]Add norm_rope_concat fused operator Co-authored-by: zhangtian6691844<zhangtiantian5@huawei.com> # message auto-generated for no-merge-commit merge: !455 merge feat/norm_rope_concat_dev into dev [Feature][ops]Add norm_rope_concat fused operator Created-by: zhangtian6691844 Commit-by: zhangtian6691844 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20251224 --> # Which issue(s) this PR fixes or accomplishes > **如问题已解决,按照下方示例附上ISSUE单号 / Apply bug or request issue as follow if the solved**\ > Fixes #ISSUE ID\ > **Fixes关键字会自动关闭issue,如问题部分解决请不要使用Fixes,可以用下方标签替代\ > Fixes will automatically close issue, please use the following tag if only part of the issue is solved**\ > Fix part of #ISSUE ID N/A — 新增特性,非问题修复。 # Purpose 为 MindIE-SD 新增 **NormRopeConcat 融合算子**,将三个高频操作(LayerNorm/RMSNorm、RoPE 旋转位置编码、KV Concat)融合为一个 AscendC 自定义算子,减少显存访问次数和 kernel launch 开销,提升大模型推理性能。 **算子功能:** - 对 Query/Key 输入执行 LayerNorm 或 RMSNorm(可选 affine) - 对 Query/Key 执行 RoPE 旋转位置编码(支持 interleave / half 两种模式) - 将 encoder KV 与当前 KV concat 拼接(支持 encoder 在前或在后) - 支持训练模式,输出 norm 的 mean/rstd 用于反向传播 - 支持 16 个输入、11 个输出,全部可选张量自动处理 **变更范围(18 files, +3819/-6 lines):** | 模块 | 文件 | 说明 | |------|------|------| | AscendC Host | csrc/ops/norm_rope_concat/op_host/ (6 files) | 算子定义、Shape/Dtype 推导、Tiling 策略 | | AscendC Kernel | csrc/ops/norm_rope_concat/op_kernel/ (4 files) | NPU 核函数实现 | | PyTorch 插件 | csrc/plugin/norm_rope_concat.{cpp,h} (2 files) | 插件适配层,调用 ACLNN 接口 | | 构建集成 | build/build_ops.sh, csrc/CMakeLists.txt, csrc/plugin/register_ops.cpp | 算子注册与编译 | | 单元测试 | tests/ops/norm_rope_concat/ (3 files) | Python 功能测试 + C++ Kernel UT | # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. **编译验证** - AscendC 算子编译(ascend910_93 / ascend910b / ascend950 三芯片) - PyTorch 插件编链(libPTAExtensionOPS.so) - 构建环境:CANN 9.1.T560 + bisheng + PyTorch 2.x 2. **单元测试(Python)** - test_norm_rope_concat.py:覆盖 norm_type (NONE/LAYER_NORM/RMS_NORM)、rope_type (NONE/INTERLEAVE/HALF)、concat_order (BEFORE/AFTER)、训练模式等组合 - run_simple_test.py:快速冒烟测试 3. **C++ Kernel UT** - test_norm_rope_concat_kernel.cpp:验证 Tiling 数据传递与 kernel 逻辑正确性 4. **回归验证** - 已有算子(LA、AdaLA、RainFusionAttention 等)编译不受影响 - build_ops.sh 中 norm_rope_concat 作为 ascendc_ops 之一参与构建 # Test Report | 测试项 | 芯片 | 结果 | |--------|------|------| | AscendC 编译 (op_host_aclnn) | - | ✅ PASS | | AscendC 编译 (opsproto) | - | ✅ PASS | | AscendC 编译 (optiling) | - | ✅ PASS | | AscendC Kernel 生成 | ascend910_93 | ✅ PASS | | AscendC Kernel 生成 | ascend910b | ✅ PASS | | AscendC Kernel 生成 | ascend950 | ✅ PASS | | CANN-custom_ops .run 打包 | - | ✅ PASS | | PyTorch 插件编译链接 | - | ✅ PASS (100%) | | 已有算子兼容性 | - | ✅ 无影响 | **测试环境:** CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 See merge request: Ascend/MindIE-SD!455 | 12 天前 |