已合并
fix(dvm): guard stride patch behind is_fx_dynamic in fallback kernel. #37883
Margaret_wangrui创建于 6月8日
fix(dvm): guard stride patch behind is_fx_dynamic in fallback kernel. #37883
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Margaret_wangrui 的贡献)6月8日 创建了 pull request,commit 2f8750df
ascend-robot
6月8日 评论:
6月8日 评论:
6月8日 添加了label:ascend-cla/yes
ascend-robot
6月8日 评论:
6月8日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| test | ✅ zichun_ye, hbhu_bin (2/2) | ✅ zichun_ye (1/1) |
| torch_npu/_inductor | ✅ zichun_ye, hbhu_bin (2/2) | ✅ zichun_ye (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Margaret_wangrui, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Margaret_wangrui
6月8日 评论:
6月8日 评论:
/retest


此处折叠了57条消息 查看更多
6月16日 添加了label:approved
6月16日 添加了label:lgtm
6月16日 合入了pull request
ascend-robot
6月16日 评论:
6月16日 评论:
流水线 pytorch_gitcode_PR_multiVersion#10741 [ commitID:7f6533ea ] 已完成


【合入来源】
说明:修复 DVM 图融合在动态 shape 场景下 codegen 失败的问题。动态子图中 Inductor buffer stride 为符号表达式,仍调用
patch_gm_placeholder_strides_from_codegen_args会在torch.empty_strided处触发TypeError(stride 含Mul等非 int 元素)。【修改方案】
问题根因:
_dvm_generate_fallback_kernel在生成dvm::fused_graph_*fallback kernel 时,无条件调用patch_gm_placeholder_strides_from_codegen_args,将 Inductor buffer 的真实 stride 写回 fused subgraph placeholder 的meta["val"]。静态 shape 下该逻辑用于选择k.view_load路径;动态 shape 下 stride 为SymInt/符号表达式,无法构造合法 fake tensor,导致 codegen 异常。修改内容:在
torch_npu/_inductor/dvm/graph_fusion.py的_dvm_generate_fallback_kernel中,引入is_fx_dynamic(来自graph_build.py),仅当 fused subgraph 非动态 shape 时才执行 stride patch:if not is_fx_dynamic(meta.gm): patch_gm_placeholder_strides_from_codegen_args(meta.gm, args_list)行为说明:
view_load优化。DvmCodegenInterpreter走dyn_shape=True与codegen_maybe_view_load的 symbolic 分支,使用k.load并在必要时由.contiguous()保证输入合法。涉及组件:Inductor
PythonWrapperCodegen.generate_fallback_kernel(DVM patch 点)→graph_fusion._dvm_generate_fallback_kernel→util.patch_gm_placeholder_strides_from_codegen_args/graph_build.DvmCodegenInterpreter。【资料变更】
不涉及
【接口变更】
不涉及
本次修改仅影响 DVM 图融合内部 codegen 逻辑,不涉及对外 Python/C++ API 及跨仓接口变更。
【功能验证】
测试场景
view_load,精度/行为与改前一致SymInt/SymFloat的 fused subgraph)empty_strided报错,可正常生成 DVM kernelk.load+.contiguous(),功能正确验证方法
_dvm_generate_fallback_kernel/util.py报empty_stridedstride 类型错误),确认torch.compile(..., backend="inductor")可完成 codegen 并正确执行。view_load相关场景),确认融合结果与 golden 一致。【CheckList】