问题2(更关键,且是问题1修复后才暴露的新缺陷):qmm_custom.asc 使用了 CANN 8.5.0 acl_prof.h 中已不存在的 3 个 profiling Range API,导致 5 个编译错误
qmm_custom.asc:232:23: error: use of undeclared identifier 'aclprofStr2Id'
qmm_custom.asc:233:23: error: use of undeclared identifier 'aclprofStr2Id'
qmm_custom.asc:248:3: error: use of undeclared identifier 'aclprofRangePushEx'
qmm_custom.asc:248:22: error: cannot initialize a parameter of type 'uint32_t'
qmm_custom.asc:254:3: error: use of undeclared identifier 'aclprofRangePop'
/usr/local/Ascend/cann-8.5.0/aarch64-linux/include/acl/acl_prof.h 中仅提供 aclprofPush/aclprofPop 等接口。教程源码与镜像内 CANN 版本文件不匹配,学员无法通过"填空"绕过。
一、问题文档/代码位置
tutorials/llm_inference/qwen3_8b/06_custom_matmul_operator_development_and_integration_with_qwen3_8b.ipynb(第4章 编译自定义算子 code cell)
tutorials/llm_inference/qwen3_8b/src/op_custom/qmm_custom/CMakeLists.txt(第16-22行)
tutorials/llm_inference/qwen3_8b/src/op_custom/qmm_custom/qmm_custom.asc(第232/233/248/254行)
环境:Notebook Lab 官方镜像,CANN 8.5.0 aarch64,torch_npu,CMake 4.2。
二、存在的问题
问题1:CMakeLists.txt 用 execute_process 取 torch_npu 路径时未过滤子进程 stdout 噪声,生成的 flags.make 含换行,make 直接报语法错误。
CMakeLists.txt 第16-20行:
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import os, torch_npu; print(os.path.dirname(torch_npu.file))" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE TORCH_NPU_PATH)
实测该命令 stdout 为两行:第一行是真实路径,进程退出时又向 stdout 打印了 "path string is NULLpath string is NULL"(结无行,OUTPUT_STRIP_TRAILING_WHITESPACE 去不掉中间的换行)。于是 TORCH_NPU_PATH 变成行字符串,生成的 build/CMakeFiles/ascendc_ops.dir/flags.make 第7行 ASC_INCLUDES 被截断,第8行变成 path string is NULLpath string is NULL/include ...,make :
CMakeFiles/ascendc_ops.dir/flags.make:8: *** missing separator. Stop.
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/ascendc_ops.dir/all] Error 2
随后 notebook 加载算子报 OSError: libascendc_ops.so: cannot open shared object file。
这是教程 CMakeLists 的健壮性缺陷,与学员填写 kernel 代码关,在该镜像上必现。
问题2(更关键,且是问题1修复后才暴露的新缺陷):qmm_custom.asc 使用了 CANN 8.5.0 acl_prof.h 中已不存在的 3 个 profiling Range API,导致 5 个编译错误
qmm_custom.asc:232:23: error: use of undeclared identifier 'aclprofStr2Id'
qmm_custom.asc:233:23: error: use of undeclared identifier 'aclprofStr2Id'
qmm_custom.asc:248:3: error: use of undeclared identifier 'aclprofRangePushEx'
qmm_custom.asc:248:22: error: cannot initialize a parameter of type 'uint32_t'
qmm_custom.asc:254:3: error: use of undeclared identifier 'aclprofRangePop'
/usr/local/Ascend/cann-8.5.0/aarch64-linux/include/acl/acl_prof.h 中仅提供 aclprofPush/aclprofPop 等接口。教程源码与镜像内 CANN 版本文件不匹配,学员无法通过"填空"绕过。
三、复现步骤
手动修复问题1(CMakeLists.txt 第20后加 string(REGEX REPLACE 取首行) )后重新 cmake && make;
四、临时规避(仅本地验证用,不作为 PR)
(a)CMakeLists.txt 在 execute_process 之后增加 string(REGEX REPLACE 只取首行) 清洗 TORCH_NPU_PATH;
(b)在 qmm_custom.asc 中为 aclprofStr2Id / aclprofRangePushEx / aclprofRangePop 增加空实现 shim。
两步之后编译成生成 libascendc_ops.so(639KB),算子可加载,06 后续 profiling 推理可继续执行。