-
Notifications
You must be signed in to change notification settings - Fork 281
Python Logging Integration for FINN Build Flow #1476
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
Open
tafk7
wants to merge
29
commits into
Xilinx:custom/transformer
Choose a base branch
from
tafk7:feature/logging-integration-transformer
base: custom/transformer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Python Logging Integration for FINN Build Flow #1476
tafk7
wants to merge
29
commits into
Xilinx:custom/transformer
from
tafk7:feature/logging-integration-transformer
+2,360
−902
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enable users to control Xilinx tool output verbosity (Vivado, xsim, HLS)
through Python logging instead of accepting all console spam.
Implementation:
- Enhanced launch_process_helper() with dual-mode operation (legacy/logging)
- Added pattern-based log level detection for Xilinx tool output
- Migrated internal call sites to use logging mode (vivado.py, rtlsim_exec.py)
- Added comprehensive unit tests (26 tests, all passing)
Usage:
logging.getLogger('finn.vivado').setLevel(logging.ERROR) # Suppress spam
Backward compatible (opt-in design, legacy mode default).
- Configure finn logger hierarchy to respect verbose flag in build_dataflow - Rename rtlsim subprocess loggers to finn.gcc and finn.xsim for clarity - Enable console output in verbose mode, warnings-only in quiet mode
- Remove StreamToLogger class and stream redirection logic from build_dataflow.py - Replace all print() calls with logger.info/warning/error in builder and steps - Remove no_stdout_redirect config option as it's no longer needed - Add logger instances to make_driver transformation - Remove debug print statement from vivado.py resource parsing Build output now uses Python logging throughout instead of redirecting stdout/stderr streams, enabling better integration with terminal-aware libraries and structured logging.
Replace intermediate .sh script generation with direct process invocation using launch_process_helper for Vivado, Vitis, HLS, and g++ workflows. Update build_dataflow.py verbose mode to prevent log duplication. Add environment variable expansion in launch_process_helper for consistency with shell behavior. Add glob pattern support in CppBuilder for *.cpp files.
Makes logging mode the default behavior by removing the use_logging flag and legacy tuple return mode. All callers now use the unified logging interface with integer exit codes.
…ontrol Separate finn.builder logger hierarchy from tool loggers to enable independent control of progress messages vs tool output. Add show_progress config field (default True) to control builder console output while verbose flag controls tool logger console output. Changes: - Add show_progress field to DataflowBuildConfig (default True) - Configure finn.builder with independent console/file handlers - Configure finn.builder.propagate=False to prevent cross-hierarchy leakage - Set finn tool loggers to always propagate to file regardless of verbose - Update root logger format to include logger name and level for audit trail - Console formats: builder uses clean format, tools use bracketed format Behavior matrix: - show_progress=True, verbose=False: progress on console, tools to file (default) - show_progress=False, verbose=False: completely silent console (library mode) - show_progress=True, verbose=True: all output on console (debug mode)
Adds subprocess_log_levels parameter to DataflowBuildConfig allowing library users to customize log levels for specific tool categories (e.g., hls, vivado). Build flow now applies these overrides after logger initialization.
Splits subprocess_log_levels into two independent configs: - subprocess_console_levels: controls console output (when verbose=True) - subprocess_log_levels: controls file logging (always active) Console output defaults to WARNING, file logging defaults to DEBUG. Each subprocess logger gets its own console handler to prevent duplication. Parent finn logger excludes configured children via filter.
- Standardize logger naming hierarchy (finn.compile.*, finn.vivado.*, finn.vitis.*) - Add generate_script parameter to launch_process_helper for automatic debug script creation - Implement _generate_shell_script to produce standalone executable scripts with proper quoting and environment capture - Modify _detect_log_level to strip redundant level prefixes from messages - Simplify rtlsim_exec by delegating script generation to launch_process_helper - Remove manual shell script creation in favor of automated generation - Add comprehensive test coverage for script generation and message cleaning
…former-insert-fifo-fix fix for now?
- Reorder step_hw_codegen to run PrepareIP before prepare_loop_ops_fifo_sizing so loop body nodes have correct initializer data during code generation - Add mlo_input_type metadata to FINNLoop input tensors for FIFO sizing - Generate unique FIFO names in InsertFIFO to prevent collisions - Skip standard ONNX nodes in FINNLoop cycle estimation - Use get_output_datatype() instead of direct nodeattr access for Thresholding - Preserve node names in SpecializeLayers and GiveUniqueNodeNames - Use real parameter data in FIFO depth setting when available
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replaces FINN's fragmented subprocess management with unified Python logging. All Xilinx tool invocations (Vivado, Vitis, HLS, xsim, g++) now use direct subprocess calls with structured logging, eliminating bash script wrappers and stdout redirection.
Problems solved:
verboseflag for everything)Key Changes
1. Centralized Subprocess Execution
New
launch_process_helper()insrc/finn/util/basic.pyprovides:$FINN_ROOT)ERROR:,WARNING:)All 10+ subprocess invocation sites now use this unified interface.
2. Hierarchical Logger Design
Both hierarchies write to file; console output independently controlled.
3. Multi-Level Verbosity Control
New config fields:
Operation modes:
verboseshow_progressExample - filter Vivado spam:
Defaults: console
ERROR, fileDEBUGwhen not specified.4. Code Simplification
Before:
After:
Removed:
StreamToLoggerclass (stdout redirection)use_loggingparameter (always enabled)File Changes
Core Implementation:
src/finn/util/basic.py(+257/-22) -launch_process_helper(),CppBuilderrefactorsrc/finn/builder/build_dataflow.py(+91/-38) - Logger configuration, removed stdout redirectionsrc/finn/builder/build_dataflow_config.py(+15) - New config fieldsSubprocess Call Sites (8 files):
src/finn/util/hls.py,src/finn/util/vivado.py,src/finn/core/rtlsim_exec.pysrc/finn/transformation/fpgadataflow/*.py- IP generation, Zynq synthesis, Vitis buildTests:
tests/util/test_launch_process_helper.py(+266) - 26 unit testsBenefits
Backward Compatibility
Breaking:
verbose=Falsenow silent (was progress visible). Migration: useshow_progress=True, verbose=False(new default)[timestamp] [logger] level: message(was[timestamp] message)Non-breaking:
verbose=TrueunchangedTesting
Unit Tests (34 total):
test_launch_process_helper.py(26 tests) - Subprocess execution, streaming, log level detection, environment handlingtest_logging_config.py(8 tests) - Configuration behavior verification:show_progressflag controls progress console outputverboseflag controls subprocess console outputsubprocess_log_levelsfilters file logging per toolsubprocess_console_levelsfilters console output per tool (when verbose=True)verbose-only configsverboseflag (preventsconsole_levelfrom affecting file logging when console is disabled)Integration: