已合并
[fix]tiling_key_error #32336
cuiduo创建于 3月25日
[fix]tiling_key_error #32336
已合并
cuiduo创建于 3月25日
cuiduo
cuiduo成员
3月25日

【合入来源】

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

【修改方案】

  1. 在codegen的tiling阶段,会调用get_axis_dtype来获取node的type,当axis为sympy.Expr类时会报错
File "/home/cuiduo/miniconda3/envs/py311/lib/python3.11/site-packages/torch_npu/_inductor/codegen/triton.py", line 790, in get_axis_dtype
dim = self.range_tree_nodes_removed[key]
torch ._ dynamo. exc. BackendCompilerFailed: backend='inductor' raised:
KeyError: x2 + 512*y1 + 2048*z0

因此需要增加校验,提取sympy.Expr中的Symbol以进行dtype的判断
2.在fold类fx_pass的入口处添加stable_topological_sort(gm)进行排序,避免乱序图带来的影响

【资料变更】

不涉及

【接口变更】

不涉及

【功能验证】

自验完成

【CheckList】

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

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 cuiduo 的贡献)
cuiduocuiduo成员
3月25日 创建了 pull request,commit d6d74912
ascend-robot
ascend-robot成员
3月25日 评论:

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, adrian07110 (2/2) zichun_ye, adrian07110 (2/1)
torch_npu/_inductor zichun_ye, adrian07110 (2/2) zichun_ye, adrian07110 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

cuiduo, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robotascend-robot成员
3月25日 添加了label:ascend-cla/yes
cuiduocuiduo成员
3月25日 update merge request[project id: 7404318, iid: 32336, commit_id: f7935b35b09aa90b70d39464c5713e78e2bdf640] virtual merging success
此处折叠了61条消息 查看更多
ZhihaoLi
ZhihaoLi成员3月28日进行代码检视1
torch_npu/_inductor/codegen/triton.py
@@ -786,6 +786,21 @@ class NPUIndexTritonKernel(TritonKernel):
786786 dtype = None
787787 if axis is None:
788788 return None
789+ 
790+ def _lookup_dim(sym) -> Optional["IterationRangesEntryNPUIndex"]:
791+ dim = self.range_tree_nodes.get(sym)
792+ if dim is not None:
793+ return dim
794+ return self.range_tree_nodes_removed.get(sym)
795+ 
796+ def _iter_candidate_syms(key):
797+ # indexing_map keys can be sympy.Symbol (common) or sympy.Expr (e.g. linearized indexing)
798+ # Try direct lookup first, then fall back to free_symbols for Expr.
799+ yield key
800+ if isinstance(key, sympy.Expr) and not isinstance(key, sympy.Symbol):
801+ for s in key.free_symbols:
802+ yield s
803+ 
789804 for node in self.node_schedule:
790805 if node in (EnableReduction, DisableReduction):
791806 continue
@@ -800,10 +815,13 @@ class NPUIndexTritonKernel(TritonKernel):
800815 if node in (EnableReduction, DisableReduction):
801816 continue
802817 for key, _ in node._body.indexing_map.items():
803- if key in self.range_tree_nodes:
ZhihaoLi
ZhihaoLi3月28日评论:

可将if dim is None修改为else,不用预定义dim=None

likedislike
ZhihaoLi
ZhihaoLi成员
3月30日 评论:

/approve

likedislike
ascend-robotascend-robot成员
3月30日 添加了label:lgtm
ascend-robot
ascend-robot成员
3月30日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: zichun_ye, adrian07110.
Reviewers who wrote a comment of /lgtm are: zichun_ye, adrian07110.

likedislike
ascend-robotascend-robot成员
3月30日 合入了pull request