Vitis Unified Backend - #1376
Conversation
…i wrapper for vitisUnified partial backend and build the skeleton code for other generation section
…tream and enable auto-restart feature on the kernel
… waiting ctrl system
…2025.2. create_xsa.tcl now dynamically checks if Vivado-version is supported and sources the right script.
|
An updated version of the tutorial can be found at Tanawin1701d/vitis_unified_backend_tutorial. I have successfully used it to build and run a Keras model with |
|
Some issues regarding the Vitis Unified backend: 1.
|
|
Hi @gflengas , thank you for your feedback.
I will keep you updated as I make progress. |
…ith both Vivado 2023.2 and 2025.2.
|
Hi! I am testing this VitisUnified PR in the context of an implementation-CI prototype, where the goal is to run a small end-to-end implementation flow and collect the generated reports/artifacts across hls4ml releases. For context, the branch I am testing from is: The test file is here The current test uses
The flow gets through HLS synthesis, cosimulation, and starts the Vitis hardware link. With This keeps repeating and does not seem to progress. Does anything in these settings look wrong, or should I change some part of the test setup for this flow? |
|
@marco66colombo Hi! Our fix was to export the env-variable ( |
|
Thanks @lolbraa, this worked! |
|
@marco66colombo Glad our frustrating experiences are not in vain! While I'm here, I'd like to get some general input from you guys. Now we're pondering (1) if the changes are welcome upstream, and (2) how we should go about creating a pull request. Do we just PR into VitisUnifiedClean on Tanawin1701d/hls4ml? And is it a deal-breaker if we haven't setup (or know how to, or have time to learn how to) set up unit tests for CI? |
|
Hey @Tanawin1701d What is the status of this? From the discussion, I think there were a few more updates planned? It would be great to integrate this into a new release to come out for FastML in late August. |
Support for KV260 and Vitis 2025.2
|
pre-commit.ci autofix |
JanFSchulte
left a comment
There was a problem hiding this comment.
Looks good to me, but I'm also not a user and can't test it hands-on. Given that we have reports from actual users though, that should be fine. I have a few smaller comments, please have a look at those.
Then I'm mostly interested to know if this is considered ~complete now or if there are any outstanding items. For example, do the FIFO-sizing deadlock and the 64-char kernel name overflow reported by @gflengas still need to be addressed?
|
|
||
| assert self.input_type == self.output_type, 'Input and Output data types must be the same type different' | ||
| assert len(model_inputs) >= 1, 'Only models with at least one input tensor are currently supported by VitisUnified' | ||
| assert len(model_outputs) >= 1, 'Only models with one output tensor are currently supported by VitisUnified' |
There was a problem hiding this comment.
The assert requires >= 1, but the message says we support one output tensor. Should the assert be ==, or the message read "at least one"?
| filedir = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
| with ( | ||
| open(os.path.join(filedir, f'../templates/vitis_unified/{self._get_project_name(model)}_axi_master.cpp')) as fin, |
There was a problem hiding this comment.
I think we need to use the hard-coded myproject here instead of {self._get_project_name(model)} to open the template file.
| def __init__( | ||
| self, bitfile_name, x_shape, y_shape, dtype=np.float32, dtbo=None, download=True, ignore_version=False, device=None | ||
| ): | ||
| super().__init__(bitfile_name, dtbo=None, download=True, ignore_version=False, device=None) |
There was a problem hiding this comment.
This seems to discard the arguments passed the this class' __init__ function and instead hard-codes these values. Same for the other driver templates.
|
|
||
| bindto = ['xilinx.com:hls:<TOP_NAME>:1.0'] | ||
|
|
||
| def enable_gie(self): |
There was a problem hiding this comment.
enable_gie and disable_gie seem to set the same value.
| # flush the buffer first | ||
| input_buffer.flush() | ||
| # prepare the data | ||
| self.set_input(0, input_buffer) |
There was a problem hiding this comment.
Does that mean that we effectively support models with exactly 1 input and 1 output? That would conflict with other places in the code that suggest >=1 is supported.
|
So in regards with the naming issue it has been resolved by nghielme#45 but it has not merged yet. The fifo-sizing issue has been resolved by some additional changes from this PR Tanawin1701d#3 on top of the previous mentioned. Tanawin1701d#3 also adds 2 more things on top of the fix:
The 2nd one is user specific and could be omitted but i think its helpful. I have also identify some additional bugs :
Will do one more run overnight to validate these 2 one last time. I have also included the PR#1376 on my test branch, so i will report back tomorrow. |
|
Thanks for the update. Looks like there's still a few things to integrate, but at least it looks there are fixes available for everything. The CI tests for this are currently failing since they expect a Vitis/Vivado installation and hardcode the path. That will not work. We do now support running synthesis in CI tests, see for example https://github.com/fastmachinelearning/hls4ml/blob/main/test/pytest/test_keras_api.py#L79, which might need some adaptation for this case, I'm not sure. The other big missing piece is documentation, of course. |
|
Quick update: the overnight runs passed. I’ve consolidated all the fixes discussed above on a branch based directly on For documentation, would a dedicated We could also reuse the existing Vitis Unified tutorial material for the proposed Part 5 - FPGA inference in the revamped hls4ml tutorial: For the CI tests, I can have a look once I have some free time. |
Description
VitisUnified backend
Motivation
Summarized features
/tools/Xilinx/Vitis/2023.2/base_platformshttps://github.com/Xilinx/Vitis-Tutorials/tree/2025.1/Vitis_Platform_Creation/Design_Tutorials/01-Edge-KV260Type of change
For a new feature or function, please create an issue first to discuss it
with us before submitting a pull request.
Note: Please delete options that are not relevant.
Tests
test/pytest/test_backend/vitis_unified.pywith 4 main aspectbridge test
VitisUnifiedwithVitiscosimulation
fifo test optimization
hardware test
test_gen_unifiedintest reproduce
test/pytest/test_backend/vitis_unified.pyfiletest_gen_unified), you should specify XPFM_PATH(path to xpfm file) to the correct place.LOG_STD == True, HLS4ML will give the HLS+linker compiling message @ console.<output_project_dir>/<prefix>_err.logor<output_project_dir>/<prefix>_out.logTest Configuration:
Checklist
pre-commiton the files I edited or added.implementation detail
file generation(HLS4ML generated file) prepare file for system Generation and pynq driversynthesis Kernel(Synthesis Kernel (v++)) do c-synthesis for HLS4ML modellinker(Linker+vivado+Bitfile+hwh)File structure
template structure
hls4ml/templates/vitis_unifiedoutput file structure
configuration
input_typeandoutput_typeare support only float and double. And it must be match{in/out}_stream_buf_sizeunit is in amount elements of thennet::arrayxpfmPath
note to developer
unifiedWorkspace. The IDE will automatically detect your projectinput_type/output_typewas set totype x(double or float), you cannot predict with numpy array with different input/output typedepthargument @axi_master write@<project_name>_dm.cppmust be match of the array size generated the output array@ ````myproject_test.cpp``` for cosim and csim.<project_folder>/unifiedWorkspace/linker/_x/link/vivado/vpl/prjnote to tutorial
https://github.com/Tanawin1701d/vitisUnifiedTutorialgenerated warning
unused parameter,deprecated pragma,dataflow conflict