Merged
feat(machine): Support host ctrlflow cache by jit #5741
可惜春残风雨又Add on Aug 27
feat(machine): Support host ctrlflow cache by jit #5741
Merged
可惜春残风雨又Add on Aug 27
可惜春残风雨又
可惜春残风雨又Collaborators
Aug 27

1、支持通过 jit ready_on_host_tensors 配置 npu_name: cpu_name 传入配对关系,算子 kernel 传入值依赖 tensor 对应的 cpu tensor
2、支持传入值依赖 tensor 场景下在 host 侧做 controlflow cache

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 可惜春残风雨又's contribution.)
可惜春残风雨又可惜春残风雨又Collaborators
Aug 27 Created pull request, commit dc4fbe2c
atomgit-bot
atomgit-bot
Aug 27 Comments:

变更摘要

本 PR 为机器侧(machine)的 host 控制流缓存(ctrlflow cache)增加 JIT 场景支持:当检测到 value-depend 但相关张量均配置了 CPU 版本(通过 ready_on_host_tensors 指定 [device_name, cpu_name] 配对)时,不再因 disableCtrlFlowCache 跳过缓存构建,而是在模拟执行中把设备张量地址替换为对应 CPU 张量地址后继续构建。为此,ready_on_host_tensors 配置项新增 list[list[string]] 配置形式,并配套扩展了配置解析/校验、Python 绑定、schema 描述及 DyndevFunctionAttribute、DevAscendProgram 等数据结构字段。

主要改动

  • 配置项支持双层列表形式: config_manager_ng.cpp 为 runtime.ready_on_host_tensors 增加 std::vector<std::vector<std::string>> 的类型名映射(list[list[string]])、类型校验豁免及 SetOptionsNg 模板实例化;controller.cpp 的 ConvertPyList 支持解析 [device_name, cpu_name] 形式的双层列表,并对内层长度、元素类型等非法输入抛出 type_error;tile_fwk_config_schema.json 的配置描述同步更新。

  • 新增数据结构字段: DyndevFunctionAttribute 新增 readyOnHostCpuPairs(std::vector<std::pair<std::string, std::string>>)字段,DevAscendProgram 结构体新增 readyOnHostAllCpu 字段,用于记录并传递 value-depend 张量的 CPU 配对信息。

  • 解析与标记逻辑: backend.cpp 的 GetReadyOnHostTensorsSet 重写为同时支持 list[string] 与 list[list[string]] 两种形式,配对形式会同时校验 device 与 cpu 张量存在性并填充 readyOnHostCpuPairs;SetDyndevProgBinary 在存在 CPU 配对时置位 devProg->readyOnHostAllCpu。

  • host 控制流缓存构建行为调整: kernel_binary.cpp 的 DisableHostCtrlFlowCacheBuild 改为仅在 value-depend 且并非所有张量都有 CPU 版本时返回跳过;emulation_launcher.cpp 在 readyOnHostAllCpu 置位时继续构建缓存,并在 BuildControlFlowCache 中建立设备张量索引到 CPU 张量地址的映射,用 CPU 地址替代 CONTROL_FLOW_CACHE_BASE_ADDR 分配的地址。

  • 补充类型错误测试用例: test_config_options_type_error.py 新增针对内层列表长度、元素类型及混合形式的错误消息断言用例。

likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 27 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 27 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 27 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/configs ✅ 尹杰, gaoxingwang (2/2) ✅ 尹杰 (1/1)
framework/src/interface/function ✅ 尹杰, gaoxingwang (2/2) ✅ 尹杰 (1/1)
framework/src/interface/tensor ✅ 尹杰, gaoxingwang (2/2) ✅ 尹杰 (1/1)
framework/src/machine ✅ 尹杰, gaoxingwang (2/2) ✅ 尹杰 (1/1)
repo-cann/pypto ✅ 尹杰, gaoxingwang (2/2) ✅ 尹杰 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
317 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 1 Added label: lgtm
Jie Yin
Jie YinCollaborators
Sep 1 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 1 Added label: approved
CANN-robot
CANN-robotCollaborators
Sep 1 Comments:

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
CANN-robotCANN-robotCollaborators
Sep 1 Merged pull request