Skip to content

Commit fc3a5ed

Browse files
Avoid adding unneccessary changes
1 parent 21a6ed5 commit fc3a5ed

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

optimum/intel/openvino/modeling_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,11 +791,11 @@ def _export(
791791
)
792792
compile_only = False
793793

794-
ov_config = OVConfig(dtype="auto")
795-
if load_in_8bit is None and quantization_config is None:
796-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
797-
# models larger than 1B parameters will be quantized to int8
794+
# If load_in_8bit and quantization_config not specified then ov_config is set to None and will be set by default in convert depending on the model size
795+
if load_in_8bit is None and not quantization_config:
798796
ov_config = None
797+
else:
798+
ov_config = OVConfig(dtype="fp32")
799799

800800
variant = kwargs.pop("variant", None)
801801

optimum/intel/openvino/modeling_decoder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ def _export(
321321
if use_cache:
322322
task = task + "-with-past"
323323

324-
ov_config = OVConfig(dtype="auto")
325-
if load_in_8bit is None and quantization_config is None:
326-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
327-
# models larger than 1B parameters will be quantized to int8
328-
ov_config = None
324+
# If load_in_8bit and quantization_config not specified then ov_config is set to None and will be set by default in convert depending on the model size
325+
if load_in_8bit is None and not quantization_config:
326+
ov_export_config = None
327+
else:
328+
ov_export_config = OVConfig(dtype="auto")
329329

330330
stateful = kwargs.pop("stateful", ensure_stateful_is_available(warn=False) and use_cache)
331331

@@ -349,7 +349,7 @@ def _export(
349349
local_files_only=local_files_only,
350350
force_download=force_download,
351351
trust_remote_code=trust_remote_code,
352-
ov_config=ov_config,
352+
ov_config=ov_export_config,
353353
stateful=stateful,
354354
model_loading_kwargs=model_loading_kwargs,
355355
library_name=cls._library_name,

optimum/intel/openvino/modeling_diffusion.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,12 @@ def _export(
608608
)
609609
compile_only = False
610610

611-
ov_config = OVConfig(dtype="auto")
612-
if load_in_8bit is None and quantization_config is None:
613-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
614-
# models larger than 1B parameters will be quantized to int8
611+
# If load_in_8bit and quantization_config not specified then ov_config is set
612+
# to None and will be set by default in convert depending on the model size
613+
if load_in_8bit is None and not quantization_config:
615614
ov_config = None
615+
else:
616+
ov_config = OVConfig(dtype="auto")
616617

617618
torch_dtype = kwargs.pop("torch_dtype", None)
618619

optimum/intel/openvino/modeling_open_clip.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ def _export(
245245
# would end-up removing the directory containing the underlying OpenVINO model
246246
cls._model_save_dir_tempdirectory_instance = save_dir
247247

248-
ov_config = OVConfig(dtype="auto")
249-
if load_in_8bit is None and quantization_config is None:
250-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
251-
# models larger than 1B parameters will be quantized to int8
248+
# If load_in_8bit and quantization_config not specified then ov_config is set to None and will be set by default in convert depending on the model size
249+
if load_in_8bit is None and not quantization_config:
252250
ov_config = None
251+
else:
252+
ov_config = OVConfig(dtype="fp32")
253253

254254
def fn_get_submodels(model):
255255
return {"model_text": model.text}
@@ -370,11 +370,11 @@ def _export(
370370
# would end-up removing the directory containing the underlying OpenVINO model
371371
cls._model_save_dir_tempdirectory_instance = save_dir
372372

373-
ov_config = OVConfig(dtype="auto")
374-
if load_in_8bit is None and quantization_config is None:
375-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
376-
# models larger than 1B parameters will be quantized to int8
373+
# If load_in_8bit and quantization_config not specified then ov_config is set to None and will be set by default in convert depending on the model size
374+
if load_in_8bit is None and not quantization_config:
377375
ov_config = None
376+
else:
377+
ov_config = OVConfig(dtype="fp32")
378378

379379
def fn_get_submodels(model):
380380
return {"model_vision": model.visual}

optimum/intel/openvino/modeling_seq2seq.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,11 @@ def _export(
593593
"Please provide openvino model obtained using optimum-cli or saved on disk using `save_pretrained`"
594594
)
595595
compile_only = False
596-
ov_config = OVConfig(dtype="auto")
597-
if load_in_8bit is None and quantization_config is None:
598-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
599-
# models larger than 1B parameters will be quantized to int8
596+
# If load_in_8bit and quantization_config not specified then ov_config is set to None and will be set by default in convert depending on the model size
597+
if load_in_8bit is None and not quantization_config:
600598
ov_config = None
599+
else:
600+
ov_config = OVConfig(dtype="fp32")
601601
stateful = kwargs.get("stateful", True)
602602
variant = kwargs.pop("variant", None)
603603

optimum/intel/openvino/modeling_visual_language.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,12 @@ def _export(
653653
if task is None:
654654
task = cls.export_feature
655655

656-
ov_config = OVConfig(dtype="auto")
657-
if load_in_8bit is None and quantization_config is None:
658-
# If load_in_8bit and quantization_config are not specified then ov_config is set to None, and
659-
# models larger than 1B parameters will be quantized to int8
656+
# If load_in_8bit and quantization_config not specified then ov_config is set to None and will be set by default in convert depending on the model size
657+
if load_in_8bit is None and not quantization_config:
660658
ov_config = None
659+
else:
660+
# Export in fp32 if compression won't be applied later
661+
ov_config = OVConfig(dtype="fp32" if load_in_8bit is False else "auto")
661662

662663
stateful = kwargs.pop("stateful", ensure_stateful_is_available(warn=False) and use_cache)
663664
variant = kwargs.pop("variant", None)

0 commit comments

Comments
 (0)