nncf icon indicating copy to clipboard operation
nncf copied to clipboard

Cache statistics in OpenVINO/ONNX Accuracy Restorer

Open andersendsa opened this issue 5 months ago • 1 comments

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.

andersendsa avatar Jun 25 '26 14:06 andersendsa

HI @andrey-churkin could you pls let me know if this pr needs any changes or if it is good to merge

andersendsa avatar Jun 27 '26 12:06 andersendsa