Closed
[perf] DVM GroupNorm、matmul、内存分配与可选 permute lowering 优化 #5282
SorryNaCNAdd on Oct 8Closed at 11 days ago
Oct 8 Added label: triage-reviewmodule: graph-mode
TorchNPU-Bot
Oct 8 Comments:
Oct 8 Comments:
无报错,属性能优化建议/需求;主题为 DVM 后端图编译与 lowering 优化
添加分类标签:module: graph-mode。
当前分类由社区bot提供,如分类有误请在评论中回复。


Oct 8 Added label: bot-triaged; Removed label: triage-review
TorchNPU-Bot
Oct 8 Comments:
Oct 8 Comments:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged


chenrayray
11 days ago Comments:
11 days ago Comments:
关联的 PR(!47449)已全部合入,先关闭这个 issue。如问题仍存在或需要继续跟踪,欢迎补充信息后重新打开。


11 days ago Close issue
11 days ago changed custom state from TODO to DONE
11 days ago changed custom state from TODO to DONE
11 days ago Added label: resolved
关联 PR:https://gitcode.com/Ascend/pytorch/pull/47449
个人仓库跟踪 Issue:https://gitcode.com/SorryNaCN/pytorch_8420/issues/10
背景与目标
优化 DVM 后端的 GroupNorm 分解、广播 matmul、内存分配代码生成和可选 permute lowering,降低相关模型开销,并记录验证范围。
修改方案
aten.native_group_norm分解,使 DVM 可以融合其计算。_override_matmul_should_fold_for_npu(),将适用的 3D×2D matmul 转为 MM,减少权重广播和 BMM 开销。NPUWrapperCodeGen.make_allocation,生成_empty_strided_npu调用;非 NPU、内存生命周期跟踪、pinned 分配及子图保留原有路径。aten.permute放入生成白名单,新增默认关闭的enable_fusion_permute配置;开启后允许 DVM 融合并生成reinterpret_tensor视图。修改范围:
torch_npu/_inductor/dvm/下的config.py、decomp.py、mlir_fusion.py和新增的wrapper.py。详细设计见关联 PR。已记录的验证结果
环境:Ascend910B3 / CANN 9.2.0.beta.2 / PyTorch 2.13,基于 PR !47318 构建并应用对应改动。时间单位为 ms/次,严格精度阈值为
rtol=atol=1e-4。以下引用 PR 已记录结果,创建本 Issue 时未重新测试。aten.permute调用为 0。git diff --check通过;提交3e76f0ecf45429273b2a20a2fc7c2a1b9898c6f2的流水线PR-pipeline_pytorch#71518已通过。待完成项