已合并
fix(inductor): keep multi_slice_concat out of epilogue fusion #44887
dezheng889创建于 1 天前
fix(inductor): keep multi_slice_concat out of epilogue fusion #44887
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 dezheng889 的贡献)1 天前 创建了 pull request,commit a3d1777f
ascend-robot
1 天前 评论:
1 天前 评论:
atomgit-bot
1 天前 评论:
1 天前 评论:
变更摘要
本 PR 修复 multi_slice_concat(torch_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 源码,供上述测试校验融合结果使用。


atomgit-bot
1 天前 评论:
1 天前 评论:
1 天前 添加了label:ascend-cla/yes
此处折叠了58条消息 查看更多
li_jing_hw
1 天前 评论:
1 天前 评论:
/approve


1 天前 添加了label:approvedlgtm
1 天前 合入了pull request
ascend-robot
1 天前 评论:
1 天前 评论:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


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


回退pr:https://gitcode.com/Ascend/pytorch/pull/44718
【合入来源】
【修改方案】
【资料变更】
【接口变更】
【功能验证】
【CheckList】