refactor: replace private CANN logging interfaces - #36
Open
jarvis666666 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor: xllm-ops 整改 CANN 非公开日志接口报告
1. PR总结
该PR是把
op_common/log/log.h、OP_LOG*、OP_CHECK_IF等私有接口迁移到CANN公开的log/ops_log.h、OPS_LOG_*和OPS_CHECK。相同源码可在 CANN 9.0/9.1 构建,且比强制包含本地cann_compat.h更健壮。2. 问题与根因
CANN 9.1.0升级后编译报错,原因是:
CANN 9.0.0中的内部头文件
/usr/local/Ascend/cann-9.0.0/aarch64-linux/pkg_inc/op_common/log/log.h
变更到
/usr/local/Ascend/cann-9.1.0/aarch64-linux/include/op_common/log/log.h
很多xllm-ops算子通过包含 err/ops_err.h,间接依赖 CANN 私有头文件。
common/include/err/ops_err.h:19
#include "log/log.h"
例如 Sparse Attention 中同时存在直接和间接依赖:
sparse_attn_sharedkv_tiling.h
├── #include "log/log.h" // 直接依赖
└── #include "err/ops_err.h"
└── #include "log/log.h" // 间接依赖
直接引用 log/log.h 的 xllm-ops 头文件共有 13 个:
所以根因是 xllm-ops 的公共错误处理、fallback 和多个 tiling 基础头共同引用了 CANN 私有日志接口。当前 PR 已统
一替换为:
#include "log/ops_log.h"
并将 OP_LOG*、OP_CHECK* 迁移为 OPS_LOG_*、OPS_CHECK,从依赖源头上完成清理。
CANN的私有接口变更没有兼容性的保障,本次CANN 9.1.0 升级发现报错,统一整改成CANN 的公开接口,彻底解决后续接口兼容性问题。
3. 代码变更
目标提交修改 48 个文件,不新增兼容层,而是移除兼容层:
log/log.hlog/ops_log.hOP_LOGE/W/DOPS_LOG_E/W/DOP_CHECK_IFOPS_CHECKcann_compat.hops_xllm_utils_tiling_headers与公开编译定义ONNX plugin、fallback、tiling 模板和多个算子 host 代码同步迁移,避免只修一个首先
报错的编译单元。个人仓原子提交还合入 compressor 的同类公开日志遗漏,共修改
49 个文件;没有合入
2644097的 HCCL 闭包修改。4. 兼容性分析
ops_log.h与OPS_LOG_*op_common/log/log.h传递暴露cann_compat.h因此这不是通过
#if CANN_VERSION维护两套日志代码,而是收敛到两个版本共同支持的公开接口。
5. 测试验证结果
git diff --check通过。49 files, +1094/-1134。cann_compat.h强制包含,公开日志 target 依赖完整。