已合并
fix(inductor): keep multi_slice_concat out of epilogue fusion #44887
fix(inductor): keep multi_slice_concat out of epilogue fusion #44887
已合并
dezheng889创建于 1 天前
dezheng889成员
1 天前

回退pr:https://gitcode.com/Ascend/pytorch/pull/44718

【合入来源】

如有社区issue,请关联issue链接
请勿携带内部流程信息(需求链接、问题单、内部issue等)

【修改方案】

请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列
如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

【资料变更】

请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

【接口变更】

请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”

【功能验证】

说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤
新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 dezheng889 的贡献)
Ddezheng889成员
1 天前 创建了 pull request,commit a3d1777f
atomgit-bot
atomgit-bot
1 天前 评论:

变更摘要

本 PR 修复 multi_slice_concattorch_npu/_inductor/kernel/multi_slice_concat.py)的 epilogue 融合问题:该模板按 segment 逐段 tl.store 存储输出且不渲染 store_output 钩子,若调度器将 epilogue 融合进该 kernel,代码生成时会直接跳过该 epilogue,导致消费者的计算(如 concat 之后的 clamp)被静默丢弃。修复方案是在 lowering 阶段通过 V.graph.no_fuse_buffer_names.add(out.data.data.get_name()) 将输出标记为不可融合,使调度器在咨询后端之前即拒绝 epilogue 与横向融合,从而保证 concat 的 rewrite 照常发生、消费者保持为独立 kernel。

主要改动

  • 标记输出为不可融合: 在 multi_slice_concat 的 lowering 中,将 autotune_select_algorithm 的返回值包装为 out,并把其 output_node() 对应的 buffer 名称加入 V.graph.no_fuse_buffer_names,阻止 epilogue 与横向融合;同步更新了模块顶部文档注释,说明放弃 epilogue 融合的原因与处理机制。
  • 新增不可融合行为的回归测试: 在 test/_inductor/test_multi_slice_concat_pass.py 中新增 test_compile_epilogue_is_not_fused_away,构造 torch.clamp(_col_concat_ref(...), -bound, bound) 场景,断言 pass 生效、结果与参考实现逐位一致,并验证模板 kernel 源码中不出现 maximum/minimum/clamp( 等 clamp 痕迹。
  • 新增 kernel 源码提取辅助函数: 添加 _kernel_source(code, marker),通过按 async_compile.triton( 切分代码并按 def 行过滤,提取包含指定参数的编译后 kernel 源码,供上述测试校验融合结果使用。
likedislike
atomgit-bot
atomgit-bot
1 天前 评论:

代码审查

✅ 未发现问题

likedislike
ascend-robotascend-robot成员
1 天前 添加了label:ascend-cla/yes
此处折叠了58条消息 查看更多
li_jing_hw成员
1 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
1 天前 添加了label:approvedlgtm
ascend-robotascend-robot成员
1 天前 合入了pull request
ascend-robot
ascend-robot成员
1 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
ascend-robot
ascend-robot成员
1 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#14227 [ commitID:65cc47c6 ] 已完成
likedislike