Merged
feat(ir): Support versioned assemble outputs #5787
feat(ir): Support versioned assemble outputs #5787
Merged
赵俊涵Add on Aug 29
赵俊涵
赵俊涵Collaborators
Aug 29

背景

旧版前端中,连续多次 assemble 写入同一 destination 时会复用同一个
LogicalTensor。这种表达无法区分不同写入产生的逻辑版本,因此中间读取
难以准确引用第 N 次写入后的快照,并可能观察到后续写入的值。

为配合新版 IR assemble 语义及 token 访存时序,本 PR 完成前端侧适配:
每次用户可见的 assemble 写入生成独立的 LogicalTensor 版本,同时继续
共享同一个底层 RawTensor。

主要修改

  • 调整 LogicalTensor::NextVersion:

    • 创建独立的 LogicalTensor;
    • 共享原有 RawTensor;
    • 完整复制 shape、offset、动态 shape、storage、memory type、自定义属性等逻辑元数据;
    • 将新版本注册到当前 Function 的 TensorMap;
    • 不再由版本创建过程生成 token,token 统一交由 TokenPass 推导。
  • 调整 Function 构建与 outcast 处理:

    • 连续写入同一 RawTensor 时保留各次写入对应的逻辑版本;
    • 生成 Function outcast 时按 RawTensor 去重,并选择最新的
      LogicalTensor 版本;
    • 增加稳定的轻量级排序模式,在满足依赖关系的同时尽量保持原始 op 顺序。
  • 补充 token 依赖支持:

    • Function operation 排序纳入 ProducerOpsByToken 依赖;
    • 轻量级排序同时处理数据依赖和 token 依赖;
    • DCE 在新版 assemble 机制开启时保留推导出的 result token,供后续
      token 清理 Pass 分析;
    • Operation 从 JSON 恢复时同步恢复输入、输出 token 信息。
  • 增强相关基础逻辑:

    • 处理 LogicalTensor 自消费场景下的排序依赖;
    • 为 assemble shape 推导补充空操作数及维度不完整场景的保护。

测试

  • 新增 LogicalTensor::NextVersion 元数据继承测试;
  • 新增连续多次 assemble 共享同一 RawTensor、但生成不同
    LogicalTensor 版本的测试;
  • 新增重复 assemble 后仅选择最新版本作为 outcast 的快照测试。

影响范围

本 PR 仅包含新版 assemble/token 方案的前端及基础 IR 适配。

MergeDanglingAssembleOutput、TokenPass 的完整访存依赖计算,以及
RemoveRedundantReshape、MergeViewAssemble、GraphPartition、
OoOSchedule、GlobalMemoryReuse 等下游 Pass 的适配不在本 PR 的修改范围内。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 赵俊涵's contribution.)
赵俊涵赵俊涵Collaborators
Aug 29 Created pull request, commit 120fbf84
CANN-robotCANN-robotCollaborators
Aug 29 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Aug 29 Added label: cann-cla/yes
赵俊涵赵俊涵Collaborators
Aug 29 Associated issue: [Task|任务跟踪]: 前端插入token依赖,删除冗余token
CANN-robot
CANN-robotCollaborators
Aug 29 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 ✅ 尹杰, DCGDDD, tsungl4 (3/2) ✅ 尹杰, DCGDDD (2/1)
framework/src/interface/ir/transforms ✅ 尹杰, tsungl4 (2/2) ✅ 尹杰 (1/1)
framework/src/interface/operation ✅ 尹杰, tsungl4 (2/2) ✅ 尹杰 (1/1)
framework/src/interface/tensor ✅ tsungl4, DCGDDD, 尹杰 (3/2) ✅ 尹杰, DCGDDD (2/1)
repo-cann/pypto ✅ DCGDDD, 尹杰, tsungl4 (3/2) ✅ 尹杰, DCGDDD (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Aug 29 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 29 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
赵俊涵
赵俊涵Collaborators
Aug 29 Comments:

/compile

likedislike
赵俊涵赵俊涵Collaborators
Aug 29 Pre merge succeeded (commit_id: 119f59f72929fc19bc313e2a8fe23a146dd03d6b)
CANN-robotCANN-robotCollaborators
Aug 29 Added label: ci-pipeline-running
赵俊涵
赵俊涵Collaborators
Aug 29 Comments:

/compile

likedislike
赵俊涵赵俊涵Collaborators
Aug 29 Pre merge succeeded (commit_id: a8ff25a4dcf1c401f185435751d07afe899ed353)
11 event messages are collapsed here。 See more
赵俊涵赵俊涵Collaborators
Aug 31 Modify description of pull request
lidongsheng
lidongshengCollaborators
Aug 31 Comments:

/lgtm

likedislike
杨旭
杨旭Collaborators
Aug 31 Comments:

/approve

likedislike
Jie Yin
Jie YinCollaborators
Aug 31 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 31 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Aug 31 Merged pull request