Pull Request已成功合入, 合并人@CANN-robot
(感谢 liu-wei 的贡献)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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| */*/README.md | ✅ 张磊, 杜慧萍 (2/2) | ✅ 杜慧萍 (1/1) |
| repo-cann/ops-cv | ✅ 张磊, 王林木 (2/2) | ✅ 王林木, 张磊 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
liu-wei, thanks for your pull request. All authors of the commits have signed the CLA. 👍


变更摘要
此 PR 主要对 examples/fast_kernel_launch_example 下的构建配置进行两项改进:将环境变量 NPU_ARCH 重命名为 NPU_SOC_VERSION(并保留向后兼容),以及将 Python wheel 的版本标签从硬编码的 cp38 改为根据当前解释器动态生成。
主要改动
- 环境变量重命名
NPU_ARCH→NPU_SOC_VERSION:在cmake/func.cmake的recursive_add_subdirectory宏中将目录路径变量从${NPU_ARCH}改为${NPU_SOC_VERSION};在setup.py的CMakeBuildCommand中将 CMake 参数从-DNPU_ARCH=改为-DNPU_SOC_VERSION=,并优先读取NPU_SOC_VERSION环境变量。 NPU_ARCH向后兼容支持:当NPU_SOC_VERSION未设置时,setup.py会回退读取旧的NPU_ARCH环境变量,若使用了旧变量名则输出 deprecation 日志提示。- Python wheel 版本标签动态适配:在
ABI3Wheel.get_tag()中将 Python 标签从硬编码的"cp38"改为f"cp3{sys.version_info.minor}",使构建的 wheel 标签自动匹配当前 Python 解释器的次版本号,并为此新增import sys。


代码审查
审查总结
本 Diff 共涉及 4 个文件的变更,审查结论如下:
| 文件 | 审查结果 |
|---|---|
examples/fast_kernel_launch_example/CMakeLists.txt |
无问题 |
examples/fast_kernel_launch_example/README.md |
无问题 |
examples/fast_kernel_launch_example/cmake/func.cmake |
无问题 |
examples/fast_kernel_launch_example/setup.py |
P1 问题 1 个 |
发现统计:
- P0:0
- P1:1
- P2:0
- P3:0
整体风险判定:中高。 setup.py 中 ABI3Wheel.get_tag() 的 python tag 动态化改动会导致在 Python ≥ 3.9 环境下构建的 abi3 轮子无法被 Python 3.8–3.9 的 pip 安装,与项目声明的 Python ≥ 3.8 支持契约相悖。建议在合入前修复该项。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


🟠 High Priority
变更点:setup.py 第 72 行,ABI3Wheel.get_tag() 方法中,原先硬编码的 python = "cp38" 被改为 python = f"cp3{sys.version_info.minor}"。
影响的行为/契约:对于 abi3 标签的 wheel,根据 PEP 425 及 pip 的兼容性判定规则,python tag 表示最低支持的 Python 版本,而非构建环境的 Python 版本。cp38-abi3 表示 "CPython 3.8 及更高版本",而 cp311-abi3 表示 "CPython 3.11 及更高版本"。
失败模式:该项目在 CMakeLists.txt 第 94 行设置了 Py_LIMITED_API=0x03080000(即 Python 3.8 稳定 ABI),二进制实际上兼容 Python ≥ 3.8。但若在 Python 3.11 环境构建,wheel tag 会变为 cp311-abi3,pip 在 Python 3.8–3.10 上将拒绝安装此 wheel,因为 tag 声明的 python 最低版本为 3.11。这与类文档字符串 "this wheel supports multiple python versions >= 3.8" 以及 python_requires='>=3.8' 的元数据相矛盾。
触发条件:使用 Python ≥ 3.9 的环境执行 python3 -m build --wheel -n 构建。
建议:将 python tag 恢复为固定常量 "cp38"(与 Py_LIMITED_API=0x03080000 保持一致),或根据 Py_LIMITED_API 定义动态推导出正确的最低版本号,而不是使用构建时 Python 的 minor 版本。


example不存在发包,不存在A版本 python环境编出来,到B版本python环境用
compile


流水线任务触发成功
任务链接 [2ccd89145f6d49e2b0921ed4b2c3da25][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_report_lcov | ✅ SUCCESS |
[2026-07-01 10:49:31] CI执行结束


流水线任务触发成功
任务链接 [e192e2c5d0444ff6a55b41a6c905de51][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_codestyle | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-07-01 10:46:24] CI执行结束


compile


流水线任务触发成功
任务链接 [37771a2b8a6a434cab2cce21aa7b9dba][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_report_lcov | ✅ SUCCESS |
[2026-07-01 11:17:21] CI执行结束


流水线任务触发成功
任务链接 [d968932d8cca4378b458ccafdf63793d][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_codestyle | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-07-01 11:13:44] CI执行结束


🔗 关联 follow-up issue:#589
本 PR 重命名 NPU_ARCH → NPU_SOC_VERSION 时保留了兼容读 + deprecation 日志,但没有给完全移除的时间表。#589 跟踪移除 NPU_ARCH 兼容层的 release 计划,建议在下次 minor release(合入 NPU_SOC_VERSION 唯一支持的版本)实施。
具体需要清理的位置、联动扫其他 example 的检查、每次 milestone 的验收 checklist 都在 issue 正文里。


/lgtm
/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
ZhaiPeiChao


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
ZhaiPeiChao


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
ZhaiPeiChao


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
ZhaiPeiChao


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
ZhaiPeiChao


/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
ZhaiPeiChao


描述
examples/fast_kernel_launch_example/里有两处需要改造,不属于同一 concern 但都局限在该 example 目录,合并到同一个修复提交:改动 A:
NPU_ARCH重命名为NPU_SOC_VERSIONPyTorch 官方
torch_npu的同名环境变量NPU_ARCH在新版本里被复用为昇腾 SOC 版本号,原本"扩展模块编译目标架构"的语义已发生迁移。继续使用旧名容易在用户 shell / CI 环境里跟torch_npu的同名变量直接撞车。统一改成NPU_SOC_VERSION更贴合"芯片型号"的语义。为了不破坏现有用户的 CI 脚本:
NPU_ARCH仍可读取,仅打印 deprecation 日志NPU_SOC_VERSION时优先使用,识别不到再回退到NPU_ARCH涉及文件:
CMakeLists.txt—NPU_ARCH的 cache 读取逻辑替换为NPU_SOC_VERSION+ fallbackcmake/func.cmake—recursive_add_subdirectory引用改NPU_SOC_VERSIONsetup.py—CMakeBuildCommand的环境变量读取迁移,并加 deprecation 日志README.md— 文档同步改动 B:wheel tag 从硬编码
cp38改为跟随实际 Python 版本ABI3Wheel.get_tag()之前硬编码python = "cp38",导致用 Python 3.9+ 构建时 wheel 文件名仍标 cp38(PEP 425 平台标签机制会因"环境 Python 版本 vs wheel 声称版本"不一致,pip 安装时直接报platform-tag-implicit-metadata类错误)。改为
f"cp3{sys.version_info.minor}"跟随sys.version_info.minor,让产物跟实际构建环境一致。涉及文件:
setup.py(ABI3Wheel.get_tag())关联的Issue
无
测试
在容器内(cp39 / cp310 / cp311)分别执行:
cd examples/fast_kernel_launch_example python3 -m build --wheel -n # 验证产物文件名 cp 标签与 python3 --version 一致 ls dist/*.whl python3 -c "import sys; print(sys.version_info.minor)" # 对照确认回退验证:保留旧
NPU_ARCH环境变量时,构建应继续成功,并在setup.py日志里看到"NPU_ARCH is deprecated, please use NPU_SOC_VERSION."。文档更新
README.md已同步:新增NPU_SOC_VERSION三种芯片档位说明(Atlas A2 →ascend910b、Atlas A3 →ascend910_93、Ascend 950PR/950DT →ascend950),并标注旧NPU_ARCH已 deprecated 但仍兼容。类型标签