Skip to content

Commit 768c2a4

Browse files
committed
[SW-191317] Raise exception according to hqt config object
Change-Id: I06ba8fa912c811c88912987c11e5c12ef328348a
1 parent 52a98f4 commit 768c2a4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

neural_compressor/torch/algorithms/fp8_quant/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424

2525
def save_calib_result(model):
2626
import habana_quantization_toolkit as hqt
27-
hqt.finish_measurements(model)
27+
if (hasattr(model, "__hqt_config__") and
28+
isinstance(model.__hqt_config__, hqt._quant_common.quant_config.Fp8cfg)):
29+
# TODO SW-184714 modify hqt notation to inc notation once code is ported
30+
hqt.finish_measurements(model)
31+
else:
32+
raise NotImplementedError("Saving calibration results currently supported only in HPU.")
33+
2834

2935

3036
def update_mode(config_path, measure_step=False, quant_step=False):

neural_compressor/torch/quantization/quantize.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,5 @@ def convert(
220220

221221

222222
def finalize_calibration(model):
223-
if hasattr(model, "quant_config") and isinstance(model.quant_config, FP8Config): # FP8
224223
from neural_compressor.torch.algorithms.fp8_quant import save_calib_result
225-
226224
save_calib_result(model)
227-
else:
228-
raise NotImplementedError("`finalize_calibration` only supports FP8 measurement now.")

0 commit comments

Comments
 (0)