Repository navigation
[Lint] Fix all remaining ruff warnings, type errors and asserts in src - #300
Open
LinusJungemann wants to merge 2 commits into
Open
LinusJungemann wants to merge 2 commits into
LinusJungemann wants to merge 2 commits into
Conversation
Port of #262 onto the custom-op refactor branch (#257 port) and current dev. #262's own changes were re-applied file by file with dev's functional changes kept, and the same cleanup was done for the code dev added after #262 was written (QoR estimation, resource models, torch_hw_modules, the convert_to_hw transforms for PWPolyF/Pad1D/Where/ SelectToken/Requant, multi-FPGA, MLO/DDR weight offsets, ...). - src/ is ruff-clean (ruff-check pre-commit hook, v0.15.10, on ^src/), which replaces flake8 (.flake8 removed) - pyright reports 0 errors for src/ - no assert statements left in src/: FINNUserError for invalid input, FINNInternalError for broken invariants - the docstring-check GitHub action is removed, ruff's D rules cover it Behaviour is unchanged apart from exception types for invalid input, with these exceptions: - AuroraPartitioner: the connections_per_device constraint now sums over the right nodes (from #262), so ports_per_device actually limits partitions - fold_quant_weights: #262's new "unknown output shape" check is only applied to Conv/ConvTranspose targets, where the shape is used; applying it to all targets broke MatMul folding (test_brevitas_pwpolyf) - build_dataflow_steps: unlike #262, the Vitis platform is still resolved for single-FPGA Alveo builds before any transformation runs Merge fixes: streamline_plus imported #262's AbsorbSignBiasIntoMultiThreshold but called dev's renamed AbsorbScalarBiasIntoMultiThreshold (NameError); multi_dnn imported DNNContainer from the old abstract/ path. Verification: pre-commit --all-files clean, pyright 0 errors and 0 asserts in src/. Differential checks against the previous version for data_packing (11k pack/unpack cases, byte-identical), resource models (1.39M cases), QoR estimators, torch_hw_modules, generated TCL/driver code (AST comparison), and targeted fast tests for every touched area. Signed-off-by: Linus Jungemann <38974033+LinusJungemann@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
Supersedes #262: the same change, ported onto the #257 port (
refactor/custom_ops_v2) and currentdev. Depends on the custom-ops PR; review that one first. Until it is merged, this PR's diff also contains its two commits.Problem
#262 finishes the cleanup that #257 started for the custom ops:
src/passes ruff and pyright;assertis no longer used for error handling;It was written against the same 819-commit-old
devas #257. Since thendevhas changed 15 of the files #262 touches. It has also added a lot of code #262 never saw: QoR estimation, resource models,torch_hw_modules, PWPolyF/Pad1D/Where/SelectToken/Requant conversion, multi-FPGA, MLO DDR weight offsets. With ruff now gating every file undersrc/in CI, all of that code has to be clean too.Changes
devmade. Where Refactor Part 2: Fix all remaining ruff warnings, type errors and asserts in src #262 had cleaned up code thatdevhas since rewritten (e.g. FINNLoop aximm handling increate_stitched_ip, the routed-netlist power flow, thedata_packingfast paths,robust_rmtree),dev's version is kept and cleaned up the same way.devadded since Refactor Part 2: Fix all remaining ruff warnings, type errors and asserts in src #262: cleaned up to the same standard. That means annotations,cast()at untyped qonnx boundaries, pathlib, f-strings and docstrings, andFINNUserError/FINNInternalErrorinstead ofassert.ruff-checkv0.15.10 on^src/) replaces flake8;.flake8is removed.AuroraPartitioner: theconnections_per_deviceconstraint now sums over the right nodes (Refactor Part 2: Fix all remaining ruff warnings, type errors and asserts in src #262's fix). The old generator used the leftovernodefrom the previous loop, normally the last node, soports_per_devicehad no effect. Partitions that were feasible before can now be infeasible.fold_quant_weights: Refactor Part 2: Fix all remaining ruff warnings, type errors and asserts in src #262 added an "unknown output shape" check for every target op. It is now only applied to Conv/ConvTranspose, where the shape is used; applied to all targets it broke MatMul weight folding (test_brevitas_pwpolyf).build_dataflow_steps: Refactor Part 2: Fix all remaining ruff warnings, type errors and asserts in src #262 moved the Vitis platform resolution into the multi-FPGA branch. It still runs first for single-FPGA Alveo builds, so an unresolvable platform keeps failing before synthesis.streamline_plusimported Refactor Part 2: Fix all remaining ruff warnings, type errors and asserts in src #262'sAbsorbSignBiasIntoMultiThresholdbut calleddev's renamedAbsorbScalarBiasIntoMultiThreshold, which would have raised aNameError.multi_dnnimportedDNNContainerfrom the oldabstract/path.test_fifo_transaction_countsexpectsFINNUserErrorinstead ofAssertionError.Testing
Lint:
pre-commit run --all-filesis clean, including ruff on all ofsrc/.pyright srcreports 0 errors.assertstatements insrc/.Follow-ups
🤖 Generated with Claude Code