Forums - Large difference between Float32 and Float16 precision

7 posts / 0 new
Last post
Large difference between Float32 and Float16 precision
manuel.k
Join Date: 27 Feb 23
Posts: 15
Posted: Wed, 2023-08-30 03:33
Dear Qualcomm team,
 
we experience large numerical and visual differences when using the QNN SDK to run a fully convolutional model in Float32 (libQnnGpu.so) versus Float16 (also libQnnGpu.so or libQnnHtp.so).
 
The models are converted from the same TF Lite checkpoint, the only difference is the "--float_bw 16" versus "--float_bw 32" option.
As a sanity check, we have run the same model in Pytorch using 16bit and 32bit precision and used the SNPE SDK to run with both precisions on GPU. All these tests showed only minor numerical differences and the outputs looked visually identical.
 
Can you help us find and resolve this issue? Running on the HTP backend with Float16 precision is necessary for us to continue using Qualcomm on a large scale and we would have to abandon it otherwise.
Please let me know if you can help in any way!
 
With best regards,
Manuel
  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Sat, 2023-09-02 19:25

Dear developer,

Not fully understand your questions. We assmue it's the FP16 accuracy not good as FP32. Do you know which ops accuracy dropped after layer laye analysis.

BR.

Wei

  • Up0
  • Down0
manuel.k
Join Date: 27 Feb 23
Posts: 15
Posted: Sun, 2023-09-03 02:00

Hi Wei,

 

Thank you for getting back to me!

So we have a very simple model, Conv2D-ReLU-Conv2D-ReLU-Conv2D-ReLU-Conv2D, trained in Pytorch.

If run it in Pytorch with Float32 and in Pytorch with Float16, their outputs show minimal differences.

The same is if we run it using SNPE on a phone GPU with Float32 and Float16, both outputs show minimal differences.

BUT, if we run it using QNN on a phone GPU with Float32 and Float16, the outputs suddenly have a very large difference.

 

Do you have any idea, why that is? What makes the differences between SNPE and QNN here?

  • Up0
  • Down0
xarius
Join Date: 8 Sep 23
Posts: 4
Posted: Mon, 2023-09-11 05:48

Hi Manuel,

I encounter the same problem as you, however, when I convert my Float32 model to Float16 via SNPE SDK with "--float_bw 16", the large difference between these two precisions is observed. May I know how you convert Float32 model using SNPE?

Also sent you a DM regarding this problem. Looking forward to hearing from you soon!

 

  • Up0
  • Down0
manuel.k
Join Date: 27 Feb 23
Posts: 15
Posted: Mon, 2023-09-11 10:06

Hi,

yes of course, my command to convert to SNPE is 

snpe-tflite-to-dlc \

--input_network checkpoints/${NAME}.tflite \
--input_dim input "1,1024,1024,1" \
--output_path checkpoints/${NAME}.dlc

Note that in SNPE you don't specify the float bit-width during conversion, but later by selecting the "GPU" or "GPU16" backend.
  • Up0
  • Down0
xarius
Join Date: 8 Sep 23
Posts: 4
Posted: Mon, 2023-09-11 18:19

Hi Manuel,

Thanks for your prompt reply. As far as I know, isn't that SNPE also supports Float16 inference on DSP? Are you managed to inference on SNPE DSP with float16 precision? Besides, I found that by simply converting tflite to dlc or .so files on SNPE and QNN respectively, I able to get result on HTP, have you tried this before?  

  • Up0
  • Down0
manuel.k
Join Date: 27 Feb 23
Posts: 15
Posted: Tue, 2023-09-12 11:29

Hi Xarius,

Thank you for the great exchange!

All our conversion (except for testing) is done from TF Lite to HTP using the QNN toolkit, meaning that I still experience errors when coming from TF Lite.

I have not done Float16 on the DSP using SNPE, how would I do that? I if convert a model using the command above, it fails do run. Do I need to specify Float16 during conversion somehow?

 

Cheers,
Manuel

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.