已合并
[v2.10.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix and mod test case for 32GB chip #45117
[v2.10.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix and mod test case for 32GB chip #45117
已合并
ffmh创建于 11 天前
ffmh
ffmh成员
11 天前

【合入来源】

如有社区issue,请关联issue链接
请勿携带内部流程信息(需求链接、问题单、内部issue等)

https://gitcode.com/Ascend/pytorch/issues/3991

  • [✕ ] 需求
  • [ ✓] 问题单
  • [ ✓] issue/工单
  • [ ✓] 重构优化
  • [✕ ] 资料更新

【修改方案】

请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列
如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

问题现象:
PTA 26.1.0 仓库中的 third_party/acl 头文件来自 CANN 9.1.0,而编译环境安装的是 CANN 9.0.0。当同一个编译单元同时包含两套版本的 ACL 头文件时,会出现类似以下错误:aclmdlRITask 未声明、未定义或类型不匹配
aclmdlRITask 是 CANN 9.1.0 头文件所依赖的定义,但 CANN 9.0.0 对应头文件中不存在该定义或定义不兼容。

根因分析:
1 当前头文件查找路径不统一:PTA 源码中大量使用以下写法
#include "third_party/acl/inc/acl/acl_mdl.h"
因为编译命令中包含 PTA 项目根目录,这种写法会直接命中 PTA 26.1.0 仓库内由 CANN 9.1.0 导入的头文件:torch_npu/third_party/acl/inc/acl/acl_mdl.h
但该头文件内部使用的是标准 SDK 相对路径:#include "acl/acl_base.h"
编译器无法相对 acl_mdl.h 所在目录找到 acl/acl_base.h,因此转而按照全部 -I 目录依次搜索。如果 CANN 9.0.0 的 include 路径排在 PTA 内置 ACL 路径前面,就会命中:CANN-9.0.0/include/acl/acl_base.h
同一个翻译单元最终形成:
acl_mdl.h -> PTA third_party 中的 CANN 9.1.0 版本
acl_base.h -> 环境 CANN 9.0.0 版本
这是一种“首层头文件由源码路径固定版本、传递头文件由 -I 顺序选择版本”的混合查找模式。

2 问题不局限于 acl_mdl.h
同样风险存在于所有能够继续 include 其他 CANN 头文件的入口,包括:
acl/...
aml/...
profiling/...
graph/...
ge/...
op_proto/...
因此不能只修复出现错误的某一个头文件,也不能只替换 acl_mdl.h。必须统一整个 CANN 头文件族的查找规则。

修改目标:
修改后需要满足
源码不再包含 third_party/acl/inc/... 这种仓库物理路径。
ACL、AML、profiling 等头文件全部通过统一 include root 查找。
一个编译 target 对 CANN 头文件只选择一套版本。
CANN 9.0.0 环境构建时,首层和传递头文件必须全部命中 CANN 9.0.0。
使用 PTA 内置头文件构建时,首层和传递头文件必须全部命中 PTA 内置的同一套版本。
wheel、libtorch_npu、C++ Extension 和 Inductor/AOT 使用同一目录契约

修改方案:
1、代码中使用 PTA 内置 ACL 头文件的地方,删除 third_party/acl/inc/ 物理路径前缀,统一改成从 include root 查找
2、打包或安装时,把 third_party/acl/inc 下需要公开的目录按原相对结构复制到安装产物的公共 include 根目录

【资料变更】

请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

不涉及

【接口变更】

请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”

不涉及

【功能验证】

说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤
新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

cann 9.0.0 + pta 26.1.0的vllm-ascend安装验证成功
image.png

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

  • [✓ ] 代码注释完备,正确记录错误日志
  • [✓ ] 代码实现进行了返回值、空指针等校验
  • [✓ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
  • [✓ ] PR持续集成流水线(CI)执行通过,代码检查无异常
likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ffmh 的贡献)
ffmhffmh成员
11 天前 创建了 pull request,commit 29745ae9
ffmhffmh成员
11 天前 关联了issue:[Bug]: fix cann and pta header mixing use
atomgit-bot
atomgit-bot
11 天前 评论:

变更摘要

该 PR 修复 PTA 26.1.0(内置 CANN 9.1.0 头文件)与编译环境 CANN 9.0.0 头文件混用的构建问题(关联 issue #3991)。根因是源码中大量使用 #include "third_party/acl/inc/..." 仓库物理路径,导致首层头文件命中 PTA 内置版本、传递头文件按 -I 顺序命中环境 CANN 版本,形成混合查找。修改方案为:源码统一改为从 include root 按 <acl/...><aml/...><graph/...><profiling/...> 方式查找 CANN 头文件,打包/安装时将 third_party/acl/inc 下头文件按原相对结构复制到安装产物公共 include 根目录,并保留旧路径的转发头文件以兼容历史 include 写法;同时顺带调整了部分 32GB 芯片上的测试用例。

主要改动

  • 统一 CANN 头文件查找方式:在 torch_npu/csrc 下约 60 个源文件中,将 "third_party/acl/inc/acl/acl.h""third_party/acl/inc/acl/acl_base.h""third_party/acl/inc/acl/acl_rt.h" 等物理路径写法批量改为 <acl/acl.h><acl/acl_base.h><acl/acl_rt.h> 形式(含 acl_mdl.hacl_prof.hacl_op_compiler.hsuper_kernel.herror_codes/rt_error_codes.h,以及 aml/aml_fwk_detect.hgraph/operator.hprofiling/prof_api.h 等),third_party/hccl/inc/hccl/hccl.h 中的 #include "third_party/acl/inc/acl/acl.h" 同步改为 <acl/acl.h>
  • 打包与安装产物头文件布局调整setup.pybuild_libtorch_npu.py 不再按 third_party/acl/inc/*/*.h 等固定 glob 复制 ACL 头文件,改为递归收集 third_party/acl/inc 下全部 *.h,按相对路径复制到安装产物 include/ 根目录,并为每个头文件在旧路径 include/third_party/acl/inc/... 生成仅含 #pragma once#include <...> 的转发头文件,保证旧 include 路径兼容。
  • 构建工具与扩展编译的 include 路径统一torch_npu/csrc/inductor/cpp_builder.pyinclude_pathstorch_npu/utils/cpp_extension.pyNpuExtensiontorch_npu/_inductor/ascend_npu_ir/npu/utils.py 均移除 include/third_party/acl/inc 这一独立 include 目录,统一使用公共 include 根目录;third_party/acl/libs/build_stub.sh 新增 ACL_INCLUDE_DIR 参数(默认 ../inc),stub 编译与 Extension 编译共用同一安装头文件根目录,并加 set -eci/access_control_test.py 中安装 ACL 头文件查找路径由 include/third_party/acl/inc/acl 改为 include/acl
  • 相关测试用例适配test/allocator/test_pluggable_allocator_extensions.pytest/test_npu_expandable_segments.pytest/test_sanitizer_pluggable_allocator.pybuild_stub 中传入安装 include 路径并移除 third_party/acl/inc include 目录,pluggable_allocator_extensions.cpp 同步改用 <acl/acl_base.h><acl/acl_rt.h>
  • 32GB 芯片测试用例调整test/distributed/rpc/test_single_machine_multi_devices.pytest_async_call_for_cpu 的 tensor 由 torch.rand(1024, 1024, 1024) 调小为 torch.rand(1024, 1024, 4)test/test_npu_expandable_segments.pytest_pluggable_allocator 的 tensor 由 (7500, 1024, 1024) 调小为 (5000, 1024, 1024)test/distributed/test_fault_mode.py 移除了对 "wait for compute device to finish failed" 错误文案的断言。
likedislike
atomgit-bot
atomgit-bot
11 天前 评论:

代码审查

✅ 未发现问题

likedislike
ascend-robotascend-robot成员
11 天前 添加了label:stat/needs-squash
ascend-robotascend-robot成员
11 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
11 天前 评论:

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.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
ci chujinjin, liangsongwei (2/2) chujinjin, liangsongwei (2/1)
repo-Ascend/pytorch chujinjin, liangsongwei (2/2) chujinjin, liangsongwei (2/1)
test chujinjin, liangsongwei (2/2) chujinjin, liangsongwei (2/1)
torch_npu/_inductor chujinjin, liangsongwei (2/2) chujinjin, liangsongwei (2/1)
torch_npu/csrc/distributed chujinjin, liangsongwei (2/2) chujinjin, liangsongwei (2/1)
torch_npu/csrc/inductor liangsongwei, chujinjin (2/2) chujinjin, liangsongwei (2/1)
torch_npu/csrc/profiler chujinjin, liangsongwei (2/2) chujinjin, liangsongwei (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robot
ascend-robot成员
11 天前 评论:

当前仓库存在以下 保护分支

Protected Branch Version Release
master
v2.7.1
v2.10.0-26.1.0
v2.9.0-26.1.0
v2.10.0
v2.7.1-26.1.0
v2.9.0
v2.11.0-26.1.0
v2.12.0-26.1.0
v2.11.0
v2.12.0
ci-test

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
ffmhffmh成员
11 天前 关联了里程碑:v26.1.1
ascend-robotascend-robot成员
11 天前 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
11 天前 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
11 天前 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
11 天前 评论:
流水线 PR-pipeline_pytorch#63010 [ commitID:b6e9eb23 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_X86 >>>
Build_ARM >>>
Build_X86_torchair 🛑 >>>
Build_ARM_torchair 🛑 >>>
patch_test 🛑 >>>
Build_X86_213 🛑 >>>
Build_ARM_213 🛑 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 codecheck_pre-commit >>>
check_error >>>
lintrunner >>>
开源片段检查 SCA >>>
开发者测试 UT_ARM_A3_Part_01 🛑 >>>
UT_ARM_A3_Part_02 🛑 >>>
UT_ARM_A2_Part_01 >>>
UT_ARM_A2_Part_02 >>>
UT_ARM_A2_Part_03 >>>
UT_inductor_Part_01 >>>
UT_inductor_Part_02 >>>
UT_inductor_Part_03 >>>
UT_inductor_Part_04 >>>
UT_DIST_ARM_Part_01 >>>
UT_DIST_ARM_Part_02 >>>
UT_DIST_ARM_Part_03 >>>
UT_DIST_ARM_Part_04 >>>
UT_ARM_A2_Select_Part_01 >>>
UT_ARM_A2_Select_Part_02 >>>
UT_ARM_A2_Part_01_213 🛑 >>>
UT_ARM_A2_Part_02_213 🛑 >>>
UT_ARM_A2_Part_03_213 🛑 >>>
UT_inductor_Part_01_213 🛑 >>>
UT_inductor_Part_02_213 🛑 >>>
UT_inductor_Part_03_213 🛑 >>>
UT_inductor_Part_04_213 🛑 >>>
UT_DIST_ARM_Part_01_213 🛑 >>>
UT_DIST_ARM_Part_02_213 🛑 >>>
UT_DIST_ARM_Part_03_213 🛑 >>>
UT_DIST_ARM_Part_04_213 🛑 >>>
UT_ARM_A2_Select_Part_01_213 🛑 >>>
UT_ARM_A2_Select_Part_02_213 🛑 >>>
流水线 PR-pipeline_pytorch >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0, LiNuohang, taohuoquan, Jesse, WSs_321]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
ffmhffmh成员
11 天前 修改了pull request 的描述
梁松伟
梁松伟成员
10 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
10 天前 添加了label:approved
chujinjin成员
10 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
10 天前 添加了label:lgtm
ascend-robotascend-robot成员
10 天前 合入了pull request
ascend-robot
ascend-robot成员
10 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#14422 [ commitID:b6e9eb23 ] 已完成
likedislike