专栏算法工具链基于sparse4d进行ptq量化报错

基于sparse4d进行ptq量化报错

已解决
浮浮浮2025-10-16
395
28

oe版本:3.0.31

 

执行:ptq量化时报错 hb_compile--config/private/oe_code/horizon_j6_open_explorer_v3.0.31- py310_20241231/samples/ai_toolchain/horizon_model_train_sample/scripts/hb_compile_fast- perf/full_compile_config.yaml

 报错信息如下:

2025-10-1502:34:16,208 ERROR Model inference failed,check if the model matches the given input!

 2025-10-1502:34:16,210 ERROR *** ERROR-OCCUR-DURING hmct.api.build_model***,error message: onnx model inferencefailed even if batch_size==1 

 

其中,npy校准数据的维度和onnx提示的一样, yaml配置的onnx输入 如下维度: 

input_name: input.1;onnx::Reshape_1;onnx::Clip_2;onnx::Slice_3

input_shape: 6x3x256x704;6x4x4;1x384x11;1x384x256

已用hb_compile --fast-perf --model xxx.onnx --march nash-m做快速模型验证,能正常输出hbm模型。

请问大佬这个问题出在哪里,如何解决。

 

几点小疑问:

1.sparse 4d做ptq转换时,onnx的4个输入分别为(6,3,256,704),(6,4,4),(1,384,11),(1,384,256),fast-perf没问题,传统模式编译时,报batch_size错误,是否需要处理模型输入维度,比如统一改为batch_size=1

2.上述网络在做ptq转换时,是否有精度损失,损失能否控制在2%以内

 

附件:
算法工具链
征程6
评论5
0/1000
  • Vincent
    Lv.4

    你好,意思是快速性能验证没问题,走正常的hb_compile编译就报这个错误是吗

    2025-10-16
    0
    2
    • 浮浮浮回复Vincent:

      是的,快速性能验证没问题 ,hb_compile --configxx.yaml就报错

      2025-10-16
      0
    • Vincent回复浮浮浮:

      拿hb_config_generator生成config再试下

      2025-10-16
      0
  • Vincent
    Lv.4

    我觉得最好把input_shape形状维度跟input_layout_train一样

    2025-10-16
    0
    0
  • Vincent
    Lv.4

    或者你直接拿generator生成基于你这个onnx的配置文件吧

    2025-10-16
    0
    0
  • 浮浮浮
    Lv.1

    不小心点了结贴,还有一些疑问需要请教

    2025-10-20
    0
    0
  • Vincent
    Lv.4

    生成什么就是什么

    2025-10-16
    0
    21
    • 浮浮浮回复Vincent:

      校准数据集是在train过程中保存的,应该没有问题吧

      2025-10-16
      0
    • 浮浮浮回复Vincent:

      使用的这个命令生成的配置文件:hb_config_generator --full-yaml --model float.onnx --march nash-m。配置文件显示的onnx输入是: input_name: input.1;onnx::Reshape_1;onnx::Clip_2;onnx::Slice_3 input_shape: 6x3x256x704;6x4x4;1x384x11;1x384x256。我准备的数据形状也是 : input_name: input.1;onnx::Reshape_1;onnx::Clip_2;onnx::Slice_3 input_shape: 6x3x256x704;6x4x4;1x384x11;1x384x256。两者是一样的。

      2025-10-16
      0
    • Vincent回复浮浮浮:

      input_layout_train呢

      2025-10-16
      0
    • 浮浮浮回复Vincent:
      input_parameters:input_layout_rt: '[]'
      # input_batch: 1
      input_layout_train: NCHW;NCHW;NCHW;NCHW
      input_name: input.1;onnx::Reshape_1;onnx::Clip_2;onnx::Slice_3
      input_shape: 6x3x256x704;6x4x4;1x384x11;1x384x256
      # input_shape: 6x3x256x704;6x4x4;1x384x11;1x384x256
      input_type_rt: featuremap;featuremap;featuremap;featuremap
      input_type_train: featuremap;featuremap;featuremap;featuremap
      # mean_value: 103.94 116.78 123.68;103.94 116.78 123.68;103.94 116.78 123.68;103.94
      # 116.78 123.68
      norm_type: no_preprocess;no_preprocess;no_preprocess;no_preprocess
      # scale_value: 0.017;0.017;0.017;0.017
      separate_batch: false
      2025-10-16
      0
    • Vincent回复浮浮浮:

      还是报同样的错吗

      2025-10-16
      0
    • Vincent:

      看一下校准集数据维度跟onnx模型输入维度能不能对应上

      2025-10-16
      0
    • Vincent回复浮浮浮:

      你这个快速验证没问题,快速验证是按照模型输入shape自动生成的随机校准数据,正常的编译遇到问题 我感觉还是校准集数据准备的有问题

      2025-10-16
      0
    • 浮浮浮回复Vincent:

      我上传了数据集和配置和onnx模型,能麻烦大佬看一下吗?我还是没看出来问题

      2025-10-16
      0
    • Vincent回复浮浮浮:

      收到,校准集呢

      2025-10-16
      0
    • 浮浮浮回复Vincent:

      都在里面

      2025-10-16
      0
    • Vincent回复浮浮浮:

      有没有最原始的那个onnx模型,不是这个编译过程产生的float_ori.onnx

      2025-10-17
      0
    • 浮浮浮回复Vincent:

      文件最大上传100M,上传不上来怎么发给您

      2025-10-17
      0
    • Vincent回复浮浮浮:

      邮箱吧,试一试。hqliu666@163.com

      2025-10-17
      0
    • 浮浮浮回复Vincent:

      已发送,附件较大,下载期限10.31到期。

      2025-10-19
      0
    • Vincent回复浮浮浮:

      收到

      2025-10-20
      0
    • Vincent回复浮浮浮:

      我编译一下试试看

      2025-10-20
      0
    • 浮浮浮回复浮浮浮:

      已上传nas:https://nas.tztek.com:5021/sharing/h8NPZ4Azf

      2025-10-20
      0
    • Huanghui回复浮浮浮:
      你好,我编译那个1017的模型是可以正常编译出来的,然后你说的hbm有个输入shape被改动了?但是我用hb_model_info查看并没有改动呀,与onnx输入都是对应的
      2025-10-20
      0
    • 浮浮浮回复Huanghui:
      请问一下,1016的包也是没有报错的吗,yaml有改动什么吗?

      有一个疑问需要请教,sparse 4d做ptq转换时,onnx的4个输入分别为(6,3,256,704),(6,4,4),(1,384,11),(1,384,256),fast-perf没问题。但是传统模式编译时,报batch_size错误,是否需要处理模型输入维度,比如统一改为batch_size=1。
      2025-10-20
      0
    • Huanghui回复浮浮浮:

      1016的我还没试我一会儿也编译一下试试看

      2025-10-21
      1
    • 浮浮浮回复Huanghui:

      能麻烦您给一下详细的操作手法吗?看看有什么不一样的地方。比如命令和配置文件的修改

      2025-10-21
      0