已合并
fix_nfa_grad_meta #38633
fix_nfa_grad_meta #38633
已合并
Ambi创建于 6月16日
Ambi
Ambi
6月16日

https://gitcode.com/Ascend/pytorch/issues/2433

【合入来源】

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

【修改方案】

删除了对 torch._dynamo.utils.run_node 的 monkey patch:去掉 _patch_run_node() 以及 torch._dynamo.utils.run_node = _patch_run_node。
原先在 Dynamo run_node 阶段特殊处理 npu.npu_fusion_attention,把 actual_seq_qlen / actual_seq_kvlen 转成 list;现在这个逻辑下沉到了 npu_stream.py 的算子封装里。

npu_fusion_attention_grad 同步支持 softmax_layout、sink,返回值从 4 个扩展为 5 个,新增 dsink 梯度。
将 prefix、actual_seq_qlen、actual_seq_kvlen 的 tensor-to-list 转换放到 wrapper 内部处理,替代原来在 run_node patch 里的处理。
新增 InductorNpuAttentionFunction 的 autograd 封装,forward 保存 sink,backward 返回 grad_sink,并通过 apply_inductor_npu_attention_patch() 替换 torch.ops.npu.npu_fusion_attention。

【资料变更】

不涉及

【接口变更】

不涉及

【功能验证】

Ci UT全量自检

【CheckList】

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

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Ambi 的贡献)
AmbiAmbi
6月16日 创建了 pull request,commit 8000ea0a
openLiBingCI成员6月16日进行代码检视1
torch_npu/_inductor/ascend_npu_ir/ascend_npu_ir/npu/npu_stream.py
@@ -11,4 +23,4 @@
1123# create a library to hold the custom op
1224npu_stream_lib = Library("npu_stream", "FRAGMENT") # noqa
25+inductor_npu_lib = Library("inductor_npu", "FRAGMENT") # noqa
1326 
1427def direct_register_custom_op(
openLiBingCI6月16日评论:

此条代码评论区间+23+27

【openlibing.ci】识别到代码检查告警抑制注释,匹配工具:flake8,请Committer检视其合理性。

likedislike
openLiBingCI成员6月16日进行代码检视2
torch_npu/_inductor/ascend_npu_ir/ascend_npu_ir/npu/npu_stream.py
@@ -11,4 +23,4 @@
1123# create a library to hold the custom op
1224npu_stream_lib = Library("npu_stream", "FRAGMENT") # noqa
25+inductor_npu_lib = Library("inductor_npu", "FRAGMENT") # noqa
1326 
1427def direct_register_custom_op(
openLiBingCI6月16日评论:

此条代码评论区间+23+27

【openlibing.ci】识别到代码检查告警抑制注释,匹配工具:flake8,请Committer检视其合理性。

likedislike
Ambi
Ambi
6月18日 评论:

合理添加

Ambi
Ambi
6月16日 评论:

compile

likedislike
ascend-robot
ascend-robot成员
6月16日 评论:

当前仓库存在以下 保护分支

Protected Branch Version Release
master
v2.12.0
v2.11.0
v2.10.0
v2.9.0
v2.7.1
v2.12.0-26.1.0
v2.10.0-26.1.0
v2.11.0-26.1.0
v2.9.0-26.1.0
v2.7.1-26.1.0
ci-test
sync-pr28113--to-v2.9.0

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
ascend-robotascend-robot成员
6月16日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
6月16日 评论:

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

💡 Tip:

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

CLA Signature Pass

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

likedislike
Ambi
Ambi
6月16日 评论:

compile

likedislike
ascend-robotascend-robot成员
6月16日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
6月16日 评论:

Ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
6月16日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
6月16日 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
6月16日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
6月16日 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
6月16日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
6月16日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
6月16日 评论:
流水线 PR-pipeline_pytorch#32848 已完成
阶段 任务名 状态 详情
编译构建 Build_X86 >>>
Build_ARM >>>
Build_LibTorch_x86 >>>
Build_LibTorch_ARM >>>
Build_X86_torchair 🛑 >>>
Build_ARM_torchair 🛑 >>>
patch_test 🛑 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
check_error >>>
CodeCheck_lintrunner >>>
开源片段检查 SCA >>>
开发者测试 UT_X86_Part_01 🛑 >>>
UT_X86_Part_02 🛑 >>>
UT_ARM_A3_Part_01 🛑 >>>
UT_ARM_A3_Part_02 🛑 >>>
UT_ARM_A2_Part_01 >>>
UT_ARM_A2_Part_02 >>>
UT_ARM_A2_Part_03 >>>
UT_inductor_Part_01 >>>
UT_inductor_Part_02 >>>
UT_inductor_Part_03 >>>
UT_inductor_Part_04 >>>
UT_DIST_ARM_Part_01 🛑 >>>
UT_DIST_ARM_Part_02 🛑 >>>
UT_DIST_ARM_Part_03 🛑 >>>
UT_DIST_ARM_Part_04 🛑 >>>
UT_ARM_A2_Select_Part_01 >>>
UT_ARM_A2_Select_Part_02 >>>
流水线 PR-pipeline_pytorch >>>
likedislike
AmbiAmbi
6月18日 修改标题为 “fix_nfa_grad_meta”,原标题为“fix_patch_node_and_npu_stream”
ascend-robotascend-robot成员
6月18日 添加了label:needs-issue
ascend-robot
ascend-robot成员
6月18日 评论:

Linking Issue Notice

@sunhaolun , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

likedislike
AmbiAmbi
6月18日 修改了pull request 的描述
zichun_ye
zichun_ye成员
6月18日 评论:

/approve

likedislike
ascend-robotascend-robot成员
6月18日 添加了label:approved
梁松伟
梁松伟成员
6月18日 评论:

/approve

likedislike
ascend-robotascend-robot成员
6月18日 添加了label:lgtm
AmbiAmbi
6月18日 修改了pull request 的描述
ascend-robotascend-robot成员
6月18日 删除了label:needs-issue
ascend-robot
ascend-robot成员
6月18日 评论:

The MR can not be merged, because of CodeReview discussion not resolved

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

likedislike
梁松伟梁松伟成员
6月18日 解决了最后一个问题
ascend-robotascend-robot成员
6月18日 合入了pull request
ascend-robot
ascend-robot成员
6月18日 评论:

Pull Request 已合并或已关闭。

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

likedislike
ascend-robot
ascend-robot成员
6月18日 评论:
流水线 pytorch_gitcode_PR_multiVersion#10967 [ commitID:a188128c ] 已完成
likedislike