super_kernel 用例演示【免费下载链接】graph-autofusionGraph-autofusion 是一个面向昇腾Ascend芯片的轻量级、解耦式组件集合旨在通过自动融合技术加速模型执行。 目前已开源 SuperKernel 组件未来将持续开放更多自动融合相关模块。项目地址: https://gitcode.com/cann/graph-autofusion用例功能模型包含6个sk片段部分sk相同复用缓存部分多了可输入bias或option配置不同走在线编译编译使用super_kernel和不使用super_kernel的模型将性能数据输出融合算子使用如下with语句块super_kernel语句块内算子均被融合为一个超级Kernel进行计算with torchair.scope.super_kernel(sk1):详细功能介绍见图内标定SuperKernel范围执行命令python3 superkernel_compare.py预期执行结果执行后打印显示successexecute sample success在执行目录生成prof_result文件夹目录如下获取数据后对比耗时prof_result ├── sk_model # 带superkernel结果 │ ├── localhost.localdomain_ascend_pt │ ├── PROF_* │ ├── mindstudio_profiler_output │ ├── op_statistic.csv # profiling数据 ├── no_sk_model # 不带superkernel结果 │ ├── localhost.localdomain_ascend_pt │ ├── PROF_* │ ├── mindstudio_profiler_output │ ├── op_statistic.csv # profiling数据分别从两份op_statistic.csv表中得到如下数据 | OP_Type | Core Type | Total Time(us) | |--|--|--| | GroupedMatmul | MIX_AIC | 126.26 | | Transpose | AI_VECTOR_CORE | 90.02 | | MoeGatingTopK | AI_VECTOR_CORE | 68.32| |Tile | AI_VECTOR_CORE| 24.96 | | DequantSwigluQuant |AI_VECTOR_CORE | 24.18 | | ReduceMeanD | MIX_AIV| 16.36 | | ConcatV2D| AI_VECTOR_CORE| 14.9 | | ReduceMeanD | AI_VECTOR_CORE | 14.14 | | SplitVD |AI_VECTOR_CORE | 10.04 | | MatMul |AI_CORE | 6.26 | | Cast | AI_VECTOR_CORE|3.96 | | Data | AI_VECTOR_CORE| 3.3 | | StridedSliceD | AI_VECTOR_CORE |3.18 | | AutomaticBufferFusionOp |AI_VECTOR_CORE |1.66 | |no_sk_model|总耗时|407.54|| OP_Type | Core Type | Total Time(us) | |--|--|--| |SuperKernel | MIX_AIC| 172.4| |Transpose |AI_VECTOR_CORE | 92.42| |Tile |AI_VECTOR_CORE |24.66 | |SuperKernel |MIX_AIV | 18.48| |ReduceMeanD |MIX_AIV | 16.34| |ConcatV2D |AI_VECTOR_CORE |14.74 | |ReduceMeanD | AI_VECTOR_CORE| 14.24| |SplitVD |AI_VECTOR_CORE |10.12 | |MatMul |AI_CORE | 8.6| |Cast |AI_VECTOR_CORE |4.08 | |Data |AI_VECTOR_CORE | 3.72| |StridedSliceD |AI_VECTOR_CORE |3.1 | |AutomaticBufferFusionOp |AI_VECTOR_CORE | 1.76| |sk_model|总耗时|384.66|对比获得使用super_kernel融合算子的收益是5.61%【免费下载链接】graph-autofusionGraph-autofusion 是一个面向昇腾Ascend芯片的轻量级、解耦式组件集合旨在通过自动融合技术加速模型执行。 目前已开源 SuperKernel 组件未来将持续开放更多自动融合相关模块。项目地址: https://gitcode.com/cann/graph-autofusion创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考