已合并
fix: fix npugrphs backend bug and add indexput test case #31726
fix: fix npugrphs backend bug and add indexput test case #31726
已合并
luochao60创建于 3月12日
luochao60成员
3月12日

【合入来源】

(如有)请关联需求文档/issue链接

【修改方案】

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

  1. 修复 patch_get_first_incompatible_cudagraph_node monkey patch 不生效的问题torch_npu/_inductor/utils.py):

    • 去除 compile_fxcudagraphs 模块 patch 时的 hasattr 条件判断,改为直接赋值覆盖,因为 torch_npu 与 torch 是固定版本匹配的,不需要兼容性判断
    • 新增对 torch_npu.utils._graph_tree 模块的 patch:该模块通过 from torch._inductor.utils import get_first_incompatible_cudagraph_node 拿走了原始引用,必须显式覆盖该模块命名空间中的引用,否则 npugraphs 后端无法正确检测 cudagraph-unsafe 算子
  2. 修复 _graph_tree.py 中的代码格式问题torch_npu/npu/_graph_tree.py):

    • 清理行尾多余空格
  3. 新增 ACL graph 特殊算子的测试用例test_acl_graph_special_op.py):

    • test_masked_assign_forward:验证 tensor[bool_mask] = -1(aten.index_put_ with bool indices)在 inductor 后端 cudagraphs 模式下被正确检测为 cudagraph-unsafe 并回退到 eager 执行,支持 float32/float16 参数化测试
    • test_masked_assign_forward_backward:验证包含 bool index_put 的前向+反向传播在 inductor 后端下的正确性
    • test_npugraphs_masked_assign_forward:同上,使用 npugraphs 后端验证
    • test_npugraphs_masked_assign_forward_backward:同上,使用 npugraphs 后端验证前向输出和梯度正确性

【资料变更】

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

不涉及

【接口变更】

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

不涉及

【功能验证】

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

已新增 UT 测试用例 test_acl_graph_special_op.py,覆盖以下场景:

  • inductor 后端 + cudagraphs:bool index_put 前向(float32/float16)、前向+反向
  • npugraphs 后端:bool index_put 前向(float32/float16)、前向+反向
  • 测试方法:torch.compile 编译后与 eager 模式对比输出和梯度一致性

【CheckList】

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

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 luochao60 的贡献)
Lluochao60成员
3月12日 创建了 pull request,commit 0b747928
ascend-robot
ascend-robot成员
3月12日 评论:

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

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robotascend-robot成员
3月12日 添加了label:ascend-cla/yes
luochao60成员
3月12日 评论:

compile

likedislike
此处折叠了86条消息 查看更多
ascend-robotascend-robot成员
3月25日 添加了label:approved
suhaibo成员
3月25日 评论:

/lgtm

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

Review Guide

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

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