| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Co-authored-by: hanrui22<hanrui2@huawei.com> # message auto-generated for no-merge-commit merge: !590 merge master into master 上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Created-by: hanrui22 Commit-by: hanrui22 Merged-by: cann-robot Description: ## 描述 新增性能优化工作流,完成对element、 broadcast 和reduce类算子进行性能优化。 支持的CLI: opencode 和 claudecode 支持的模型: GLM5_2 OPUS4.8 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/413 ## 测试 当前从element、 broadcast 和reduce类算子中,选择了3个算子做性能优化。基线代码目录: exp(element-wise) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/exp 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Exp | 1.00x | 3.50x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 11.54 | 10.94 | 3.94 | 1.05x | 2.93x | 2.78x | OK | | 2 | 2048x2048 | float32 | 25.62 | 34.60 | 11.01 | 0.74x | 2.33x | 3.14x | OK | | 3 | 4096x4096 | bfloat16 | 45.97 | 130.96 | 22.75 | 0.35x | 2.02x | 5.76x | OK | | 4 | 8192x8192 | float16 | 385.66 | 513.94 | 77.24 | 0.75x | 4.99x | 6.65x | OK | | 5 | 8192x8192 | float32 | 1466.84 | 495.46 | 152.35 | 2.96x | 9.63x | 3.25x | OK | | 6 | 1023x1023 | bfloat16 | 14.33 | 11.39 | 4.33 | 1.26x | 3.31x | 2.63x | OK | | 7 | 1009x1021 | float16 | 72.19 | 10.74 | 4.16 | 6.72x | 17.35x | 2.58x | OK | | 8 | 1537x769 | float32 | 93.43 | 12.33 | 4.65 | 7.58x | 20.09x | 2.65x | OK | | 9 | 363x367x373 | bfloat16 | 185.28 | 378.45 | 59.84 | 0.49x | 3.10x | 6.32x | OK | | 10 | 2049x513 | float16 | 10.00 | 11.17 | 4.05 | 0.90x | 2.47x | 2.76x | OK | | 11 | 3x7x13x4003 | float32 | 10.88 | 11.46 | 4.47 | 0.95x | 2.43x | 2.56x | OK | | 12 | 1000007 | bfloat16 | 9.98 | 11.26 | 4.24 | 0.89x | 2.35x | 2.66x | OK | | 13 | 11x13x17x67x67 | float32 | 66.65 | 83.51 | 25.27 | 0.80x | 2.64x | 3.30x | OK | | 14 | 3x7x11x13x1013 | float16 | 14.09 | 26.21 | 5.87 | 0.54x | 2.40x | 4.47x | OK | | 15 | 512x2049 | float32 | 10.73 | 11.25 | 4.60 | 0.95x | 2.33x | 2.45x | OK | | 16 | 255x8193 | bfloat16 | 13.04 | 19.37 | 5.16 | 0.67x | 2.53x | 3.75x | OK | | 17 | 4097x511 | float16 | 13.44 | 18.87 | 4.78 | 0.71x | 2.81x | 3.95x | OK | | 18 | 2x511x2049 | float32 | 20.22 | 19.10 | 6.24 | 1.06x | 3.24x | 3.06x | OK | | 19 | 4x255x2049 | bfloat16 | 16.52 | 19.51 | 5.17 | 0.85x | 3.20x | 3.77x | OK | | 20 | 2x3x17x1024x101 | float16 | 30.96 | 82.74 | 14.82 | 0.37x | 2.09x | 5.58x | OK | > 基线代码几何平均加速比 1.00x(与 A5 官方基线持平),优化后达 3.50x(大幅超越 A5 官方基线),整体提升 **3.51 倍**(优化后 vs 基线几何平均加速比) maxinum (broadcast) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/maximum_base 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Maximum | 0.61x | 1.09x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | (1024,1024) | float16 | 5.82 | 5.88 | 5.83 | 0.99x | 0.99x | 1.01x | OK | | 2 | (2048,2048) | float32 | 27.16 | 24.25 | 26.69 | 1.12x | 1.01x | 0.91x | OK | | 3 | (4096,4096) | bfloat16 | 47.83 | 45.55 | 47.60 | 1.05x | 1.01x | 0.96x | OK | | 4 | (8192,8192) | int32 | 521.01 | 521.01 | 517.65 | 1.00x | 1.01x | 1.01x | OK | | 5 | (4096,4096) | int64 | 254.51 | 247.10 | 245.19 | 1.03x | 1.04x | 1.01x | OK | | 6 | (8192,16384) | int8 | 250.65 | 245.74 | 247.35 | 1.02x | 1.02x | 0.99x | OK | | 7 | (1023,1023) | float16 | 6.57 | 5.76 | 5.60 | 1.14x | 1.17x | 1.03x | OK | | 8 | (1009,1021) | float32 | 10.76 | 8.41 | 8.58 | 1.28x | 1.26x | 0.98x | OK | | 9 | (1537,769) | bfloat16 | 8.44 | 6.16 | 7.70 | 1.37x | 1.10x | 0.80x | OK | | 10 | (363,367,373) | float16 | 174.22 | 172.50 | 170.52 | 1.01x | 1.02x | 1.01x | OK | | 11 | (2049,513) / (1,513) | float32 | 9.36 | 19.11 | 6.47 | 0.49x | 1.44x | 2.95x | OK | | 12 | (3,127,687,37) / (1,1,687,1) | float32 | 25.27 | 2526.84 | 29.07 | 0.01x | 1.11x | 86.92x | OK | | 13 | (2,3,5,1024,256) / (1,1,1,1024,1) | int32 | 27.47 | 343.43 | 24.40 | 0.08x | 1.07x | 14.08x | OK | | 14 | (1000007,) | float32 | 10.18 | 7.89 | 8.47 | 1.29x | 1.21x | 0.93x | OK | | 15 | (11,13,17,67,67) | float16 | 31.20 | 30.89 | 31.59 | 1.01x | 0.99x | 0.98x | OK | | 16 | (3,7,11,13,1013) | float32 | 21.37 | 18.91 | 19.65 | 1.13x | 1.09x | 0.96x | OK | | 17 | (512,2049) | bfloat16 | 7.83 | 5.76 | 7.32 | 1.36x | 1.07x | 0.79x | OK | | 18 | (255,8193) / (8193,) | float16 | 11.73 | 6.34 | 11.78 | 1.85x | 0.99x | 0.54x | OK | | 19 | (4097,511) / (1,511) | int64 | 17.92 | 33.82 | 15.34 | 0.53x | 1.17x | 2.20x | OK | | 20 | (2,3,17,1024,101) / (1,1,1,1024,1) | float32 | 33.87 | 1129.04 | 31.37 | 0.03x | 1.10x | 35.99x | OK | > 基线代码几何平均加速比 0.61x(低于 A5 官方基线),优化后达 1.09x(超越 A5 官方基线),整体提升 **1.75 倍**(优化后 vs 基线几何平均加速比) softmax (reduce) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/softmax 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Softmax | 0.180x | 1.005x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 5.51 | 13.96 | 5.67 | 0.39x | 0.97x | 2.46x | OK | | 2 | 2048x2048 | float32 | 15.89 | 28.82 | 14.19 | 0.55x | 1.12x | 2.03x | OK | | 3 | 4096x4096 | bfloat16 | 30.50 | 63.46 | 26.70 | 0.48x | 1.14x | 2.38x | OK | | 4 | 8192x8192 | float16 | 171.99 | 11663.06 | 234.77 | 0.01x | 0.73x | 49.68x | OK | | 5 | 8192x8192 | float32 | 389.94 | 336.40 | 321.08 | 1.16x | 1.21x | 1.05x | OK | | 6 | 31x67x127x257 | bfloat16 | 207.12 | 1135.66 | 209.41 | 0.18x | 0.99x | 5.42x | OK | | 7 | 1023x2047 | float16 | 8.28 | 16.52 | 7.97 | 0.50x | 1.04x | 2.07x | OK | | 8 | 2049x4097 | float32 | 29.56 | 39.66 | 25.74 | 0.75x | 1.15x | 1.54x | OK | | 9 | 127x257x1023 | bfloat16 | 74.47 | 698.65 | 92.55 | 0.11x | 0.80x | 7.55x | OK | | 10 | 1009x1021 | float16 | 5.66 | 14.80 | 5.96 | 0.38x | 0.95x | 2.48x | OK | | 11 | 367x373x379 | float32 | 297.98 | 2397.48 | 318.73 | 0.12x | 0.93x | 7.52x | OK | | 12 | 11x13x17x4001 | bfloat16 | 19.49 | 40.34 | 18.20 | 0.48x | 1.07x | 2.22x | OK | | 13 | 1000003x2 | float16 | 20.23 | 4730.31 | 16.77 | 0.00x | 1.21x | 282.07x | OK | | 14 | 11x13x17x67x67 | float32 | 51.87 | 1384.35 | 40.73 | 0.04x | 1.27x | 33.99x | OK | | 15 | 3x7x11x13x1013 | bfloat16 | 9.90 | 35.46 | 9.54 | 0.28x | 1.04x | 3.72x | OK | | 16 | 512x2049 | float16 | 5.93 | 75.30 | 8.47 | 0.08x | 0.70x | 8.89x | OK | | 17 | 255x8193 | float32 | 9.12 | 13.51 | 9.19 | 0.68x | 0.99x | 1.47x | OK | | 18 | 2x511x2049 | bfloat16 | 8.19 | 16.69 | 7.51 | 0.49x | 1.09x | 2.22x | OK | | 19 | 4x255x2049 | float16 | 8.30 | 77.33 | 8.69 | 0.11x | 0.96x | 8.90x | OK | | 20 | 2x3x17x1024x101 | float32 | 51.30 | 1478.12 | 53.58 | 0.03x | 0.96x | 27.59x | OK | > 基线代码几何平均加速比 0.180x(远低于 A5 官方基线),优化后达 1.005x(追平 A5 官方基线),整体提升 **5.58 倍**(优化后 vs 基线几何平均加速比)。 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [ ] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/cannbot-skills!590 | 12 天前 | |
feat: 新增 MC² 通算融合算子性能优化能力 Co-authored-by: yufang<yufang11@huawei.com> # message auto-generated for no-merge-commit merge: !656 merge mc2perf_skill into master feat: 新增 MC² 通算融合算子性能优化能力 Created-by: yufang11 Commit-by: yufang Merged-by: cann-robot Description: ## 描述 为 ops-perf-optimize 插件新增 MC² 通算融合算子(通信+计算融合)的完整性能优化能力,覆盖从数据采集、Bound 诊断、流水配平搜索到方案实施的全流程。 新增能力: - 隔离测试与 Bound 诊断:通过 tileCnt=1 下注释通信/计算 process,实测 T_comm 和 T_compute,计算 R 值精确判定 Bound 类型(计算 Bound / 通信 Bound / 完美平衡) - Local Matmul 策略:将本 rank 数据(无需通信)的 matmul 独立前置/后置执行,与首次通信重叠,隐藏通信延迟 - 流水配平系统搜索:基于 TilingData(baseM/baseN/usedCoreNum)和 R 值,在配平可行域内执行四条剪枝规则的系统搜索,输出 Top-N 候选切分方案供 msprof 实测择优 - 膨胀分析:评估切分粒度对计算膨胀(流水中断、核利用率)和通信膨胀(头开销、带宽)的影响 - 均分切分兜底算法:当缺少隔离测试数据时,提供满核+最多切分的稳健基线 - MC² 实现层设计指南:提供 TilingData 结构、Host 侧搜索代码、AIC/AIV 核心循环、长短块切换同步等实施细节 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/456 ## 测试 在 Ascend 950 (dav-3510) 4P 环境下完成两个 MC² 算子的端到端调优验证: ### allgather_matmul(AllGather + MXFP8 量化 Matmul,12 cases): - 最佳方案:Local Matmul + 流水配平,几何平均加速比 1.44x,12/12 case 全部提升 - 最佳单 case 加速比 1.72x(m=4040, n=2560) - 掩盖率:计算 Bound 组均值 0.82,强计算 Bound 组均值 0.90 - 精度验证:36/36 PASS MC² allgather_matmul 性能指标(加速比与掩盖率) > 基于 Step 1 隔离测试的 T_comm / T_compute,按 /ascendc-perf-optimize 的 comm-compute/index.md 性能指标公式核算。 > 加速比 = 基线T / 优化后T;掩盖率 = (基线T - 优化后T) / min(T_comm, T_compute) | Case | 基线T(us) | T_comm(us) | T_compute(us) | min(T_comm,T_compute) | 方案1最优T(us) | 加速比 | 掩盖率 | |------|---------|----------|-------------|---------------------|-------------|--------|--------| | 1 | 233.20 | 111.48 | 126.28 | 111.48 | 155.84 | 1.50 | 0.69 | | 2 | 432.55 | 111.82 | 325.01 | 111.82 | 330.07 | 1.31 | 0.92 | | 3 | 466.61 | 213.30 | 257.75 | 213.30 | 287.65 | 1.62 | 0.84 | | 4 | 855.15 | 211.85 | 652.39 | 211.85 | 656.56 | 1.30 | 0.94 | | 5 | 504.60 | 232.51 | 275.22 | 232.51 | 314.27 | 1.61 | 0.82 | | 6 | 918.71 | 234.88 | 698.50 | 234.88 | 721.73 | 1.27 | 0.84 | | 7 | 565.84 | 262.03 | 307.41 | 262.03 | 355.04 | 1.59 | 0.80 | | 8 | 1048.28 | 263.69 | 793.80 | 263.69 | 819.71 | 1.28 | 0.87 | | 9 | 699.20 | 311.39 | 401.63 | 311.39 | 408.32 | 1.71 | 0.93 | | 10 | 1248.26 | 314.20 | 947.37 | 314.20 | 940.22 | 1.33 | 0.98 | | 11 | 893.35 | 395.76 | 503.94 | 395.76 | 518.31 | 1.72 | 0.95 | | 12 | 1597.91 | 396.57 | 1213.94 | 396.57 | 1262.62 | 1.27 | 0.85 | > Group A(compute bound)平均掩盖率 0.82,Group B(strong_compute bound)平均掩盖率 0.90。Group B 掩盖率更高因为通信时间小(T_comm << T_compute),min(T_comm, T_compute)=T_comm,而优化节省的绝对时间占 T_comm 比例大,通信几乎被完全掩盖。 ### all_to_all_matmul(AllToAll + MXFP8 Matmul,6 cases): - 最佳方案:流水配平 + Local Matmul,几何平均加速比 1.15x,6/6 case 全部提升 - 最佳单 case 加速比 1.27x(m=2080) - 掩盖率从基线均值 34.6% 提升至 66.9%(+32pp) - 精度验证:18/18 PASS #### 基线性能指标 | Case | m | 融合前(us) | 基线TaskDur(us) | 基线加速比 | 基线掩盖率 | |------|---|-----------|----------------|-----------|-----------| | 1 | 2624 | 387.117 | 345.614 | 1.1200 | 0.2983 | | 2 | 3136 | 456.656 | 397.613 | 1.1485 | 0.3652 | | 3 | 4096 | 589.386 | 486.867 | 1.2107 | 0.4939 | | 4 | 2080 | 318.524 | 289.713 | 1.0994 | 0.2500 | | 5 | 1010 | 167.587 | 149.285 | 1.1225 | 0.2897 | | 6 | 2304 | 342.614 | 295.048 | 1.1612 | 0.3822 | #### Opt2(最佳方案)性能指标 | Case | m | 融合前(us) | Opt2 TaskDur(us) | Opt2 加速比(vs融合前) | Opt2 加速比(vs基线) | Opt2 掩盖率 | |------|---|-----------|-----------------|---------------------|-------------------|------------| | 1 | 2624 | 387.117 | 304.701 | 1.2704 | 1.1343 | 0.5924 | | 2 | 3136 | 456.656 | 334.422 | 1.3654 | 1.1890 | 0.7549 | | 3 | 4096 | 589.386 | 432.327 | 1.3633 | 1.1262 | 0.7552 | | 4 | 2080 | 318.524 | 227.819 | 1.3982 | 1.2717 | 0.7864 | | 5 | 1010 | 167.587 | 131.946 | 1.2702 | 1.1314 | 0.5639 | | 6 | 2304 | 342.614 | 272.749 | 1.2562 | 1.0818 | 0.5608 | #### Opt3 性能指标 | Case | m | 融合前(us) | Opt3 TaskDur(us) | Opt3 加速比(vs融合前) | Opt3 加速比(vs基线) | Opt3 掩盖率 | |------|---|-----------|-----------------|---------------------|-------------------|------------| | 1 | 2624 | 387.117 | 305.450 | 1.2672 | 1.1315 | 0.5870 | | 2 | 3136 | 456.656 | 348.026 | 1.3124 | 1.1425 | 0.6711 | | 3 | 4096 | 589.386 | 435.876 | 1.3522 | 1.1170 | 0.7381 | | 4 | 2080 | 318.524 | 251.150 | 1.2683 | 1.1535 | 0.5841 | | 5 | 1010 | 167.587 | 125.811 | 1.3321 | 1.1866 | 0.6606 | | 6 | 2304 | 342.614 | 256.114 | 1.3377 | 1.1520 | 0.6948 | **alltoallMatmul 掩盖率提升**: - 基线掩盖率:25%~49%(平均 34.6%) - Opt2 掩盖率:56%~79%(平均 66.9%),提升约 32 个百分点 - Opt3 掩盖率:58%~74%(平均 65.6%),提升约 31 个百分点 ## 文档更新 无需额外文档更新,变更本身即为 skill 文档 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [x] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: ## 流水线故障排查 <!-- 如果下方的流水线检查未通过,可参考以下指引进行自助修复 --> > **UT_Test 未通过?** > 请在下方流水线表格的 **UT_Test** 行,点击右侧的 >>>>> 下载 **CANNBot-skills UT 测试报告**(HTML 格式)。 > 打开报告后,展开页面中的「UT Test 失败修复指南」,复制其中的提示词并粘贴给 Agent,Agent 将根据日志自动定位并修复问题。 > > 示例: >  See merge request: cann/cannbot-skills!656 | 2 天前 | |
上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Co-authored-by: hanrui22<hanrui2@huawei.com> # message auto-generated for no-merge-commit merge: !590 merge master into master 上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Created-by: hanrui22 Commit-by: hanrui22 Merged-by: cann-robot Description: ## 描述 新增性能优化工作流,完成对element、 broadcast 和reduce类算子进行性能优化。 支持的CLI: opencode 和 claudecode 支持的模型: GLM5_2 OPUS4.8 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/413 ## 测试 当前从element、 broadcast 和reduce类算子中,选择了3个算子做性能优化。基线代码目录: exp(element-wise) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/exp 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Exp | 1.00x | 3.50x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 11.54 | 10.94 | 3.94 | 1.05x | 2.93x | 2.78x | OK | | 2 | 2048x2048 | float32 | 25.62 | 34.60 | 11.01 | 0.74x | 2.33x | 3.14x | OK | | 3 | 4096x4096 | bfloat16 | 45.97 | 130.96 | 22.75 | 0.35x | 2.02x | 5.76x | OK | | 4 | 8192x8192 | float16 | 385.66 | 513.94 | 77.24 | 0.75x | 4.99x | 6.65x | OK | | 5 | 8192x8192 | float32 | 1466.84 | 495.46 | 152.35 | 2.96x | 9.63x | 3.25x | OK | | 6 | 1023x1023 | bfloat16 | 14.33 | 11.39 | 4.33 | 1.26x | 3.31x | 2.63x | OK | | 7 | 1009x1021 | float16 | 72.19 | 10.74 | 4.16 | 6.72x | 17.35x | 2.58x | OK | | 8 | 1537x769 | float32 | 93.43 | 12.33 | 4.65 | 7.58x | 20.09x | 2.65x | OK | | 9 | 363x367x373 | bfloat16 | 185.28 | 378.45 | 59.84 | 0.49x | 3.10x | 6.32x | OK | | 10 | 2049x513 | float16 | 10.00 | 11.17 | 4.05 | 0.90x | 2.47x | 2.76x | OK | | 11 | 3x7x13x4003 | float32 | 10.88 | 11.46 | 4.47 | 0.95x | 2.43x | 2.56x | OK | | 12 | 1000007 | bfloat16 | 9.98 | 11.26 | 4.24 | 0.89x | 2.35x | 2.66x | OK | | 13 | 11x13x17x67x67 | float32 | 66.65 | 83.51 | 25.27 | 0.80x | 2.64x | 3.30x | OK | | 14 | 3x7x11x13x1013 | float16 | 14.09 | 26.21 | 5.87 | 0.54x | 2.40x | 4.47x | OK | | 15 | 512x2049 | float32 | 10.73 | 11.25 | 4.60 | 0.95x | 2.33x | 2.45x | OK | | 16 | 255x8193 | bfloat16 | 13.04 | 19.37 | 5.16 | 0.67x | 2.53x | 3.75x | OK | | 17 | 4097x511 | float16 | 13.44 | 18.87 | 4.78 | 0.71x | 2.81x | 3.95x | OK | | 18 | 2x511x2049 | float32 | 20.22 | 19.10 | 6.24 | 1.06x | 3.24x | 3.06x | OK | | 19 | 4x255x2049 | bfloat16 | 16.52 | 19.51 | 5.17 | 0.85x | 3.20x | 3.77x | OK | | 20 | 2x3x17x1024x101 | float16 | 30.96 | 82.74 | 14.82 | 0.37x | 2.09x | 5.58x | OK | > 基线代码几何平均加速比 1.00x(与 A5 官方基线持平),优化后达 3.50x(大幅超越 A5 官方基线),整体提升 **3.51 倍**(优化后 vs 基线几何平均加速比) maxinum (broadcast) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/maximum_base 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Maximum | 0.61x | 1.09x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | (1024,1024) | float16 | 5.82 | 5.88 | 5.83 | 0.99x | 0.99x | 1.01x | OK | | 2 | (2048,2048) | float32 | 27.16 | 24.25 | 26.69 | 1.12x | 1.01x | 0.91x | OK | | 3 | (4096,4096) | bfloat16 | 47.83 | 45.55 | 47.60 | 1.05x | 1.01x | 0.96x | OK | | 4 | (8192,8192) | int32 | 521.01 | 521.01 | 517.65 | 1.00x | 1.01x | 1.01x | OK | | 5 | (4096,4096) | int64 | 254.51 | 247.10 | 245.19 | 1.03x | 1.04x | 1.01x | OK | | 6 | (8192,16384) | int8 | 250.65 | 245.74 | 247.35 | 1.02x | 1.02x | 0.99x | OK | | 7 | (1023,1023) | float16 | 6.57 | 5.76 | 5.60 | 1.14x | 1.17x | 1.03x | OK | | 8 | (1009,1021) | float32 | 10.76 | 8.41 | 8.58 | 1.28x | 1.26x | 0.98x | OK | | 9 | (1537,769) | bfloat16 | 8.44 | 6.16 | 7.70 | 1.37x | 1.10x | 0.80x | OK | | 10 | (363,367,373) | float16 | 174.22 | 172.50 | 170.52 | 1.01x | 1.02x | 1.01x | OK | | 11 | (2049,513) / (1,513) | float32 | 9.36 | 19.11 | 6.47 | 0.49x | 1.44x | 2.95x | OK | | 12 | (3,127,687,37) / (1,1,687,1) | float32 | 25.27 | 2526.84 | 29.07 | 0.01x | 1.11x | 86.92x | OK | | 13 | (2,3,5,1024,256) / (1,1,1,1024,1) | int32 | 27.47 | 343.43 | 24.40 | 0.08x | 1.07x | 14.08x | OK | | 14 | (1000007,) | float32 | 10.18 | 7.89 | 8.47 | 1.29x | 1.21x | 0.93x | OK | | 15 | (11,13,17,67,67) | float16 | 31.20 | 30.89 | 31.59 | 1.01x | 0.99x | 0.98x | OK | | 16 | (3,7,11,13,1013) | float32 | 21.37 | 18.91 | 19.65 | 1.13x | 1.09x | 0.96x | OK | | 17 | (512,2049) | bfloat16 | 7.83 | 5.76 | 7.32 | 1.36x | 1.07x | 0.79x | OK | | 18 | (255,8193) / (8193,) | float16 | 11.73 | 6.34 | 11.78 | 1.85x | 0.99x | 0.54x | OK | | 19 | (4097,511) / (1,511) | int64 | 17.92 | 33.82 | 15.34 | 0.53x | 1.17x | 2.20x | OK | | 20 | (2,3,17,1024,101) / (1,1,1,1024,1) | float32 | 33.87 | 1129.04 | 31.37 | 0.03x | 1.10x | 35.99x | OK | > 基线代码几何平均加速比 0.61x(低于 A5 官方基线),优化后达 1.09x(超越 A5 官方基线),整体提升 **1.75 倍**(优化后 vs 基线几何平均加速比) softmax (reduce) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/softmax 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Softmax | 0.180x | 1.005x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 5.51 | 13.96 | 5.67 | 0.39x | 0.97x | 2.46x | OK | | 2 | 2048x2048 | float32 | 15.89 | 28.82 | 14.19 | 0.55x | 1.12x | 2.03x | OK | | 3 | 4096x4096 | bfloat16 | 30.50 | 63.46 | 26.70 | 0.48x | 1.14x | 2.38x | OK | | 4 | 8192x8192 | float16 | 171.99 | 11663.06 | 234.77 | 0.01x | 0.73x | 49.68x | OK | | 5 | 8192x8192 | float32 | 389.94 | 336.40 | 321.08 | 1.16x | 1.21x | 1.05x | OK | | 6 | 31x67x127x257 | bfloat16 | 207.12 | 1135.66 | 209.41 | 0.18x | 0.99x | 5.42x | OK | | 7 | 1023x2047 | float16 | 8.28 | 16.52 | 7.97 | 0.50x | 1.04x | 2.07x | OK | | 8 | 2049x4097 | float32 | 29.56 | 39.66 | 25.74 | 0.75x | 1.15x | 1.54x | OK | | 9 | 127x257x1023 | bfloat16 | 74.47 | 698.65 | 92.55 | 0.11x | 0.80x | 7.55x | OK | | 10 | 1009x1021 | float16 | 5.66 | 14.80 | 5.96 | 0.38x | 0.95x | 2.48x | OK | | 11 | 367x373x379 | float32 | 297.98 | 2397.48 | 318.73 | 0.12x | 0.93x | 7.52x | OK | | 12 | 11x13x17x4001 | bfloat16 | 19.49 | 40.34 | 18.20 | 0.48x | 1.07x | 2.22x | OK | | 13 | 1000003x2 | float16 | 20.23 | 4730.31 | 16.77 | 0.00x | 1.21x | 282.07x | OK | | 14 | 11x13x17x67x67 | float32 | 51.87 | 1384.35 | 40.73 | 0.04x | 1.27x | 33.99x | OK | | 15 | 3x7x11x13x1013 | bfloat16 | 9.90 | 35.46 | 9.54 | 0.28x | 1.04x | 3.72x | OK | | 16 | 512x2049 | float16 | 5.93 | 75.30 | 8.47 | 0.08x | 0.70x | 8.89x | OK | | 17 | 255x8193 | float32 | 9.12 | 13.51 | 9.19 | 0.68x | 0.99x | 1.47x | OK | | 18 | 2x511x2049 | bfloat16 | 8.19 | 16.69 | 7.51 | 0.49x | 1.09x | 2.22x | OK | | 19 | 4x255x2049 | float16 | 8.30 | 77.33 | 8.69 | 0.11x | 0.96x | 8.90x | OK | | 20 | 2x3x17x1024x101 | float32 | 51.30 | 1478.12 | 53.58 | 0.03x | 0.96x | 27.59x | OK | > 基线代码几何平均加速比 0.180x(远低于 A5 官方基线),优化后达 1.005x(追平 A5 官方基线),整体提升 **5.58 倍**(优化后 vs 基线几何平均加速比)。 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [ ] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/cannbot-skills!590 | 12 天前 | |
feat: 新增 MC² 通算融合算子性能优化能力 Co-authored-by: yufang<yufang11@huawei.com> # message auto-generated for no-merge-commit merge: !656 merge mc2perf_skill into master feat: 新增 MC² 通算融合算子性能优化能力 Created-by: yufang11 Commit-by: yufang Merged-by: cann-robot Description: ## 描述 为 ops-perf-optimize 插件新增 MC² 通算融合算子(通信+计算融合)的完整性能优化能力,覆盖从数据采集、Bound 诊断、流水配平搜索到方案实施的全流程。 新增能力: - 隔离测试与 Bound 诊断:通过 tileCnt=1 下注释通信/计算 process,实测 T_comm 和 T_compute,计算 R 值精确判定 Bound 类型(计算 Bound / 通信 Bound / 完美平衡) - Local Matmul 策略:将本 rank 数据(无需通信)的 matmul 独立前置/后置执行,与首次通信重叠,隐藏通信延迟 - 流水配平系统搜索:基于 TilingData(baseM/baseN/usedCoreNum)和 R 值,在配平可行域内执行四条剪枝规则的系统搜索,输出 Top-N 候选切分方案供 msprof 实测择优 - 膨胀分析:评估切分粒度对计算膨胀(流水中断、核利用率)和通信膨胀(头开销、带宽)的影响 - 均分切分兜底算法:当缺少隔离测试数据时,提供满核+最多切分的稳健基线 - MC² 实现层设计指南:提供 TilingData 结构、Host 侧搜索代码、AIC/AIV 核心循环、长短块切换同步等实施细节 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/456 ## 测试 在 Ascend 950 (dav-3510) 4P 环境下完成两个 MC² 算子的端到端调优验证: ### allgather_matmul(AllGather + MXFP8 量化 Matmul,12 cases): - 最佳方案:Local Matmul + 流水配平,几何平均加速比 1.44x,12/12 case 全部提升 - 最佳单 case 加速比 1.72x(m=4040, n=2560) - 掩盖率:计算 Bound 组均值 0.82,强计算 Bound 组均值 0.90 - 精度验证:36/36 PASS MC² allgather_matmul 性能指标(加速比与掩盖率) > 基于 Step 1 隔离测试的 T_comm / T_compute,按 /ascendc-perf-optimize 的 comm-compute/index.md 性能指标公式核算。 > 加速比 = 基线T / 优化后T;掩盖率 = (基线T - 优化后T) / min(T_comm, T_compute) | Case | 基线T(us) | T_comm(us) | T_compute(us) | min(T_comm,T_compute) | 方案1最优T(us) | 加速比 | 掩盖率 | |------|---------|----------|-------------|---------------------|-------------|--------|--------| | 1 | 233.20 | 111.48 | 126.28 | 111.48 | 155.84 | 1.50 | 0.69 | | 2 | 432.55 | 111.82 | 325.01 | 111.82 | 330.07 | 1.31 | 0.92 | | 3 | 466.61 | 213.30 | 257.75 | 213.30 | 287.65 | 1.62 | 0.84 | | 4 | 855.15 | 211.85 | 652.39 | 211.85 | 656.56 | 1.30 | 0.94 | | 5 | 504.60 | 232.51 | 275.22 | 232.51 | 314.27 | 1.61 | 0.82 | | 6 | 918.71 | 234.88 | 698.50 | 234.88 | 721.73 | 1.27 | 0.84 | | 7 | 565.84 | 262.03 | 307.41 | 262.03 | 355.04 | 1.59 | 0.80 | | 8 | 1048.28 | 263.69 | 793.80 | 263.69 | 819.71 | 1.28 | 0.87 | | 9 | 699.20 | 311.39 | 401.63 | 311.39 | 408.32 | 1.71 | 0.93 | | 10 | 1248.26 | 314.20 | 947.37 | 314.20 | 940.22 | 1.33 | 0.98 | | 11 | 893.35 | 395.76 | 503.94 | 395.76 | 518.31 | 1.72 | 0.95 | | 12 | 1597.91 | 396.57 | 1213.94 | 396.57 | 1262.62 | 1.27 | 0.85 | > Group A(compute bound)平均掩盖率 0.82,Group B(strong_compute bound)平均掩盖率 0.90。Group B 掩盖率更高因为通信时间小(T_comm << T_compute),min(T_comm, T_compute)=T_comm,而优化节省的绝对时间占 T_comm 比例大,通信几乎被完全掩盖。 ### all_to_all_matmul(AllToAll + MXFP8 Matmul,6 cases): - 最佳方案:流水配平 + Local Matmul,几何平均加速比 1.15x,6/6 case 全部提升 - 最佳单 case 加速比 1.27x(m=2080) - 掩盖率从基线均值 34.6% 提升至 66.9%(+32pp) - 精度验证:18/18 PASS #### 基线性能指标 | Case | m | 融合前(us) | 基线TaskDur(us) | 基线加速比 | 基线掩盖率 | |------|---|-----------|----------------|-----------|-----------| | 1 | 2624 | 387.117 | 345.614 | 1.1200 | 0.2983 | | 2 | 3136 | 456.656 | 397.613 | 1.1485 | 0.3652 | | 3 | 4096 | 589.386 | 486.867 | 1.2107 | 0.4939 | | 4 | 2080 | 318.524 | 289.713 | 1.0994 | 0.2500 | | 5 | 1010 | 167.587 | 149.285 | 1.1225 | 0.2897 | | 6 | 2304 | 342.614 | 295.048 | 1.1612 | 0.3822 | #### Opt2(最佳方案)性能指标 | Case | m | 融合前(us) | Opt2 TaskDur(us) | Opt2 加速比(vs融合前) | Opt2 加速比(vs基线) | Opt2 掩盖率 | |------|---|-----------|-----------------|---------------------|-------------------|------------| | 1 | 2624 | 387.117 | 304.701 | 1.2704 | 1.1343 | 0.5924 | | 2 | 3136 | 456.656 | 334.422 | 1.3654 | 1.1890 | 0.7549 | | 3 | 4096 | 589.386 | 432.327 | 1.3633 | 1.1262 | 0.7552 | | 4 | 2080 | 318.524 | 227.819 | 1.3982 | 1.2717 | 0.7864 | | 5 | 1010 | 167.587 | 131.946 | 1.2702 | 1.1314 | 0.5639 | | 6 | 2304 | 342.614 | 272.749 | 1.2562 | 1.0818 | 0.5608 | #### Opt3 性能指标 | Case | m | 融合前(us) | Opt3 TaskDur(us) | Opt3 加速比(vs融合前) | Opt3 加速比(vs基线) | Opt3 掩盖率 | |------|---|-----------|-----------------|---------------------|-------------------|------------| | 1 | 2624 | 387.117 | 305.450 | 1.2672 | 1.1315 | 0.5870 | | 2 | 3136 | 456.656 | 348.026 | 1.3124 | 1.1425 | 0.6711 | | 3 | 4096 | 589.386 | 435.876 | 1.3522 | 1.1170 | 0.7381 | | 4 | 2080 | 318.524 | 251.150 | 1.2683 | 1.1535 | 0.5841 | | 5 | 1010 | 167.587 | 125.811 | 1.3321 | 1.1866 | 0.6606 | | 6 | 2304 | 342.614 | 256.114 | 1.3377 | 1.1520 | 0.6948 | **alltoallMatmul 掩盖率提升**: - 基线掩盖率:25%~49%(平均 34.6%) - Opt2 掩盖率:56%~79%(平均 66.9%),提升约 32 个百分点 - Opt3 掩盖率:58%~74%(平均 65.6%),提升约 31 个百分点 ## 文档更新 无需额外文档更新,变更本身即为 skill 文档 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [x] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: ## 流水线故障排查 <!-- 如果下方的流水线检查未通过,可参考以下指引进行自助修复 --> > **UT_Test 未通过?** > 请在下方流水线表格的 **UT_Test** 行,点击右侧的 >>>>> 下载 **CANNBot-skills UT 测试报告**(HTML 格式)。 > 打开报告后,展开页面中的「UT Test 失败修复指南」,复制其中的提示词并粘贴给 Agent,Agent 将根据日志自动定位并修复问题。 > > 示例: >  See merge request: cann/cannbot-skills!656 | 2 天前 | |
fix(init.sh): 修复 ops-lab 目录缺失导致安装失败及补齐 6 工具全量测试看护 Co-authored-by: jiangyixuan2<124090275@link.cuhk.edu.cn> # message auto-generated for no-merge-commit merge: !581 merge fix/tilelang2ascendc-init-ops-lab-missing into master fix(init.sh): 修复 ops-lab 目录缺失导致安装失败及补齐 6 工具全量测试看护 Created-by: jiangyixuan2 Commit-by: jiangyixuan2 Merged-by: cann-robot Description: ## 问题背景 ### #406:ops-lab 目录缺失导致 init.sh 安装失败 tilelang2ascendc-ops-generator/init.sh 硬编码引用 ../../ops-lab,该目录已迁移至 plugins-community/tilelang-op-orchestrator。set -e 下 cd 到不存在的目录导致脚本早期退出,OpenCode 环境无法完成配置。 ### 附带修复的问题 | # | 问题 | 影响范围 | |---|------|----------| | 1 | 11 个插件 $(cd ... && pwd) 无 if [ -d ] 保护,CI 环境下 set -e 提前退出 | catlass / model-infer-optimize / model-infer-sota-approach / ops-code-reviewer / ops-direct-invoke / ops-direct-invoke-flash / ops-registry-invoke / pypto-op-orchestrator / tilelang-op-orchestrator / torch-compile / triton-op-generator | | 2 | model-infer-sota-approach 缺少 CodeArts 适配(7f2f45b 遗漏) | model-infer-sota-approach | | 3 | 5 个 init.sh 首行缺少 shebang,MSYS2/noacl 下 test -x 失败 | catlass-op-generator / ops-code-reviewer / ops-direct-invoke / pypto-op-orchestrator / tilelang-op-orchestrator | | 4 | 3 个 init.sh 用 find -exec basename 生成 manifest,大环境下 fork 失败导致 installed_agents 为空 | model-infer-optimize / model-infer-sota-approach / ops-direct-invoke-flash | | 5 | 10 个 init.sh 用 basename "$d" 外部命令生成 manifest,同上 fork 限制 | ops-direct-invoke / catlass / ops-code-reviewer / torch-compile / tilelang-op-orchestrator / pypto-op-orchestrator / triton-op-generator / tilelang2ascendc-ops-generator / ops-perf-optimize / cuda2ascend | | 6 | cuda2ascend case 语句显式列出工具名,supports_tool() grep 误判为支持 | cuda2ascend | ### 看护缺口 测试只扫描 plugins-official,完全不覆盖 plugins-community;无 CodeArts 静态看护;无 $(cd ... && pwd) 目录存在性检查。 ## 改动清单 ### Bug 修复(14 个 init.sh) | 改动 | 文件 | |------|------| | ops-lab + ops 路径加 if [ -d ] 保护 | tilelang2ascendc-ops-generator | | SHARED/INFRA/MODEL/ASCEND_AGENT_ROOT 加 if [ -d ] 保护 | 11 个插件 | | CodeArts 适配(参数解析 / CONFIG_ROOT / Quick Start / 健康检查) | model-infer-sota-approach(9 处)、ops-perf-optimize | | 添加 #!/bin/bash 首行 | 5 个插件 | | find -exec basename -> find -printf '%f\n'(无需 fork) | 3 个插件 | | basename "$d" -> ${d##*/}(纯 bash 参数展开) | 10 个插件 | | claude|trae|... -> c[l]aude|t[r]ae|...(字符类避免 grep 误判) | cuda2ascend | ### 测试看护补齐 | 改动 | 说明 | |------|------| | test-init-install.sh 扫描 plugins-official + plugins-community | 修复漏检根因 | | 新增 Check 6:静态检查 $(cd ... && pwd) 引用目录存在性 | 防止此类 bug 再次遗漏 | | test-init-behavior.sh 扫描扩展到两个目录 + supports_tool 跳过逻辑 | 覆盖社区插件 | | 新增 5 个静态 UT(L1):claude / copilot / cursor / trae / opencode | 6 工具全覆盖 | | 新增 18 个 scenario(L2):6 工具 x project/global(trae 含 ide/plugin/cli 变体) | 行为测试全覆盖 | | run-tests.sh fast 列表加入 5 个 tool UT | CI 自动执行 | | 12 个插件 .gitignore 添加 .github 和 .copilot | CO-07 合规 | ### 其他 - .gitattributes:加 *.xml text eol=lf(OAT.xml CRLF 修复) ## 测试覆盖 ### 静态 UT(L1)- 6 工具全覆盖 | 测试 | 规则 | 结果 | |------|------|------| | test-init-opencode.sh | OC-01 ~ OC-07 | 98 passed | | test-init-claude.sh | CL-01 ~ CL-07 | 91 passed | | test-init-trae.sh | TR-01 ~ TR-07 | 84 passed | | test-init-cursor.sh | CU-01 ~ CU-07 | 84 passed | | test-init-copilot.sh | CO-01 ~ CO-07 | 84 passed | | test-init-codearts.sh | CA-01 ~ CA-07 | 91 passed | | test-init-install.sh | Check 1 ~ 6 | 267 passed | | test-safe-install.sh | — | 14 passed | ### 行为测试(L2)- 6 工具 x 18 scenario | 工具 | scenario 数 | |------|------------| | opencode | project + global = 2 | | claude | project + global = 2 | | trae | project(ide/plugin/cli) + global(ide/plugin/cli/unknown/priority) = 8 | | codearts | project + global = 2 | | cursor | project + global = 2 | | copilot | project + global = 2 | ## 变更统计 38 files changed, 2159 insertions(+), 124 deletions(-) Closes #406 See merge request: cann/cannbot-skills!581 | 8 天前 | |
feat: 新增 MC² 通算融合算子性能优化能力 Co-authored-by: yufang<yufang11@huawei.com> # message auto-generated for no-merge-commit merge: !656 merge mc2perf_skill into master feat: 新增 MC² 通算融合算子性能优化能力 Created-by: yufang11 Commit-by: yufang Merged-by: cann-robot Description: ## 描述 为 ops-perf-optimize 插件新增 MC² 通算融合算子(通信+计算融合)的完整性能优化能力,覆盖从数据采集、Bound 诊断、流水配平搜索到方案实施的全流程。 新增能力: - 隔离测试与 Bound 诊断:通过 tileCnt=1 下注释通信/计算 process,实测 T_comm 和 T_compute,计算 R 值精确判定 Bound 类型(计算 Bound / 通信 Bound / 完美平衡) - Local Matmul 策略:将本 rank 数据(无需通信)的 matmul 独立前置/后置执行,与首次通信重叠,隐藏通信延迟 - 流水配平系统搜索:基于 TilingData(baseM/baseN/usedCoreNum)和 R 值,在配平可行域内执行四条剪枝规则的系统搜索,输出 Top-N 候选切分方案供 msprof 实测择优 - 膨胀分析:评估切分粒度对计算膨胀(流水中断、核利用率)和通信膨胀(头开销、带宽)的影响 - 均分切分兜底算法:当缺少隔离测试数据时,提供满核+最多切分的稳健基线 - MC² 实现层设计指南:提供 TilingData 结构、Host 侧搜索代码、AIC/AIV 核心循环、长短块切换同步等实施细节 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/456 ## 测试 在 Ascend 950 (dav-3510) 4P 环境下完成两个 MC² 算子的端到端调优验证: ### allgather_matmul(AllGather + MXFP8 量化 Matmul,12 cases): - 最佳方案:Local Matmul + 流水配平,几何平均加速比 1.44x,12/12 case 全部提升 - 最佳单 case 加速比 1.72x(m=4040, n=2560) - 掩盖率:计算 Bound 组均值 0.82,强计算 Bound 组均值 0.90 - 精度验证:36/36 PASS MC² allgather_matmul 性能指标(加速比与掩盖率) > 基于 Step 1 隔离测试的 T_comm / T_compute,按 /ascendc-perf-optimize 的 comm-compute/index.md 性能指标公式核算。 > 加速比 = 基线T / 优化后T;掩盖率 = (基线T - 优化后T) / min(T_comm, T_compute) | Case | 基线T(us) | T_comm(us) | T_compute(us) | min(T_comm,T_compute) | 方案1最优T(us) | 加速比 | 掩盖率 | |------|---------|----------|-------------|---------------------|-------------|--------|--------| | 1 | 233.20 | 111.48 | 126.28 | 111.48 | 155.84 | 1.50 | 0.69 | | 2 | 432.55 | 111.82 | 325.01 | 111.82 | 330.07 | 1.31 | 0.92 | | 3 | 466.61 | 213.30 | 257.75 | 213.30 | 287.65 | 1.62 | 0.84 | | 4 | 855.15 | 211.85 | 652.39 | 211.85 | 656.56 | 1.30 | 0.94 | | 5 | 504.60 | 232.51 | 275.22 | 232.51 | 314.27 | 1.61 | 0.82 | | 6 | 918.71 | 234.88 | 698.50 | 234.88 | 721.73 | 1.27 | 0.84 | | 7 | 565.84 | 262.03 | 307.41 | 262.03 | 355.04 | 1.59 | 0.80 | | 8 | 1048.28 | 263.69 | 793.80 | 263.69 | 819.71 | 1.28 | 0.87 | | 9 | 699.20 | 311.39 | 401.63 | 311.39 | 408.32 | 1.71 | 0.93 | | 10 | 1248.26 | 314.20 | 947.37 | 314.20 | 940.22 | 1.33 | 0.98 | | 11 | 893.35 | 395.76 | 503.94 | 395.76 | 518.31 | 1.72 | 0.95 | | 12 | 1597.91 | 396.57 | 1213.94 | 396.57 | 1262.62 | 1.27 | 0.85 | > Group A(compute bound)平均掩盖率 0.82,Group B(strong_compute bound)平均掩盖率 0.90。Group B 掩盖率更高因为通信时间小(T_comm << T_compute),min(T_comm, T_compute)=T_comm,而优化节省的绝对时间占 T_comm 比例大,通信几乎被完全掩盖。 ### all_to_all_matmul(AllToAll + MXFP8 Matmul,6 cases): - 最佳方案:流水配平 + Local Matmul,几何平均加速比 1.15x,6/6 case 全部提升 - 最佳单 case 加速比 1.27x(m=2080) - 掩盖率从基线均值 34.6% 提升至 66.9%(+32pp) - 精度验证:18/18 PASS #### 基线性能指标 | Case | m | 融合前(us) | 基线TaskDur(us) | 基线加速比 | 基线掩盖率 | |------|---|-----------|----------------|-----------|-----------| | 1 | 2624 | 387.117 | 345.614 | 1.1200 | 0.2983 | | 2 | 3136 | 456.656 | 397.613 | 1.1485 | 0.3652 | | 3 | 4096 | 589.386 | 486.867 | 1.2107 | 0.4939 | | 4 | 2080 | 318.524 | 289.713 | 1.0994 | 0.2500 | | 5 | 1010 | 167.587 | 149.285 | 1.1225 | 0.2897 | | 6 | 2304 | 342.614 | 295.048 | 1.1612 | 0.3822 | #### Opt2(最佳方案)性能指标 | Case | m | 融合前(us) | Opt2 TaskDur(us) | Opt2 加速比(vs融合前) | Opt2 加速比(vs基线) | Opt2 掩盖率 | |------|---|-----------|-----------------|---------------------|-------------------|------------| | 1 | 2624 | 387.117 | 304.701 | 1.2704 | 1.1343 | 0.5924 | | 2 | 3136 | 456.656 | 334.422 | 1.3654 | 1.1890 | 0.7549 | | 3 | 4096 | 589.386 | 432.327 | 1.3633 | 1.1262 | 0.7552 | | 4 | 2080 | 318.524 | 227.819 | 1.3982 | 1.2717 | 0.7864 | | 5 | 1010 | 167.587 | 131.946 | 1.2702 | 1.1314 | 0.5639 | | 6 | 2304 | 342.614 | 272.749 | 1.2562 | 1.0818 | 0.5608 | #### Opt3 性能指标 | Case | m | 融合前(us) | Opt3 TaskDur(us) | Opt3 加速比(vs融合前) | Opt3 加速比(vs基线) | Opt3 掩盖率 | |------|---|-----------|-----------------|---------------------|-------------------|------------| | 1 | 2624 | 387.117 | 305.450 | 1.2672 | 1.1315 | 0.5870 | | 2 | 3136 | 456.656 | 348.026 | 1.3124 | 1.1425 | 0.6711 | | 3 | 4096 | 589.386 | 435.876 | 1.3522 | 1.1170 | 0.7381 | | 4 | 2080 | 318.524 | 251.150 | 1.2683 | 1.1535 | 0.5841 | | 5 | 1010 | 167.587 | 125.811 | 1.3321 | 1.1866 | 0.6606 | | 6 | 2304 | 342.614 | 256.114 | 1.3377 | 1.1520 | 0.6948 | **alltoallMatmul 掩盖率提升**: - 基线掩盖率:25%~49%(平均 34.6%) - Opt2 掩盖率:56%~79%(平均 66.9%),提升约 32 个百分点 - Opt3 掩盖率:58%~74%(平均 65.6%),提升约 31 个百分点 ## 文档更新 无需额外文档更新,变更本身即为 skill 文档 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [x] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: ## 流水线故障排查 <!-- 如果下方的流水线检查未通过,可参考以下指引进行自助修复 --> > **UT_Test 未通过?** > 请在下方流水线表格的 **UT_Test** 行,点击右侧的 >>>>> 下载 **CANNBot-skills UT 测试报告**(HTML 格式)。 > 打开报告后,展开页面中的「UT Test 失败修复指南」,复制其中的提示词并粘贴给 Agent,Agent 将根据日志自动定位并修复问题。 > > 示例: >  See merge request: cann/cannbot-skills!656 | 2 天前 | |
fix(init.sh): 修复 ops-lab 目录缺失导致安装失败及补齐 6 工具全量测试看护 Co-authored-by: jiangyixuan2<124090275@link.cuhk.edu.cn> # message auto-generated for no-merge-commit merge: !581 merge fix/tilelang2ascendc-init-ops-lab-missing into master fix(init.sh): 修复 ops-lab 目录缺失导致安装失败及补齐 6 工具全量测试看护 Created-by: jiangyixuan2 Commit-by: jiangyixuan2 Merged-by: cann-robot Description: ## 问题背景 ### #406:ops-lab 目录缺失导致 init.sh 安装失败 tilelang2ascendc-ops-generator/init.sh 硬编码引用 ../../ops-lab,该目录已迁移至 plugins-community/tilelang-op-orchestrator。set -e 下 cd 到不存在的目录导致脚本早期退出,OpenCode 环境无法完成配置。 ### 附带修复的问题 | # | 问题 | 影响范围 | |---|------|----------| | 1 | 11 个插件 $(cd ... && pwd) 无 if [ -d ] 保护,CI 环境下 set -e 提前退出 | catlass / model-infer-optimize / model-infer-sota-approach / ops-code-reviewer / ops-direct-invoke / ops-direct-invoke-flash / ops-registry-invoke / pypto-op-orchestrator / tilelang-op-orchestrator / torch-compile / triton-op-generator | | 2 | model-infer-sota-approach 缺少 CodeArts 适配(7f2f45b 遗漏) | model-infer-sota-approach | | 3 | 5 个 init.sh 首行缺少 shebang,MSYS2/noacl 下 test -x 失败 | catlass-op-generator / ops-code-reviewer / ops-direct-invoke / pypto-op-orchestrator / tilelang-op-orchestrator | | 4 | 3 个 init.sh 用 find -exec basename 生成 manifest,大环境下 fork 失败导致 installed_agents 为空 | model-infer-optimize / model-infer-sota-approach / ops-direct-invoke-flash | | 5 | 10 个 init.sh 用 basename "$d" 外部命令生成 manifest,同上 fork 限制 | ops-direct-invoke / catlass / ops-code-reviewer / torch-compile / tilelang-op-orchestrator / pypto-op-orchestrator / triton-op-generator / tilelang2ascendc-ops-generator / ops-perf-optimize / cuda2ascend | | 6 | cuda2ascend case 语句显式列出工具名,supports_tool() grep 误判为支持 | cuda2ascend | ### 看护缺口 测试只扫描 plugins-official,完全不覆盖 plugins-community;无 CodeArts 静态看护;无 $(cd ... && pwd) 目录存在性检查。 ## 改动清单 ### Bug 修复(14 个 init.sh) | 改动 | 文件 | |------|------| | ops-lab + ops 路径加 if [ -d ] 保护 | tilelang2ascendc-ops-generator | | SHARED/INFRA/MODEL/ASCEND_AGENT_ROOT 加 if [ -d ] 保护 | 11 个插件 | | CodeArts 适配(参数解析 / CONFIG_ROOT / Quick Start / 健康检查) | model-infer-sota-approach(9 处)、ops-perf-optimize | | 添加 #!/bin/bash 首行 | 5 个插件 | | find -exec basename -> find -printf '%f\n'(无需 fork) | 3 个插件 | | basename "$d" -> ${d##*/}(纯 bash 参数展开) | 10 个插件 | | claude|trae|... -> c[l]aude|t[r]ae|...(字符类避免 grep 误判) | cuda2ascend | ### 测试看护补齐 | 改动 | 说明 | |------|------| | test-init-install.sh 扫描 plugins-official + plugins-community | 修复漏检根因 | | 新增 Check 6:静态检查 $(cd ... && pwd) 引用目录存在性 | 防止此类 bug 再次遗漏 | | test-init-behavior.sh 扫描扩展到两个目录 + supports_tool 跳过逻辑 | 覆盖社区插件 | | 新增 5 个静态 UT(L1):claude / copilot / cursor / trae / opencode | 6 工具全覆盖 | | 新增 18 个 scenario(L2):6 工具 x project/global(trae 含 ide/plugin/cli 变体) | 行为测试全覆盖 | | run-tests.sh fast 列表加入 5 个 tool UT | CI 自动执行 | | 12 个插件 .gitignore 添加 .github 和 .copilot | CO-07 合规 | ### 其他 - .gitattributes:加 *.xml text eol=lf(OAT.xml CRLF 修复) ## 测试覆盖 ### 静态 UT(L1)- 6 工具全覆盖 | 测试 | 规则 | 结果 | |------|------|------| | test-init-opencode.sh | OC-01 ~ OC-07 | 98 passed | | test-init-claude.sh | CL-01 ~ CL-07 | 91 passed | | test-init-trae.sh | TR-01 ~ TR-07 | 84 passed | | test-init-cursor.sh | CU-01 ~ CU-07 | 84 passed | | test-init-copilot.sh | CO-01 ~ CO-07 | 84 passed | | test-init-codearts.sh | CA-01 ~ CA-07 | 91 passed | | test-init-install.sh | Check 1 ~ 6 | 267 passed | | test-safe-install.sh | — | 14 passed | ### 行为测试(L2)- 6 工具 x 18 scenario | 工具 | scenario 数 | |------|------------| | opencode | project + global = 2 | | claude | project + global = 2 | | trae | project(ide/plugin/cli) + global(ide/plugin/cli/unknown/priority) = 8 | | codearts | project + global = 2 | | cursor | project + global = 2 | | copilot | project + global = 2 | ## 变更统计 38 files changed, 2159 insertions(+), 124 deletions(-) Closes #406 See merge request: cann/cannbot-skills!581 | 8 天前 | |
上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Co-authored-by: hanrui22<hanrui2@huawei.com> # message auto-generated for no-merge-commit merge: !590 merge master into master 上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Created-by: hanrui22 Commit-by: hanrui22 Merged-by: cann-robot Description: ## 描述 新增性能优化工作流,完成对element、 broadcast 和reduce类算子进行性能优化。 支持的CLI: opencode 和 claudecode 支持的模型: GLM5_2 OPUS4.8 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/413 ## 测试 当前从element、 broadcast 和reduce类算子中,选择了3个算子做性能优化。基线代码目录: exp(element-wise) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/exp 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Exp | 1.00x | 3.50x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 11.54 | 10.94 | 3.94 | 1.05x | 2.93x | 2.78x | OK | | 2 | 2048x2048 | float32 | 25.62 | 34.60 | 11.01 | 0.74x | 2.33x | 3.14x | OK | | 3 | 4096x4096 | bfloat16 | 45.97 | 130.96 | 22.75 | 0.35x | 2.02x | 5.76x | OK | | 4 | 8192x8192 | float16 | 385.66 | 513.94 | 77.24 | 0.75x | 4.99x | 6.65x | OK | | 5 | 8192x8192 | float32 | 1466.84 | 495.46 | 152.35 | 2.96x | 9.63x | 3.25x | OK | | 6 | 1023x1023 | bfloat16 | 14.33 | 11.39 | 4.33 | 1.26x | 3.31x | 2.63x | OK | | 7 | 1009x1021 | float16 | 72.19 | 10.74 | 4.16 | 6.72x | 17.35x | 2.58x | OK | | 8 | 1537x769 | float32 | 93.43 | 12.33 | 4.65 | 7.58x | 20.09x | 2.65x | OK | | 9 | 363x367x373 | bfloat16 | 185.28 | 378.45 | 59.84 | 0.49x | 3.10x | 6.32x | OK | | 10 | 2049x513 | float16 | 10.00 | 11.17 | 4.05 | 0.90x | 2.47x | 2.76x | OK | | 11 | 3x7x13x4003 | float32 | 10.88 | 11.46 | 4.47 | 0.95x | 2.43x | 2.56x | OK | | 12 | 1000007 | bfloat16 | 9.98 | 11.26 | 4.24 | 0.89x | 2.35x | 2.66x | OK | | 13 | 11x13x17x67x67 | float32 | 66.65 | 83.51 | 25.27 | 0.80x | 2.64x | 3.30x | OK | | 14 | 3x7x11x13x1013 | float16 | 14.09 | 26.21 | 5.87 | 0.54x | 2.40x | 4.47x | OK | | 15 | 512x2049 | float32 | 10.73 | 11.25 | 4.60 | 0.95x | 2.33x | 2.45x | OK | | 16 | 255x8193 | bfloat16 | 13.04 | 19.37 | 5.16 | 0.67x | 2.53x | 3.75x | OK | | 17 | 4097x511 | float16 | 13.44 | 18.87 | 4.78 | 0.71x | 2.81x | 3.95x | OK | | 18 | 2x511x2049 | float32 | 20.22 | 19.10 | 6.24 | 1.06x | 3.24x | 3.06x | OK | | 19 | 4x255x2049 | bfloat16 | 16.52 | 19.51 | 5.17 | 0.85x | 3.20x | 3.77x | OK | | 20 | 2x3x17x1024x101 | float16 | 30.96 | 82.74 | 14.82 | 0.37x | 2.09x | 5.58x | OK | > 基线代码几何平均加速比 1.00x(与 A5 官方基线持平),优化后达 3.50x(大幅超越 A5 官方基线),整体提升 **3.51 倍**(优化后 vs 基线几何平均加速比) maxinum (broadcast) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/maximum_base 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Maximum | 0.61x | 1.09x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | (1024,1024) | float16 | 5.82 | 5.88 | 5.83 | 0.99x | 0.99x | 1.01x | OK | | 2 | (2048,2048) | float32 | 27.16 | 24.25 | 26.69 | 1.12x | 1.01x | 0.91x | OK | | 3 | (4096,4096) | bfloat16 | 47.83 | 45.55 | 47.60 | 1.05x | 1.01x | 0.96x | OK | | 4 | (8192,8192) | int32 | 521.01 | 521.01 | 517.65 | 1.00x | 1.01x | 1.01x | OK | | 5 | (4096,4096) | int64 | 254.51 | 247.10 | 245.19 | 1.03x | 1.04x | 1.01x | OK | | 6 | (8192,16384) | int8 | 250.65 | 245.74 | 247.35 | 1.02x | 1.02x | 0.99x | OK | | 7 | (1023,1023) | float16 | 6.57 | 5.76 | 5.60 | 1.14x | 1.17x | 1.03x | OK | | 8 | (1009,1021) | float32 | 10.76 | 8.41 | 8.58 | 1.28x | 1.26x | 0.98x | OK | | 9 | (1537,769) | bfloat16 | 8.44 | 6.16 | 7.70 | 1.37x | 1.10x | 0.80x | OK | | 10 | (363,367,373) | float16 | 174.22 | 172.50 | 170.52 | 1.01x | 1.02x | 1.01x | OK | | 11 | (2049,513) / (1,513) | float32 | 9.36 | 19.11 | 6.47 | 0.49x | 1.44x | 2.95x | OK | | 12 | (3,127,687,37) / (1,1,687,1) | float32 | 25.27 | 2526.84 | 29.07 | 0.01x | 1.11x | 86.92x | OK | | 13 | (2,3,5,1024,256) / (1,1,1,1024,1) | int32 | 27.47 | 343.43 | 24.40 | 0.08x | 1.07x | 14.08x | OK | | 14 | (1000007,) | float32 | 10.18 | 7.89 | 8.47 | 1.29x | 1.21x | 0.93x | OK | | 15 | (11,13,17,67,67) | float16 | 31.20 | 30.89 | 31.59 | 1.01x | 0.99x | 0.98x | OK | | 16 | (3,7,11,13,1013) | float32 | 21.37 | 18.91 | 19.65 | 1.13x | 1.09x | 0.96x | OK | | 17 | (512,2049) | bfloat16 | 7.83 | 5.76 | 7.32 | 1.36x | 1.07x | 0.79x | OK | | 18 | (255,8193) / (8193,) | float16 | 11.73 | 6.34 | 11.78 | 1.85x | 0.99x | 0.54x | OK | | 19 | (4097,511) / (1,511) | int64 | 17.92 | 33.82 | 15.34 | 0.53x | 1.17x | 2.20x | OK | | 20 | (2,3,17,1024,101) / (1,1,1,1024,1) | float32 | 33.87 | 1129.04 | 31.37 | 0.03x | 1.10x | 35.99x | OK | > 基线代码几何平均加速比 0.61x(低于 A5 官方基线),优化后达 1.09x(超越 A5 官方基线),整体提升 **1.75 倍**(优化后 vs 基线几何平均加速比) softmax (reduce) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/softmax 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Softmax | 0.180x | 1.005x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 5.51 | 13.96 | 5.67 | 0.39x | 0.97x | 2.46x | OK | | 2 | 2048x2048 | float32 | 15.89 | 28.82 | 14.19 | 0.55x | 1.12x | 2.03x | OK | | 3 | 4096x4096 | bfloat16 | 30.50 | 63.46 | 26.70 | 0.48x | 1.14x | 2.38x | OK | | 4 | 8192x8192 | float16 | 171.99 | 11663.06 | 234.77 | 0.01x | 0.73x | 49.68x | OK | | 5 | 8192x8192 | float32 | 389.94 | 336.40 | 321.08 | 1.16x | 1.21x | 1.05x | OK | | 6 | 31x67x127x257 | bfloat16 | 207.12 | 1135.66 | 209.41 | 0.18x | 0.99x | 5.42x | OK | | 7 | 1023x2047 | float16 | 8.28 | 16.52 | 7.97 | 0.50x | 1.04x | 2.07x | OK | | 8 | 2049x4097 | float32 | 29.56 | 39.66 | 25.74 | 0.75x | 1.15x | 1.54x | OK | | 9 | 127x257x1023 | bfloat16 | 74.47 | 698.65 | 92.55 | 0.11x | 0.80x | 7.55x | OK | | 10 | 1009x1021 | float16 | 5.66 | 14.80 | 5.96 | 0.38x | 0.95x | 2.48x | OK | | 11 | 367x373x379 | float32 | 297.98 | 2397.48 | 318.73 | 0.12x | 0.93x | 7.52x | OK | | 12 | 11x13x17x4001 | bfloat16 | 19.49 | 40.34 | 18.20 | 0.48x | 1.07x | 2.22x | OK | | 13 | 1000003x2 | float16 | 20.23 | 4730.31 | 16.77 | 0.00x | 1.21x | 282.07x | OK | | 14 | 11x13x17x67x67 | float32 | 51.87 | 1384.35 | 40.73 | 0.04x | 1.27x | 33.99x | OK | | 15 | 3x7x11x13x1013 | bfloat16 | 9.90 | 35.46 | 9.54 | 0.28x | 1.04x | 3.72x | OK | | 16 | 512x2049 | float16 | 5.93 | 75.30 | 8.47 | 0.08x | 0.70x | 8.89x | OK | | 17 | 255x8193 | float32 | 9.12 | 13.51 | 9.19 | 0.68x | 0.99x | 1.47x | OK | | 18 | 2x511x2049 | bfloat16 | 8.19 | 16.69 | 7.51 | 0.49x | 1.09x | 2.22x | OK | | 19 | 4x255x2049 | float16 | 8.30 | 77.33 | 8.69 | 0.11x | 0.96x | 8.90x | OK | | 20 | 2x3x17x1024x101 | float32 | 51.30 | 1478.12 | 53.58 | 0.03x | 0.96x | 27.59x | OK | > 基线代码几何平均加速比 0.180x(远低于 A5 官方基线),优化后达 1.005x(追平 A5 官方基线),整体提升 **5.58 倍**(优化后 vs 基线几何平均加速比)。 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [ ] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/cannbot-skills!590 | 12 天前 | |
上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Co-authored-by: hanrui22<hanrui2@huawei.com> # message auto-generated for no-merge-commit merge: !590 merge master into master 上传性能优化工作流,当前支持对element、broadcast和reduce类算子做性能优化。 Created-by: hanrui22 Commit-by: hanrui22 Merged-by: cann-robot Description: ## 描述 新增性能优化工作流,完成对element、 broadcast 和reduce类算子进行性能优化。 支持的CLI: opencode 和 claudecode 支持的模型: GLM5_2 OPUS4.8 ## 关联的Issue https://gitcode.com/cann/cannbot-skills/issues/413 ## 测试 当前从element、 broadcast 和reduce类算子中,选择了3个算子做性能优化。基线代码目录: exp(element-wise) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/exp 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Exp | 1.00x | 3.50x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 11.54 | 10.94 | 3.94 | 1.05x | 2.93x | 2.78x | OK | | 2 | 2048x2048 | float32 | 25.62 | 34.60 | 11.01 | 0.74x | 2.33x | 3.14x | OK | | 3 | 4096x4096 | bfloat16 | 45.97 | 130.96 | 22.75 | 0.35x | 2.02x | 5.76x | OK | | 4 | 8192x8192 | float16 | 385.66 | 513.94 | 77.24 | 0.75x | 4.99x | 6.65x | OK | | 5 | 8192x8192 | float32 | 1466.84 | 495.46 | 152.35 | 2.96x | 9.63x | 3.25x | OK | | 6 | 1023x1023 | bfloat16 | 14.33 | 11.39 | 4.33 | 1.26x | 3.31x | 2.63x | OK | | 7 | 1009x1021 | float16 | 72.19 | 10.74 | 4.16 | 6.72x | 17.35x | 2.58x | OK | | 8 | 1537x769 | float32 | 93.43 | 12.33 | 4.65 | 7.58x | 20.09x | 2.65x | OK | | 9 | 363x367x373 | bfloat16 | 185.28 | 378.45 | 59.84 | 0.49x | 3.10x | 6.32x | OK | | 10 | 2049x513 | float16 | 10.00 | 11.17 | 4.05 | 0.90x | 2.47x | 2.76x | OK | | 11 | 3x7x13x4003 | float32 | 10.88 | 11.46 | 4.47 | 0.95x | 2.43x | 2.56x | OK | | 12 | 1000007 | bfloat16 | 9.98 | 11.26 | 4.24 | 0.89x | 2.35x | 2.66x | OK | | 13 | 11x13x17x67x67 | float32 | 66.65 | 83.51 | 25.27 | 0.80x | 2.64x | 3.30x | OK | | 14 | 3x7x11x13x1013 | float16 | 14.09 | 26.21 | 5.87 | 0.54x | 2.40x | 4.47x | OK | | 15 | 512x2049 | float32 | 10.73 | 11.25 | 4.60 | 0.95x | 2.33x | 2.45x | OK | | 16 | 255x8193 | bfloat16 | 13.04 | 19.37 | 5.16 | 0.67x | 2.53x | 3.75x | OK | | 17 | 4097x511 | float16 | 13.44 | 18.87 | 4.78 | 0.71x | 2.81x | 3.95x | OK | | 18 | 2x511x2049 | float32 | 20.22 | 19.10 | 6.24 | 1.06x | 3.24x | 3.06x | OK | | 19 | 4x255x2049 | bfloat16 | 16.52 | 19.51 | 5.17 | 0.85x | 3.20x | 3.77x | OK | | 20 | 2x3x17x1024x101 | float16 | 30.96 | 82.74 | 14.82 | 0.37x | 2.09x | 5.58x | OK | > 基线代码几何平均加速比 1.00x(与 A5 官方基线持平),优化后达 3.50x(大幅超越 A5 官方基线),整体提升 **3.51 倍**(优化后 vs 基线几何平均加速比) maxinum (broadcast) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/maximum_base 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Maximum | 0.61x | 1.09x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | (1024,1024) | float16 | 5.82 | 5.88 | 5.83 | 0.99x | 0.99x | 1.01x | OK | | 2 | (2048,2048) | float32 | 27.16 | 24.25 | 26.69 | 1.12x | 1.01x | 0.91x | OK | | 3 | (4096,4096) | bfloat16 | 47.83 | 45.55 | 47.60 | 1.05x | 1.01x | 0.96x | OK | | 4 | (8192,8192) | int32 | 521.01 | 521.01 | 517.65 | 1.00x | 1.01x | 1.01x | OK | | 5 | (4096,4096) | int64 | 254.51 | 247.10 | 245.19 | 1.03x | 1.04x | 1.01x | OK | | 6 | (8192,16384) | int8 | 250.65 | 245.74 | 247.35 | 1.02x | 1.02x | 0.99x | OK | | 7 | (1023,1023) | float16 | 6.57 | 5.76 | 5.60 | 1.14x | 1.17x | 1.03x | OK | | 8 | (1009,1021) | float32 | 10.76 | 8.41 | 8.58 | 1.28x | 1.26x | 0.98x | OK | | 9 | (1537,769) | bfloat16 | 8.44 | 6.16 | 7.70 | 1.37x | 1.10x | 0.80x | OK | | 10 | (363,367,373) | float16 | 174.22 | 172.50 | 170.52 | 1.01x | 1.02x | 1.01x | OK | | 11 | (2049,513) / (1,513) | float32 | 9.36 | 19.11 | 6.47 | 0.49x | 1.44x | 2.95x | OK | | 12 | (3,127,687,37) / (1,1,687,1) | float32 | 25.27 | 2526.84 | 29.07 | 0.01x | 1.11x | 86.92x | OK | | 13 | (2,3,5,1024,256) / (1,1,1,1024,1) | int32 | 27.47 | 343.43 | 24.40 | 0.08x | 1.07x | 14.08x | OK | | 14 | (1000007,) | float32 | 10.18 | 7.89 | 8.47 | 1.29x | 1.21x | 0.93x | OK | | 15 | (11,13,17,67,67) | float16 | 31.20 | 30.89 | 31.59 | 1.01x | 0.99x | 0.98x | OK | | 16 | (3,7,11,13,1013) | float32 | 21.37 | 18.91 | 19.65 | 1.13x | 1.09x | 0.96x | OK | | 17 | (512,2049) | bfloat16 | 7.83 | 5.76 | 7.32 | 1.36x | 1.07x | 0.79x | OK | | 18 | (255,8193) / (8193,) | float16 | 11.73 | 6.34 | 11.78 | 1.85x | 0.99x | 0.54x | OK | | 19 | (4097,511) / (1,511) | int64 | 17.92 | 33.82 | 15.34 | 0.53x | 1.17x | 2.20x | OK | | 20 | (2,3,17,1024,101) / (1,1,1,1024,1) | float32 | 33.87 | 1129.04 | 31.37 | 0.03x | 1.10x | 35.99x | OK | > 基线代码几何平均加速比 0.61x(低于 A5 官方基线),优化后达 1.09x(超越 A5 官方基线),整体提升 **1.75 倍**(优化后 vs 基线几何平均加速比) softmax (reduce) 基线代码目录: https://gitcode.com/hanrui22/baseline/tree/main/softmax 性能数据: | 算子名 | 基线平均性能(按 A5 基线加速比,几何平均) | 优化后算子平均性能(按 A5 基线加速比,几何平均) | |--------|------------------------------------------|------------------------------------------------| | Softmax | 0.180x | 1.005x | | Case 序号 | Shape | Dtype | A5 基线(us) | 原始基线(us) | 性能优化后(us) | 基线/A5 加速比 | 优化后/A5 加速比 | 提速比例 | 精度是否 OK | |----------|-------|-------|------------|-------------|---------------|---------------|-----------------|---------|------------| | 1 | 1024x1024 | float16 | 5.51 | 13.96 | 5.67 | 0.39x | 0.97x | 2.46x | OK | | 2 | 2048x2048 | float32 | 15.89 | 28.82 | 14.19 | 0.55x | 1.12x | 2.03x | OK | | 3 | 4096x4096 | bfloat16 | 30.50 | 63.46 | 26.70 | 0.48x | 1.14x | 2.38x | OK | | 4 | 8192x8192 | float16 | 171.99 | 11663.06 | 234.77 | 0.01x | 0.73x | 49.68x | OK | | 5 | 8192x8192 | float32 | 389.94 | 336.40 | 321.08 | 1.16x | 1.21x | 1.05x | OK | | 6 | 31x67x127x257 | bfloat16 | 207.12 | 1135.66 | 209.41 | 0.18x | 0.99x | 5.42x | OK | | 7 | 1023x2047 | float16 | 8.28 | 16.52 | 7.97 | 0.50x | 1.04x | 2.07x | OK | | 8 | 2049x4097 | float32 | 29.56 | 39.66 | 25.74 | 0.75x | 1.15x | 1.54x | OK | | 9 | 127x257x1023 | bfloat16 | 74.47 | 698.65 | 92.55 | 0.11x | 0.80x | 7.55x | OK | | 10 | 1009x1021 | float16 | 5.66 | 14.80 | 5.96 | 0.38x | 0.95x | 2.48x | OK | | 11 | 367x373x379 | float32 | 297.98 | 2397.48 | 318.73 | 0.12x | 0.93x | 7.52x | OK | | 12 | 11x13x17x4001 | bfloat16 | 19.49 | 40.34 | 18.20 | 0.48x | 1.07x | 2.22x | OK | | 13 | 1000003x2 | float16 | 20.23 | 4730.31 | 16.77 | 0.00x | 1.21x | 282.07x | OK | | 14 | 11x13x17x67x67 | float32 | 51.87 | 1384.35 | 40.73 | 0.04x | 1.27x | 33.99x | OK | | 15 | 3x7x11x13x1013 | bfloat16 | 9.90 | 35.46 | 9.54 | 0.28x | 1.04x | 3.72x | OK | | 16 | 512x2049 | float16 | 5.93 | 75.30 | 8.47 | 0.08x | 0.70x | 8.89x | OK | | 17 | 255x8193 | float32 | 9.12 | 13.51 | 9.19 | 0.68x | 0.99x | 1.47x | OK | | 18 | 2x511x2049 | bfloat16 | 8.19 | 16.69 | 7.51 | 0.49x | 1.09x | 2.22x | OK | | 19 | 4x255x2049 | float16 | 8.30 | 77.33 | 8.69 | 0.11x | 0.96x | 8.90x | OK | | 20 | 2x3x17x1024x101 | float32 | 51.30 | 1478.12 | 53.58 | 0.03x | 0.96x | 27.59x | OK | > 基线代码几何平均加速比 0.180x(远低于 A5 官方基线),优化后达 1.005x(追平 A5 官方基线),整体提升 **5.58 倍**(优化后 vs 基线几何平均加速比)。 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🌟 新特性 - [ ] ✨ 特性增强 - [ ] 🐛 Bug 修复 - [ ] ⚡ 性能优化 - [ ] 🧪 测试用例 - [ ] 📦 构建 / CI - [ ] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] ♻️ 代码重构 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/cannbot-skills!590 | 12 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 12 天前 | ||
| 2 天前 | ||
| 12 天前 | ||
| 2 天前 | ||
| 8 天前 | ||
| 2 天前 | ||
| 8 天前 | ||
| 12 天前 | ||
| 12 天前 |