Merged
fix(ir): Bump ooo scope iter in new frontend loop unroll #5813
LiuChangAdd on Aug 31
fix(ir): Bump ooo scope iter in new frontend loop unroll #5813
Merged
LiuChangAdd on Aug 31
LiuChang
LiuChangCollaborators
Aug 31

修复新前端循环展开(loop unroll)中 OOO scope 迭代器计数不正确的问题:将原先集中在 Controller 类(位于 pypto/_controller.py)的编译状态(循环索引生成、函数内标志、ooo scope 迭代器)抽取到新的 CompileState 类(pypto/_compile_state.py),并在新前端循环展开路径(pypto/pil/ops.py 的 _dyn_for/_loop_unroll)中补充 ooo scope 迭代器的重置与递增逻辑,使 sg_set_ooo_scope 能为每个迭代编码出唯一 id,与旧前端 _LoopFunction.Iterator 的行为对齐。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for LiuChang's contribution.)
LiuChangLiuChangCollaborators
Aug 31 Created pull request, commit 23532aff
LiuChangLiuChangCollaborators
Aug 31 Associated issue: [Task|任务跟踪]: 新IR适配
atomgit-bot
atomgit-bot
Aug 31 Comments:

变更摘要

该 PR 修复新前端循环展开(loop unroll)中 OOO scope 迭代器计数不正确的问题:将原先集中在 Controller 类(位于 pypto/_controller.py)的编译状态(循环索引生成、函数内标志、ooo scope 迭代器)抽取到新的 CompileState 类(pypto/_compile_state.py),并在新前端循环展开路径(pypto/pil/ops.py 的 _dyn_for/_loop_unroll)中补充 ooo scope 迭代器的重置与递增逻辑,使 sg_set_ooo_scope 能为每个迭代编码出唯一 id,与旧前端 _LoopFunction.Iterator 的行为对齐。

主要改动

  • 编译状态迁移至 CompileState: 将 Controller 上的 next_loop_idx、in_function、init_ooo_scope_iter、bump_ooo_scope_iter、get_ooo_scope_iter、begin_function、end_function 等接口迁移至新的 _compile_state.CompileState,_controller.py、config.py 及相关调用点全部改用 CompileState。
  • 循环展开逐迭代递增 ooo scope iter: 在 ops.py 的 _loop_unroll 中,对 batch 与非 batch 两个分支的每次迭代都调用 CompileState.bump_ooo_scope_iter(),保证每个展开迭代获得唯一的 scope 计数。
  • 循环入口重置 ooo scope iter: 在 _dyn_for 进入循环时调用 CompileState.init_ooo_scope_iter() 重置计数,使 config.py 中 sg_set_ooo_scope 编码(sg_set_ooo_scope * 10000 + get_ooo_scope_iter())在每次循环中产生唯一的迭代 id。
  • 测试适配新状态类: test_function_abort_recording.py 中将针对 Controller.in_function 的断言与导入改为 CompileState.in_function,验证函数录制异常时状态重置的行为保持不变。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 31 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 31 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 31 Comments:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robotCollaborators
Aug 31 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 ✅ DCGDDD, tsungl4 (2/2) ✅ tsungl4 (1/1)
repo-cann/pypto ✅ tsungl4, DCGDDD (2/2) ✅ tsungl4 (1/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
Aug 31 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
Aug 31 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
LiuChang
LiuChangCollaborators
Aug 31 Comments:

compile

likedislike
LiuChangLiuChangCollaborators
Aug 31 Pre merge succeeded (commit_id: 599b6501e60cff2fc56c76ecf3f24fd50fb31996)
8 event messages are collapsed here。 See more
LiuChangLiuChangCollaborators
Aug 31 virtual merging failed, update merge request[project_id: 8635329, iid: 5813, target_commit_sha: fe20d7268b2c8a09ec1188bb01ce0aecfeedc87c], message: MR has no commits
CANN-robot
CANN-robotCollaborators
Aug 31 Comments:

Warning

The PR commit(s) can not be got, please check it!

likedislike
LiuChangLiuChangCollaborators
Aug 31 Pre merge succeeded (commit_id: bd7ebd5a4e1564ac519139a7e694b1938d23a6f3)
LiuChangLiuChangCollaborators
Aug 31 Pushed 1 commits:a0a132c7-fix(ir): Bump ooo scope iter in new frontend loop unroll
LiuChangLiuChangCollaborators
Aug 31 Pre merge succeeded (commit_id: 2132791b7bf07ad0346cb9d19dea224e2c14ce9b)
CANN-robotCANN-robotCollaborators
Aug 31 Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
Aug 31 Added label: cann-cla/yes
LiuChang
LiuChangCollaborators
Aug 31 Comments:

compile

likedislike
LiuChangLiuChangCollaborators
Aug 31 Pre merge succeeded (commit_id: aed72954fe0be46ab342f4d0f8349d3c16b1603c)
CANN-robotCANN-robotCollaborators
Aug 31 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Aug 31 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 31 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 31 Added label: ci-pipeline-passed
LiuChangLiuChangCollaborators
Sep 1 Modify description of pull request
LiuChang
LiuChangCollaborators
Sep 1 Comments:

/ai summary

likedislike
atomgit-bot
atomgit-bot
Sep 1 Comments:

变更摘要

本 PR 修复新前端循环展开(loop unroll)中 OOO scope 迭代器计数不正确的问题:将原先集中在 pypto/_controller.py 的 Controller 类中的编译状态(循环索引生成器、函数内标志、atomic scope 迭代器)抽取到新增的 CompileState 类(pypto/_compile_state.py),并在新前端循环展开路径(pypto/pil/ops.py 的 _dyn_for/_loop_unroll)补充 ooo scope 迭代器的重置与递增逻辑,使 sg_set_ooo_scope 能为每个迭代编码出唯一 id,与旧前端 _LoopFunction.Iterator 的行为对齐。

主要改动

  • 新增 CompileState 类:在 pypto/_compile_state.py 新增 CompileState,集中承载原 Controller 的 _loop_idx_generator、in_function、_atomic_scope_iter_id 状态,并提供 init_atomic_scope_iter、bump_atomic_scope_iter、get_atomic_scope_iter、next_loop_idx、begin_function、end_function 等类方法。
  • _controller.py 迁移状态与调用:删除 Controller 类定义及 begin_function/end_function 函数,function、_LoopFunction.Iterator、loop 中原本调用 Controller.xxx 的地方全部改为 CompileState.xxx。
  • 补充新前端循环展开的迭代计数逻辑:在 pypto/pil/ops.py 的 _dyn_for 循环入口调用 CompileState.init_atomic_scope_iter() 重置迭代器,在 _loop_unroll 的 batch 与非 batch 分支每次派发循环体前调用 CompileState.bump_atomic_scope_iter() 递增,使每个迭代的 scope id 唯一。
  • scope id 编码路径跟随迁移:pypto/config.py 的 _validate_and_encode_scope_id 中从 pypto._controller.Controller.get_atomic_scope_iter() 改为 pypto._compile_state.CompileState.get_atomic_scope_iter()。
  • 更新相关单测:test_function_abort_recording.py 中针对函数内标志的断言由 Controller.in_function 改为 CompileState.in_function,并补充 CompileState 的导入。
likedislike
Incorrect?
lidongsheng
lidongshengCollaborators
Sep 1 Comments:

/approve

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

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 1 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 1 Merged pull request