Skip to content

Updated Frontend and Settings#118

Open
bwintermann wants to merge 77 commits intodevfrom
finn_settings_rework
Open

Updated Frontend and Settings#118
bwintermann wants to merge 77 commits intodevfrom
finn_settings_rework

Conversation

@bwintermann
Copy link

@bwintermann bwintermann commented Oct 9, 2025

During the last weeks when I had some time I worked on updating our frontend. @LinusJungemann had mentioned that we probably shouldn't hardcode the dependencies into the code, and I thought that the settings management was a bit difficult to understand.

With that in mind, and due to the several research topics that we are currently working on (that will need to be merged and configured), I reworked mainly the following things:

TODO

  • Fix merge issues
  • Update Wiki entries

Implemented Features and Fixes

(Updated 03.11.25, 14.11.25, 19.11.25, 03-05.12.25, 05.01-13.01)

Settings

  • Settings are now managed by a dedicated Settings-class (FINNSettings) that can be used like any other class and will automatically adjust environment variables
    • The settings are being validated by Pydantic
  • Globally available FINNSettings, replacing most uses of os.environ[...]
  • The default location for FINN_DEPS is now at finn_deps instead of deps
    • The previous value would create a directory deps in site-packages. This could potentially cause confusion with other packages and doesn't mark the directory belonging to FINN, thus the change
  • Note: Currently, when FINN operations are called from outside the usual flow, often times settings are needed but not initialized. For this we provide finn.util.settings.initialize_dummy_settings() to create a settings object with default values and a non-existing flow config dummy.yaml (which can be retrieved using get_settings() as usual). In the future we might move this into the __init__.py of all relevant sub-packages so that users (for example in the notebooks) don't have to call the helper function mentioned above anytime they want to do something with FINN outside the flow.

Dependencies

  • Dependencies are defined in a YAML file, defaulting to external_dependencies.yaml. This can be configured in settings and environment via FINN_DEPS_DEFINITIONS
    • finn_xsi is part of the dependencies now, not requiring an extra setup
    • Despite the installation being in DependencyManager now, finn_xsi still needs to be loaded in prepare_finn to make sure it's available when skipping dependency updates
  • Already downloaded and up-to-date dependencies are not downloaded again, speeding up the startup
  • finn deps update got two more options:
    • --accept-defaults to accept missing settings files (explained below again)
    • --force to delete the dependency directory and freshly install all dependencies again
  • If dependency updates are skipped, the outdated dependencies are listed. If all dependencies are missing, a critical warning is printed, but FINN continues to run.
    • For some dependencies we cannot check whether they need to be updated, so they are always displayed as outdated.

Commands / Click

  • Added finn check command. This simply starts the environment and exits. It does not update dependencies. This is useful to check paths and FINNs behaviour before starting a flow, or for testing.
  • Reworked run_finn.py. Any click function is described by decorators that tell the name of the argument that they add to the function.
  • Fixed several smaller issues (finn config subcommands for example)
  • Verify input and verify output, as well as a output directory overwrite option (Add optional override of path settings from build config via CLI options #130)
  • Added utility commands: finn deps {edit,show}
  • Added utility commands: finn settings {create,edit,show} (and renaming finn config)
  • Wizards to setup FINN+ and flow configurations (automatically started upon missing settings, but skippable via --accept-defaults)
    • The configuration wizard can also be manually started with finn wizard settings or finn settings create
    • The flow config wizard can only be started manually using finn wizard flow
  • By default includes all DataflowOutputTypes, so you never accidentally forget them
  • The model can now be passed in the config in the field model_path. This way it's possible to run finn build cfg.yaml
  • New command finn auto tries to run FINN by automatically finding a flow config and a model. It searches for {cfg,config}.{yaml,yml,json} and model.onnx primarily, but if one isnt found defaults to the first available .yaml/yml/json/onnx file
    • So if you have config.yaml and model.onnx in the same directory, simply running finn auto will find these and start FINN. Note however, that this command does not have any of the other configuration options. If no settings are found this will also automatically start the setup wizard as well.

Tests

  • Single tests can be executed from the CLI now as well: finn test --variant custom --name <name>, where name can be a test specification in pytest syntax (like test_dir/complex_tests.py::ComplexTest::test_function, etc.)
  • Doctests can be run from CLI as well: finn test -v doctest --name finn.transformation.fpgadataflow.mymodule
  • Removed tests concerning build_dataflow_directory, since the function itself is removed as well
  • Updated session fixture to use the new global settings. When calling finn test, the main functions sets FINN_SETTINGS to the given file so that the tests receive these settings as well

Other

  • It is now forbidden to start a flow from a YAML or JSON if the flow config contains unknown keys. This is to prevent invalid test/benchmark results in case there is a typo in some configuration option.
  • XILINX_LOCAL_USER_DATA=no is set automatically, unless a value is already set for this variable. If it does not exist or is set to a different value than no, a warning is emitted.
  • Introduced the --batch parameter. This disables the wizards, forces default values if no settings were found and disables interactive / live displays
  • Fixed a bug where when setting output_dir: ~ in the flow config, a directory named None would be placed in ~. This is fixed now
  • Fixed a bug where in certain cases freshly installed packages were not immediately available. This bug might have existed before the PR already but was possibly shadowed by something else
  • Docstrings for various methods that needed them after editing the matching files (@LinusJungemann)
  • GHA don't add new comments everytime the docstring checker notes something, and instead modifies the existing comment (@LinusJungemann)
  • Added a note to the README to inform users about automatic dependency downloads

Backwards Compatibility
No:

  • Since finn can now start the wizards when some files are missing (and you have to specifically pass --accept-defaults to avoid this), some automated scripts might break.
  • finn deps and finn config commands were renamed
  • Renaming of a few command line parameters

In the future, we'll remove the flow config from the settings, but this will be a new PR.

Patch Notes Style Summary

Commands

  • finn check Start FINN to check that the environment is configured properly
  • finn deps {edit,show}
  • finn deps update
    • --accept-defaults Start even if settings files are missing
    • --force Delete all dependencies and re-download them
  • finn config -> finn settings {create,edit,show} Create a new config (wizard), edit the current one, show the current one
  • finn wizard {config,flow} Start the wizard for settings / flow creation
  • finn build <config> Does not require a model, if given by the model_path field in the flow config
  • finn auto Tries to search for config and model and start a build flow. (Looks for {cfg,config}.{yaml,yml,json} and model.onnx)
  • finn test --variant custom --name <pytest-specification> Start a single test from the suite with the given name, marker, filename, etc.
  • finn test --variant doctest --name <module path> Run all doctests of the given module/package
  • --batch option to disable interactive displays and wizards

Settings

  • Environment variables got replaced by FINNSettings
    • To use in FINN internal code use finn.util.settings.get_settings()
    • To use FINN internal code outside the FINN compiler, call finn.util.settings.initialize_dummy_settings() first to create a blank gloabal settings object

Dependencies

  • DependencyManager new class to handle everything regarding dependencies
  • Dependencies are defined in external_dependencies.yaml
  • Existing dependencies are not downloaded again (with a few exceptions)

Other

  • The flow config can contain model_path so that FINN can be started with the config alone
  • The flow config may not contain keys that are not DataflowBuildConfig member names
  • By default, all DataflowOutputTypes are used as an output product
  • Fixed some smaller issues with the finn settings commands
  • Refactored run_finn.py slightly
  • Removed unused code in build_dataflow.py
  • Updated tests to use the new settings
  • Fixed a bug where setting output_dir: ~ would lead to creation of a None directory in the users home
  • Fixed a bug where sometimes freshly installed packages were not immediately available
  • Docstrings, Typing and fixes to the Docstring Checker GHA, in addition to various bugfixes for changes in this PR by @LinusJungemann
  • XILINX_LOCAL_USER_DATA=no gets set automatically. Can be disabled by overwriting the variable before starting FINN.
  • Added a note to the README to inform users about automatic dependency downloads

@bwintermann
Copy link
Author

On @fpjentzsch suggestion moved our frontend to use Pydantic. There are still some bits that need fixing, but it does start normally. We can simply and read from and assign to settings and it gets saved into the environment directly as well. Also simplifies our main run_finn.py quite a bit.

@bwintermann bwintermann marked this pull request as ready for review October 28, 2025 10:37
@bwintermann
Copy link
Author

bwintermann commented Oct 28, 2025

@fpjentzsch I fixed several issues. The PR is ready for merging. I had the thought of making FINNSettings available everywhere in FINN to completely replace the environment variables, however a singleton wouldn't work with multiple FINN instances running, and passing the settings object down requires a lot of (compatibility breaking) changes. If there is another way to do it, I'd gladly implement it.

@LinusJungemann I am unsure, but I think the Builder Config Documentation Check might be broken, atleast it doesn't list the undocumented fields (I didn't add any either), and it fails with a syntax error on the match clause (Python version too old?)

Edit: Actually providing a settings singleton (and some nicer output along the way) might be possible. Ill see the next weeks if its doable.

@eki-project eki-project deleted a comment from github-actions bot Nov 14, 2025
@eki-project eki-project deleted a comment from github-actions bot Nov 14, 2025
@eki-project eki-project deleted a comment from github-actions bot Nov 14, 2025
@eki-project eki-project deleted a comment from github-actions bot Nov 14, 2025
@eki-project eki-project deleted a comment from github-actions bot Nov 14, 2025
@eki-project eki-project deleted a comment from github-actions bot Nov 14, 2025
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

📋 Docstring Check Report

Docstring check failed!

Missing Docstrings Details:

📄 src/finn/custom_op/fpgadataflow/hls/elementwise_binary_hls.py:

  • Line 1158: class 'ElementwiseMax_hls'

📄 src/finn/util/basic.py:

  • Line 353: function 'get_driver_shapes'

Total missing docstrings: 2

How to Fix:

Please add docstrings to the missing functions, classes, and modules listed above.

Docstring Guidelines:

  • All modules should have a module-level docstring
  • All public functions and methods should have docstrings
  • All private functions should have docstrings
  • All classes should have docstrings
  • Use triple quotes (""") for docstrings
  • Follow PEP 257 conventions
Raw output from docstring checker
Checking 31 specified Python file(s) (excluding tests folder):
  - scripts/check_docstrings.py
  - src/finn/benchmarking/bench_base.py
  - src/finn/builder/build_dataflow.py
  - src/finn/builder/build_dataflow_config.py
  - src/finn/core/rtlsim_exec.py
  - src/finn/custom_op/fpgadataflow/hls/elementwise_binary_hls.py
  - src/finn/custom_op/fpgadataflow/hls/thresholding_hls.py
  - src/finn/custom_op/fpgadataflow/hlsbackend.py
  - src/finn/custom_op/fpgadataflow/hwcustomop.py
  - src/finn/custom_op/fpgadataflow/matrixvectoractivation.py
  - src/finn/custom_op/fpgadataflow/rtl/convolutioninputgenerator_rtl.py
  - src/finn/custom_op/fpgadataflow/rtl/fmpadding_rtl.py
  - src/finn/custom_op/fpgadataflow/rtl/matrixvectoractivation_rtl.py
  - src/finn/custom_op/fpgadataflow/rtl/streamingdatawidthconverter_rtl.py
  - src/finn/custom_op/fpgadataflow/rtl/streamingfifo_rtl.py
  - src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py
  - src/finn/custom_op/fpgadataflow/rtl/vectorvectoractivation_rtl.py
  - src/finn/custom_op/fpgadataflow/vectorvectoractivation.py
  - src/finn/interface/interface_utils.py
  - src/finn/interface/manage_deps.py
  - src/finn/interface/manage_tests.py
  - src/finn/interface/run_finn.py
  - src/finn/interface/settings.py
  - src/finn/transformation/fpgadataflow/instrumentation.py
  - src/finn/transformation/fpgadataflow/make_zynq_proj.py
  - src/finn/util/basic.py
  - src/finn/util/exception.py
  - src/finn/util/exception_snapshot.py
  - src/finn/util/logging.py
  - src/finn/util/memutil.py
  - src/finn/util/settings.py

❌ Missing docstrings found:

📄 src/finn/custom_op/fpgadataflow/hls/elementwise_binary_hls.py:
  - Line 1158: class 'ElementwiseMax_hls'

📄 src/finn/util/basic.py:
  - Line 353: function 'get_driver_shapes'

Total missing docstrings: 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants