校准执行过程中提示“[IfmrQuantWithoutOffset]scale is illegal”
问题描述
在调用ONNX Runtime框架执行中间校准模型推理过程中,由于输入数据范围不合法,导致量化算法计算得到的scale不合理,从而校准过程失败,终止校准流程。
可能原因
原始数据不在范围:(其中EPSILON包括DBL_EPSILON double类型,FLT_EPSILON float类型,当前使用的是FLT_EPSILON类型)
AMCT量化支持计算得到的最大,因为在昇腾AI处理器量化动作做的是乘法计算: , 如果scale大于, 会小于FLT_EPSILON,此时量化后结果就不可信。因此AMCT量化算法仅支持原始数据范围在内进行量化,否则会提示不支持并提示错误信息。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[ERROR][IfmrQuantWithoutOffset][183] [IfmrQuantWithoutOffset]scale is illegal. [ERROR][ProcessScale][64] Not support scale greater than 1 / FLT_EPSILON. currentScale: 1513411575808.000000 [ERROR][IfmrQuantWithoutOffset][183] [IfmrQuantWithoutOffset]scale is illegal. [ERROR][ProcessScale][64] Not support scale greater than 1 / FLT_EPSILON. currentScale: 1492095991808.000000 [ERROR][CalScaleWithoutOffset][146] [CalScaleWithoutOffset]scale failed. [ERROR][IfmrQuantCalibration][264] CalScaleWithoutOffset failed. [ERROR][DoCalibration][126] Do IFMR calibration failed, error code: -65519. Traceback (most recent call last): File "/g/daily/xxx/bin/amct_onnx", line 8, in <module> sys.exit(main()) File "/g/daily/xxx/lib/python3.9/site-packages/amct_onnx/cmd_line_tools/command.py", line 159, in main calibration_function(args_var) File "/g/daily/xxx/lib/python3.9/site-packages/amct_onnx/cmd_line_tools/command.py", line 113, in calibration_function amct.save_model( File "/g/daily/xxx/lib/python3.9/site-packages/amct_onnx/common/utils/check_params.py", line 43, in wrapper return func(*args, **kwargs) File "/g/daily/xxx/lib/python3.9/site-packages/amct_onnx/quantize_tool.py", line 277, in save_model RecordFileParser.cmp_config(records) File "/g/daily/xxx/lib/python3.9/site-packages/amct_onnx/parser/parse_record_file.py", line 96, in cmp_config raise RuntimeError( RuntimeError: batchmatmul_7 is quantizable in config but has no record in record_file |
处理建议
根据提示信息,跳过日志中的量化层,例如上述提示信息中的batchmatmul_7 层。
父主题: FAQ