Skip to content

Commit f67e802

Browse files
committed
Applied more comments
1 parent 374b1fc commit f67e802

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

optimum/intel/openvino/modeling_base.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def _from_pretrained(
164164
from_onnx: bool = False,
165165
local_files_only: bool = False,
166166
load_in_8bit: bool = False,
167+
load_in_4bit: bool = False,
167168
**kwargs,
168169
):
169170
"""
@@ -193,8 +194,11 @@ def _from_pretrained(
193194
Whether or not to only look at local files (i.e., do not try to download the model).
194195
load_in_8bit (`bool`, *optional*, defaults to `False`):
195196
Whether or not to apply 8-bit weight quantization.
197+
load_in_4bit (`bool`, *optional*, defaults to `False`):
198+
Whether or not to apply 4-bit weight quantization.
196199
"""
197-
200+
if load_in_4bit:
201+
raise ValueError("load_in_4bit is available for OVModelForCausalLM only.")
198202
model_path = Path(model_id)
199203
default_file_name = ONNX_WEIGHTS_NAME if from_onnx else OV_XML_FILE_NAME
200204
file_name = file_name or default_file_name
@@ -262,6 +266,7 @@ def _from_transformers(
262266
task: Optional[str] = None,
263267
trust_remote_code: bool = False,
264268
load_in_8bit: Optional[bool] = None,
269+
load_in_4bit: Optional[bool] = None,
265270
**kwargs,
266271
):
267272
"""

optimum/intel/openvino/modeling_decoder.py

+2
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ def _from_pretrained(
580580
local_files_only=local_files_only,
581581
)
582582

583+
if load_in_8bit and load_in_4bit:
584+
raise ValueError("Either load_in_8bit or load_in_4bit should be set to True.")
583585
model = cls.load_model(model_cache_path, load_in_8bit=False if load_in_4bit else load_in_8bit)
584586

585587
model_type = config.model_type.replace("_", "-")

0 commit comments

Comments
 (0)