Skip to content

Commit

Permalink
Change NPU to CPU in PTQ
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-malininn committed May 3, 2024
1 parent 9cfbde0 commit e5cfe06
Show file tree
Hide file tree
Showing 5 changed files with 2,301 additions and 4 deletions.
16 changes: 16 additions & 0 deletions nncf/quantization/algorithms/min_max/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def __init__(
else:
self._preset = QuantizationPreset.PERFORMANCE

self._override_device()
self._set_mode_based_defaults()
self._review_mode_based_defaults()

Expand All @@ -228,6 +229,21 @@ def __init__(
self._reset_cache()
self._algorithm_key = f"MMQ_{hash(self)}"

def _override_device(self) -> None:
"""
Overrides NPU device to use CPU quantization scheme.
"""
if self._target_device == TargetDevice.NPU:
act_bits, weight_bits = 8, 8
if self._activations_quantization_params and self._activations_quantization_params.num_bits:
act_bits = self._activations_quantization_params.num_bits
if self._weights_quantization_params and self._weights_quantization_params.num_bits:
weight_bits = self._weights_quantization_params.num_bits

if act_bits == 8 and weight_bits == 8:
self._target_device == TargetDevice.CPU
nncf_logger.debug("Target device NPU was changed to CPU!")

def _set_mode_based_defaults(self) -> None:
"""
Sets defaults for the algorithms based on the provided mode.
Expand Down
Loading

0 comments on commit e5cfe06

Please sign in to comment.