Pull Request has been successfully merged by CANN-robot.
(Thank you for dingbo929's contribution.)变更摘要
本 PR 旨在移除精度校验工具(tools/verifier/ 下的 Python 脚本)对第三方库 ml_dtypes 的依赖:不再直接使用 ml_dtypes.int4、ml_dtypes.float8_e4m3fn、ml_dtypes.bfloat16 作为 numpy 读取类型,而是将 INT4/FP8/BF16 等打包类型统一按原始存储字节(np.uint8/np.uint16)读入,再在 tensor_diff.py 中新增的 decode_tensor_data 函数里以二进制解码方式还原为 int8/float32 数值。同时将 _get_compare_config 的入参从 numpy dtype 对象改为数据类型名称字符串,并新增 --atol/--rtol 命令行参数支持容差覆盖。
主要改动
-
移除
ml_dtypes依赖并调整 dtype 映射:parse_dump_tensors.py与pass_compare.py删除import ml_dtypes,将_data_type_full_mapping/_dtype_dict中INT4、FP8、BF16分别映射为np.uint8、np.uint8、np.uint16(原始存储类型),并把pass_compare.py中两处重复的dtype_dict合并为模块级字典_dtype_dict。 -
新增二进制解码逻辑
decode_tensor_data:tensor_diff.py中新增decode_tensor_data(data, dtype_name)函数及配套解码器——_decode_int4(从uint8低 4 位符号解码为int8)、_decode_fp8(基于预构建的_FP8_E4M3FN_LUT查找表解码为float32,含 NaN 特殊值处理)和_decode_bf16(uint16左移 16 位后按float32视图还原);非打包类型原样返回。 -
对比流程接入解码:
parse_dump_tensors.py(VerifyRes与CompactDumpTensorInfoParser)和pass_compare.py(compare_*相关读取路径)在np.fromfile读入原始数据后均调用decode_tensor_data进行解码,再执行reshape与后续对比。 -
对比配置改为按 dtype 名称判定:
_get_compare_config入参由 dtype 对象改为字符串,按名称区分整型(精确匹配rtol=0, atol=0)、FP32/DOUBLE(标准容差1e-3)及其他低精度浮点(放宽容差1e-2);tensor_diff.py同时新增import numpy as np依赖。 -
新增容差覆盖命令行参数:
parse_dump_tensors.py的parse_arguments增加--atol/--rtol(默认None),在main中写入全局变量ATOL_OVERRIDE/RTOL_OVERRIDE,_get_compare_config在推导默认值后据此覆盖,并输出对应日志。


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.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/pypto | ✅ tsungl4, DCGDDD (2/2) | ✅ tsungl4 (1/1) |
| tools/verifier | ✅ tsungl4, DCGDDD (2/2) | ✅ tsungl4 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
dingbo929, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/lgtm


移除精度工具的python脚本对于第三方库ml_dtypes的依赖,bf16等数据类型的解析用二进制解码方式实现