Cache statistics in OpenVINO/ONNX Accuracy Restorer#4113
Open
andersendsa wants to merge 1 commit into
Open
Conversation
Currently, `quantize_with_accuracy_control_impl` performs the initial quantization pass and then may call `quantize_with_tune_hyperparams` which runs `HyperparameterTuner`. Both the initial quantization and the `HyperparameterTuner` step 0 were collecting the exact same statistics. This commit updates `quantize_impl` and its internal backend functions in OpenVINO and ONNX to explicitly collect and return `StatisticPointsContainer` by exposing a new `return_statistics` flag. The returned statistics are passed down to `quantize_with_tune_hyperparams` and the `HyperparameterTuner`, which now reuse these pre-computed statistics for the first step, removing the redundant, expensive statistics recalculation step.
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.
Changes
Currently,
quantize_with_accuracy_control_implperforms the initial quantization pass and then may callquantize_with_tune_hyperparamswhich runsHyperparameterTuner. Both the initial quantization and theHyperparameterTunerstep 0 were collecting the exact same statistics.This commit updates
quantize_impland its internal backend functions in OpenVINO and ONNX to explicitly collect and returnStatisticPointsContainerby exposing a newreturn_statisticsflag. The returned statistics are passed down toquantize_with_tune_hyperparamsand theHyperparameterTuner, which now reuse these pre-computed statistics for the first step, removing the redundant, expensive statistics recalculation step.Reason for changes
Closes issue : #3905
Related tickets
Tests
No tests were modified or added: The scope of this fix focuses strictly on performance improvements (caching redundant calculations) and preserving existing functionality, so no new tests were required. The changes were implemented securely within the backend's internal quantize_impl function boundaries.
Unit Testing: I executed the core tests related to accuracy control and hyperparameter tuning in both OpenVINO and ONNX native folders:
Test Results: All tests ran successfully (or were skipped correctly based on the parameterized environments). There were no failing tests or regressions related to accuracy control, metadata dumping, or recursive If body applications.
Code Quality Checks: I iteratively passed the automated code quality checks by resolving type annotations, imports, and edge cases like where dump_parameters was located in quantize_model.py.