training_extensions icon indicating copy to clipboard operation
training_extensions copied to clipboard

MaskRCNN NNCF optimization failure

Open AlbertvanHouten opened this issue 7 months ago • 5 comments

Describe the bug

MaskRCNN optimization is failing with the below error

Error stacktrace ``` File "/home/devuser/training_extensions/library/src/getitune/backend/openvino/engine.py", line 372, in optimize return model.optimize( ~~~~~~~~~~~~~~^ Path(self.work_dir), ^^^^^^^^^^^^^^^^^^^^ optimize_datamodule, ^^^^^^^^^^^^^^^^^^^^ ptq_config, ^^^^^^^^^^^ ) ^ File "/home/devuser/training_extensions/library/src/getitune/backend/openvino/models/base.py", line 351, in optimize compressed_model = nncf.quantize( model=ov_model, calibration_dataset=quantization_dataset, **ptq_config, ) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/telemetry/decorator.py", line 81, in wrapped retval = fn(*args, **kwargs) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/quantization/quantize_model.py", line 189, in quantize return quantize_impl( # type: ignore[no-any-return] model=model, ...<8 lines>... advanced_parameters=advanced_parameters, ) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/openvino/quantization/quantize_model.py", line 351, in quantize_impl return quantize_fn( model=model, ...<8 lines>... advanced_parameters=advanced_parameters, ) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/openvino/quantization/quantize_model.py", line 122, in native_quantize_if_op_impl quantized_model, _ = apply_algorithm_if_bodies( ~~~~~~~~~~~~~~~~~~~~~~~~~^ quantization_algorithm, model, graphs, main_model_graph_id, calibration_dataset, subset_size, 1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/openvino/quantization/quantize_ifmodel.py", line 157, in apply_algorithm_if_bodies quantized_model = algorithm.apply(parent_model, parent_graph, parent_statistic_points, parent_dataset) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/quantization/algorithms/post_training/algorithm.py", line 113, in apply return self._pipeline.run_from_step(model, dataset, graph, 0, step_index_to_statistics) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/quantization/algorithms/pipeline.py", line 164, in run_from_step step_model = self.run_step(step_index, step_statistics, step_model, step_graph) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/quantization/algorithms/pipeline.py", line 117, in run_step current_model = algorithm.apply(current_model, current_graph, step_statistics) File "/home/devuser/training_extensions/library/.venv/lib/python3.13/site-packages/nncf/quantization/algorithms/min_max/algorithm.py", line 1071, in apply raise nncf.InternalError(msg) nncf.errors.InternalError: Statistics were not collected for the node __module.model.roi_heads.mask_roi_pool/aten::scatter/Slice_3 ```
Note that there is currently a workaround implemented to skip quantization of this layer: https://github.com/open-edge-platform/training_extensions/blob/ec3401f07f4ac9c43ba5231cc68520b305c227a1/library/src/getitune/backend/lightning/models/instance_segmentation/maskrcnn_tv.py#L317

The goal is to figure out what is causing this error instead of ignoring quantization of this layer.

Steps to Reproduce

  1. Train maskrcnn_r50 on WGISD dataset with default settings
  2. Optimize model with default settings

AlbertvanHouten avatar May 01 '26 11:05 AlbertvanHouten

Tested on latest develop, cannot reproduce anymore.

Image

leoll2 avatar May 29 '26 13:05 leoll2

It isn't reproducible as there is a workaround implemented as mentioned in the description. This issue was opened to find a proper solution instead of ignoring quantization of the problematic layer.

AlbertvanHouten avatar May 29 '26 13:05 AlbertvanHouten

I see, I thought the job would fail based on the title of this issue.

I've just checked if the quantized model at least generates good predictions, but it doesn't: for me, the MaskRCNN INT8 variant always returns empty predictions unlike the FP16 one.

leoll2 avatar May 29 '26 13:05 leoll2

"I've just checked if the quantized model at least generates good predictions, but it doesn't:" -> I think it is separate issue. We need to investigate

kprokofi avatar May 29 '26 14:05 kprokofi

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Aug 28 '26 04:08 github-actions[bot]