Skip to content

Cache statistics in OpenVINO/ONNX Accuracy Restorer#4113

Open
andersendsa wants to merge 1 commit into
openvinotoolkit:developfrom
andersendsa:cache_statistics
Open

Cache statistics in OpenVINO/ONNX Accuracy Restorer#4113
andersendsa wants to merge 1 commit into
openvinotoolkit:developfrom
andersendsa:cache_statistics

Conversation

@andersendsa

@andersendsa andersendsa commented Jun 25, 2026

Copy link
Copy Markdown

Changes

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.

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:

    • tests/openvino/native/quantization/test_ptq_params.py -k "test_quantize_with_accuracy_control"
    • tests/openvino/native/quantization/test_quantization_pipeline.py -k "test_quantize_with_accuracy_control"
    • tests/openvino/native/quantization/ -k "test_tune_hyperparams"
    • tests/onnx/quantization/test_ptq_params.py -k "test_quantize_with_accuracy_control"
  • 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.

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.
Copilot AI review requested due to automatic review settings June 25, 2026 14:27
@andersendsa andersendsa requested a review from a team as a code owner June 25, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants