-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V0.10 FINN Build Flow fails at step_hw_ipgen due to Error in threshold hls layer. #1060
Comments
Hi @Arbiter-glitch, from the logfiles that you have provided, I see this error: |
Hi @auphelia, I have given "test" as my build directory by setting it through export FINN_HOST_BUILD_DIR command. Apart from changes mentioned earlier, i.e. in the config file for specializing layers and the build_dataflow file. I have made no changes anywhere else in the FINN flow. I set "test" as my build dir because I am using FINN in WSL and the default host build dir temp is inside the Linux environment which cannot be accessed after the WSL has ended. I saw this particular info |
HLS has a maximum stream width limitation of 8192 bits. You could be running into this because at least one internal stream within the FINN accelerator is too wide. If this is the cause, I'm afraid you'll have to decrease the parallelism (PE or SIMD) for the offending layers or switch to the newly released RTL back-end, which shouldn't have this limitation. It's just weird that this was working in v0.9. Maybe some change caused incorrect folding of the thresholding layers? |
I used the same folding factors that I used in version v0.9. I tried replacing the layers that threw the error with RTL layers in v0.10, it gave the synthesized bitfile but not the correct output whereas in v0.9 when using old layers (HLS), even though each thresholding layers were taking a lot of resources like around 13K luts each, it gave the correct output. I had this doubt that there might be something wrong with Thresholding RTL layers in v0.10 because they were using way fewer resources like around 800Luts each when compared to old layers in v0.9. But its also entirely possible that in v0.10 the incorrect output may also not be due to Threshold layer (RTL) but some other layer. |
[Update]: To find out why the output is different in finn v0.10. I took Finn v0.9 and started to replace each of the old layers with new RTL layers, I checked at each stage. And it was only after replacing the old Thresholding hls layers with RTL layers, the output varied from the expected to give the white one again. So the problem might be with the thresholding rtl layers. |
Thanks @Arbiter-glitch for looking closer into this! |
I have replaced all the Thresholding hls layers (mem_mode "const") of v0.9 with v0.10 rtl layers. The attributes of the different threshold rtl layers are given in the images below. For image 1 in v0.10n_inp_vecs = [1, 40, 40] Function calls
Result:Too many warnings. Cannot list them all.
Result:INFO: [HLS 207-4518] in instantiation of template class 'ap_uint<18360>' requested here (/mnt/f/linux/test5/code_gen_ipgen_Thresholding_hls_0_7gbhs8ae/top_Thresholding_hls_0.cpp:28:1)
Result:A bunch of warnings and an assertion error "assert np.isclose(exp_cycles, cycles_rtlsim, atol=15)" which seems not related to variation at output. But final output went back to white colored one as soon as I used the Threshold RTL layers in v0.9. And Threshold RTL layers in v0.10 is also giving the same white output??
Note: I tried the test in v0.9 as well, but the hls layers that worked and gave correct output used mem mode "const" even though there were many warnings. But for mem_mode "decoupled". It gave the same bitwidth error in v0.9.[Update]:In light of the above tests, I tried the finn v0.10 with Thresholding hls and mem_mode="internal_embedded" and it works. |
I have posted the following images to show the variation in output due to threshold RTL layers. The first image is obtained with all threshold_HLS layers and mem_mode=internal_embedded. The Pynq board that I am targeting is the ZCU104 evaluation board. If you zoom in on the images obtained from FPGA, you can see square patches since I am processing it patch by patch and then joining them together. The second image is obtained after replacing one HLS with a Threshold RTL layer. The onnx model image is also given. All Threshold_HLS layerOne RTL Threshold layerCorresponding Onnx model image [from step_specialize_layers] |
Hi @Arbiter-glitch , |
Hi @auphelia I checked it with the dev branch, but it has not solved the problem. Earlier bad outputCurrent bad outputThe expected Correct Output taken from threshold hls layers (internal_embedded) |
Hi @Arbiter-glitch, You are dealing with quite a high bit width (for QNNs on FPGAs) and that causes (at least in the HLS Thresholding) the error in the HLS synthesis. I reproduced according to your setting above and to represent the generated thresholds, you will need the data type INT24 (like the input). When you use the Regarding the RTL Thresholding: For debugging purposes, you could execute the model either right after streamlining or after convert to hw layers with |
I did the execution of model after convert_to_hw layer and compared the output tensors according to the verfication notebook. The golden output was the output from the, all threshold hls layer network. Both results were the same for convert_to_hw layers. |
Hi @Arbiter-glitch, I know it's getting a bit into trial & error territory, but could you try your example with the latest dev again? Regarding your trial with the execution flow: |
Hi @auphelia |
Thanks @Arbiter-glitch, Could you post your next question in GitHubDiscussions please? I will close this issue and related issue #1055 and mark it as solved by PR #1077. |
Prerequisites
Possible Bug in the current version v0.10 of FINN.
Quick summary
Ipgen step for the threshold hls layers in the latest version of finn (v0.10) fails. The stack trace is included below.
This shows the error in one layer. But when the logs of other Threshold hls layers were checked, same error was found. The log files of some layers are included here.
--> ERROR: [HLS 207-814] "Bitwidth exceeds 32768 (1 << 15), the maximum allowed value" <--
logs.zip
Steps to Reproduce
export FINN_XILINX_PATH="/your/xilinx/path"
export FINN_XILINX_VERSION=2022.2
export PYNQ_BOARD=ZCU104
files.zip
Expected behavior
Completion of the Finn steps
Actual behavior
Fails at Ipgen step due to error in hls layers, resulting in not making the corresponding required IP.
Additional Info
I came across this bug because of an issue here. I tried to make it work in v0.10 by replacing the hls threshold layers that throw the error, with RTL variants but the expected image output was not produced. Since, I was getting the expected output in v0.9, I wanted to find the layer responsible for the wrong output in v0.10, by making all layers as hls like v0.9 but it threw an error in the threshold layers. Refer to steps above to reproduce the error.
The text was updated successfully, but these errors were encountered: