-
Notifications
You must be signed in to change notification settings - Fork 448
pytest based synthesis tests #1257
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
base: main
Are you sure you want to change the base?
Conversation
merge hls4ml main into add-conftest
Add synthesis tests pytest
update add-conftest branch
Add conftest
test/pytest/conftest.py
Outdated
"Vivado": {"csim": False, "synth": True, "export": False}, | ||
"Vitis": {"csim": False, "synth": True, "export": False}, | ||
"Quartus": {"synth": True, "fpgasynth": False}, | ||
"oneAPI": {"build_type": "fpga_emu", "run": False}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fpga_emu
is actually just C compilation, so this needs to be changed, though to what I am not sure. The descriptions are given in https://github.com/oneapi-src/oneAPI-samples/tree/release/2025.0/DirectProgramming/C%2B%2BSYCL_FPGA/Tutorials/GettingStarted/fpga_compile#four-compilation-options and they correspond to fpga_emu
, report
, fpga_sim
, and fpga
. I would guess report
unless you want to run cosim, in which case it's fpga_sim
. The first two don't require Quartus, while the last two do.
Can we test this to actually run SYNTHESIS tests? |
yes, but if the env var 'RUN_SYNTHESIS' is not set, the default is False. |
test/pytest/ci-template.yml
Outdated
- if [ $EXAMPLEMODEL == 1 ]; then git submodule update --init example-models; fi | ||
- pip install .[testing,sr,optimization] | ||
- sudo yum install -y libidn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What causes this requirement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to fix an error that is present only while running the code in the GitLab runner and not if I run the docker image locally.
It happens with oneAPI backend.
It was a test, but it didn't fix the issue and I'll remove it in the next commit.
Failed gitlab job: https://gitlab.cern.ch/fastmachinelearning/hls4ml/-/jobs/54542573
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/opt/Xilinx/Vitis/2020.1/tps/lnx64/cmake-3.3.2/bin/cmake
$ cmake --version
cmake: error while loading shared libraries: libidn.so.11: cannot open shared object file: No such file or directory
I found that the difference is that the cmake
comes from the Vitis installation with Vitis2020.1.
This is what causes the error.
Do you all agree with the approach of storing all the baselines in a dedicated GitHub repo, and add it as a module under |
merge remote branch 'upsteam/main'
I generally agree about storing the baselines in a dedicated repo. Is CERN gitlab or regular github preferred? We create the testing containers in gitlab. I don't really have a preference. |
Description
This PR introduces synthesis tests into the
pytest
framework forhls4ml
.The goal of this change is to automate the validation of HLS synthesis reports against predefined baselines to ensure stability and correctness over time, using pytest.
Main Changes
New submodule in
tests/pytests
calledbaselines
, which is a Git submodule pointing to an external repository containing synthesis baselines.backend_tool/version/test_artifacts.json
Baseline management:
New
conftest.py
file to manage shared pytest fixtures:synthesis_config
fixture, which provides:RUN_SYNTHESIS
environment variable).VIVADO_VERSION
, defaulting to2023.1
).model.build(...)
.Synthesis logic centralized in
synthesis_helpers.py
:test_synthesis
.RUN_SYNTHESIS=true
, runs synthesis and compares the report to baseline.Tolerances for report values can be specified using
get_tolerance
.CI integration:
ci-template.yml
updated accordingly).Current test coverage:
test_keras_api.py
includes synthesis tests at the moment.baseline_file_name
to the test,test_synthesis()
.OneAPI backend is currently skipped due to missing synthesis reports support.
Type of change
Tests
Synthesis tests are run conditionally and compared against versioned baselines if
RUN_SYNTHESIS=true
is set in the environment.Checklist
pre-commit
on the files I edited or added.