Merged
fix(pil): Fix loop-carry crash by updating dotted-slot tensors #6415
LiuChangAdd on Sep 17
fix(pil): Fix loop-carry crash by updating dotted-slot tensors #6415
Merged
LiuChangAdd on Sep 17
LiuChang
LiuChangCollaborators
Sep 17

同步主线修改

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for LiuChang's contribution.)
LiuChangLiuChangCollaborators
Sep 17 Created pull request, commit 21cb5e6e
LiuChangLiuChangCollaborators
Sep 17 Associated issue: [Bug-Report|缺陷反馈]: QkvRmsNormRopeCache 的测试中,当 JIT 装饰器开启 create_new_logical_tensor=True 时,在编译期 dispatch 阶段抛出异常,用例直接失败:
atomgit-bot
atomgit-bot
Sep 17 Comments:

变更摘要

该 PR 修复了 PIL(Python 中间层)中 dotted slot(带点号的槽位,如 d.a)在循环携带(loop-carry)场景下导致的崩溃问题。核心改动位于 python/pypto/pil/pir.py 的 Scope 类赋值逻辑:当槽位当前值和新赋的值都是 pypto.Tensor 时,不再用 setattr 整体替换对象,而是通过 Journal.record(current) 记录旧 tensor 后调用 current.set_logical_tensor(value.logical_tensor()) 进行原地更新,从而避免在循环迭代中因替换 dotted-slot 对象而崩溃;非 Tensor 场景仍保持原有「记录 + setattr」行为。配套更新了多个 .pypto IR 测试期望输出与 test_incr_fa.py 中的断言(PR 背景为同步主线修改)。

主要改动

  • 修复 Scope 的 dotted-slot 赋值逻辑(python/pypto/pil/pir.py):当 getattr(obj, key) 的当前值与新值均为 pypto.Tensor 时,改为 Journal.record(current) 后原地更新 logical tensor(current.set_logical_tensor(value.logical_tensor())),其余情况保持原有的 Journal.record(obj, key) + setattr(obj, key, value) 行为,修复循环携带变量导致的崩溃。
  • 更新 test_attr_move1~test_attr_move7 的 IR 期望输出:循环内的迭代变量由带点号名称(如 %d.a_1、%e.a_0、%h.inner.c_0)改为匿名临时变量(如 %$0_2、%$2_0),反映 tensor 原地更新后不再产生命名 dotted-slot 变量的新 IR 形态。
  • 更新 python/tests/ut/ir/test_incr_fa.py 断言:循环迭代变量名称断言由带点号的形式(如 ctx.loop_tensors.attention_output_3、ctx.temp_update_tensors.max_update)改为不带点号的名称(如 attention_output_19、max_update_1),与新的命名规则保持一致。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 17 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 17 Added label: cann-cla/yes
LiuChang
LiuChangCollaborators
Sep 17 Comments:

compile

likedislike
LiuChangLiuChangCollaborators
Sep 17 Pre merge succeeded (commit_id: eda96cb6119acd7689faa2bf7241c120dc640719)
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
python/pypto/pil ✅ tsungl4, DCGDDD (2/2) ✅ tsungl4, DCGDDD (2/1)
repo-cann/pypto ✅ DCGDDD, tsungl4 (2/2) ✅ DCGDDD, tsungl4 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 17 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 17 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-failed
LiuChang
LiuChangCollaborators
Sep 17 Comments:

compile

likedislike
LiuChangLiuChangCollaborators
Sep 17 Pre merge succeeded (commit_id: c0f24bb95e41d02ba057a1e9e46e775441bb3e12)
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 17 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-passed
lidongsheng
lidongshengCollaborators
Sep 17 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Added label: approved
杨旭
杨旭Collaborators
Sep 17 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 17 Closed associated issue
CANN-robotCANN-robotCollaborators
Sep 17 Merged pull request