Merged
fear(ir): Keep every assemble version of one slot as outcast output #6386
lidongshengAdd on Sep 16
fear(ir): Keep every assemble version of one slot as outcast output #6386
Merged
lidongshengAdd on Sep 16
lidongsheng
lidongshengCollaborators
Sep 16

Related Issue: #2559

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for lidongsheng's contribution.)
lidongshenglidongshengCollaborators
Sep 16 Created pull request, commit f1926604
lidongshenglidongshengCollaborators
Sep 16 Associated issue: [Task|任务跟踪]: 新IR适配
atomgit-bot
atomgit-bot
Sep 16 Comments:

变更摘要

本 PR 改变了 outcast 的生成语义:此前同一个 raw tensor(同一个 slot)的多次 assemble 只会保留"最新"的一个 outcast 版本,现在改为保留该 slot 的每一个 assemble 版本作为独立的 outcast 条目,且同一组版本共享第一个版本的 outcast 缓冲区(运行时同一个 slot、每个 assemble 写对应一个 outcast 条目),并让 outcast 参数与对应版本的 slot 通过 TensorSlotManager::SetSameSlot 关联,解决多版本写入同一 slot 时的 WAR(写后读)冲突问题。核心改动分布在 Function::MakeOutcasts/CreateOutcastTensor、RootFunctionBuilder::ComputeOutcast/FinalizePathFunc、TensorSlotManager::SetSameSlot/Dump,并新增 Python 侧 GetSlotInfo 接口及相应测试。

主要改动

  • MakeOutcasts/CreateOutcastTensor 支持多版本 outcast:CreateOutcastTensor 新增 shareRaw 与 name 参数;MakeOutcasts 先快照原始 raw tensor 并按 rawmagic 分组,组内后续版本复用第一个版本的 outcast 缓冲区(outSymbol->tensor = shareRaw),同时保留各自的版本名,并对 origin 与 outSymbol 调用 SetSameSlot 使 outcast 参数解析到对应版本的 slot id。

  • ComputeOutcast 由"按 raw magic 去重保留最新"改为"保留全部版本":先收集所有被消费/函数输出/IsGetTensorDataOutcast 的 operand 的 rawMagic,再遍历 op 把所有命中 raw magic 的 operand 都通过 AddOriginOutcast 注册为 origin outcast;FinalizePathFunc 中还为共享同一 raw tensor 的 outcasts 建立同 slot 关联。

  • SetSameSlot 合并逻辑改为顺序无关、保留较早 slot:当 srcTensor->Id() > dstTensor->Id() 时交换二者,使先创建的 slot tensor(参数先入槽)保持规范,已捕获到 ioslot 列表中的 id 依然有效;Dump 改为对 (index, slot) 对排序输出,以适配 slot index 即 tensor id、可能超出条目数的情况。

  • 新增 Python 接口与类型桩更新:绑定层新增 GetSlotInfo(返回 {tensor name: slot id},同名 slot 共享运行时缓冲)并补充 .pyi 桩;Program.functions 由 list[Function] 调整为按函数名索引的 dict[str, Function]。

  • 测试重构与新增用例:test_common.py 抽取 _run_pass_pipeline/run_root_function 公共流程;新增 test_issue_2912.py 验证 unroll 后多个 out 版本共享同一 out slot;原 test_assemble_latest_outcast.pypto 更名为 test_assemble_all_versions.pypto,相关 .py/.pypto 黄金文件更新为"每个 assemble 版本均保留为 outcast 条目且共享一个 slot"的期望结果。

likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 16 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 16 Added label: cann-cla/yes
lidongsheng
lidongshengCollaborators
Sep 16 Comments:

compile

likedislike
lidongshenglidongshengCollaborators
Sep 16 Pre merge succeeded (commit_id: a8e7bcabd4c088375b8af6c65fd41521494af7e1)
CANN-robot
CANN-robotCollaborators
Sep 16 Comments:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robotCollaborators
Sep 16 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
framework/src/interface/function ✅ gaoxiang618, 尹杰 (2/2) ✅ gaoxiang618, 尹杰 (2/1)
framework/src/interface/tensor ✅ gaoxiang618, 尹杰 (2/2) ✅ gaoxiang618, 尹杰 (2/1)
python/pypto/pypto_impl ✅ 尹杰, gaoxiang618 (2/2) ✅ 尹杰 (1/1)
repo-cann/pypto ✅ gaoxiang618, 尹杰 (2/2) ✅ gaoxiang618, 尹杰 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robotCANN-robotCollaborators
Sep 16 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,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 16 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,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robot
CANN-robotCollaborators
Sep 16 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 16 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 16 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 16 Added label: ci-pipeline-passed
Jie Yin
Jie YinCollaborators
Sep 16 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 16 Added label: approved
gaoxiang618
gaoxiang618Collaborators
Sep 16 Comments:

/approve
/lgtm

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