Pull Request已成功合入, 合并人@CANN-robot
(感谢 guigui_jzh 的贡献)变更摘要
本 PR(新特性,关联 issue #151)为 A5 质量加固场景新增 --clear-l0 选项,用于在执行前对 L0A/L0B/L0C 进行确定性数据注入,以模拟复杂网络情况。改动覆盖了从 CLI 参数解析、SWITCHES 开关字段、helper kernel 编译(TIK 与 Ascend950 专用 Ascend C 两套实现)到 RTS/ACL 运行时启动与结果校验的完整链路,并调整了 profiling 循环中的清空执行顺序;同时顺带精简了大量冗余的 else 分支(纯风格重构,无行为变化)。
主要改动
-
新增
--clear-l0CLI 选项与开关字段:在ttk/cli/kernel.py增加--clear-l0参数(说明 L0A/L0B 填充指定值、L0C 为 matmul 结果);ttk/cli/bridge.py的apply_kernel_args通过_parse_clean_val("L0", args.clear_l0)写入sw.force_clear_l0;ttk/utilities/classes.py的SWITCHES新增并初始化force_clear_l0字段,测试文件同步覆盖该参数的数值/特殊浮点解析。 -
新增
clear_l0helper kernel 编译逻辑:ttk/core_modules/operator/helper_kernels.py新增基于 TIK 的clear_l0(两步 matmul 填充 L0A/L0B 并写 L0C,Ascend950 用 f16f16f16、Ascend910B 用 f16f16f32);ttk/core_modules/operator/tbe_interface.py新增Opc.compile_l0_clear(),对Ascend950平台通过_compile_l0_clear_ascendc用ccec/ld.lld编译新增的ascendc_kernels/clear_l0_950.cpp(tensor_api 实现 GM→L1→L0A/L0B→Mmad→L0C→fixpipe→GM 链路并生成clear_l0.json),其余平台走 TIK 编译;ttk/core_modules/npu/instance_refactor.py的_compile_help_kernels相应加入Opc().compile_l0_clear()。 -
打通运行时注入与校验链路:
ttk/core_modules/aclnn/acl_interface.py新增AclInterface.clear_l0透传;ttk/core_modules/runtime/rts_interface.py新增RTSInterface.clear_l0,按 128KB fp16 输入启动 helper kernel(Ascend950 额外携带 fp32 输出 GM 参数并计算期望值K*v²),并为_launch_helper_kernel新增verify_arg参数,回读设备输出校验全链路是否真正执行并记录 warning/info 日志。 -
调整执行前清空顺序:
ttk/core_modules/npu/op/rts_sequence.py的OnlineRtsProfiling._rts_kernel_sequence_v2与ttk/core_modules/npu/op_api/profiling.py的AclOpExecutor中,将原来的clear_l1 → clear_ub顺序改为clear_l0 → clear_ub → clear_l1,确保每次重复执行前先对 L0A/L0B/L0C 完成注入。 -
精简冗余
else分支:在acl_interface.py、rts_sequence.py、tbe_interface.py、rts_interface.py、classes.py等多处将if/else中else提前返回后的多余分支删除,属于无行为变化的代码清理,其中rts_interface.py的_process_exception_str等还伴随elif降级为if的等价改写。


Hi @guigui_jzh, welcome to submitting your first PR to ops-test-kit!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


当前PR是否有AI参与:
[] 否
[x] 是
__1. AI Agent 平台: opencode
__2. AI 模型: glm5.3
__3. Prompt上下文 :
PR功能描述 / 为什么需要这个合入**:
A5质量加固,模拟复杂网络情况,对L0进行注入
该PR关联的issue
(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #151
希望检视人员了解:
测试
文档更新
类型标签