Skip to content

Commit 0abed19

Browse files
committed
add nncf check
1 parent f1c9d6f commit 0abed19

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

optimum/intel/openvino/modeling_decoder.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232

3333
from ...exporters.openvino import ensure_stateful_is_available, main_export, patch_stateful
3434
from ...exporters.openvino.stateful import model_has_state
35+
from ..utils.import_utils import is_nncf_available
3536
from ..utils.modeling_utils import MULTI_QUERY_ATTN_MODELS
3637
from .configuration import OVWeightQuantizationConfig
3738
from .modeling import _TOKENIZER_FOR_DOC, INPUTS_DOCSTRING, MODEL_START_DOCSTRING, OVModel
38-
from .quantization import _int4_weight_only_quantization
3939
from .utils import ONNX_WEIGHTS_NAME, OV_XML_FILE_NAME, STR_TO_OV_TYPE
4040

4141

@@ -596,6 +596,12 @@ def _from_pretrained(
596596
causal_model = init_cls(model=model, config=config, model_save_dir=model_cache_path.parent, **kwargs)
597597

598598
if load_in_4bit:
599+
if not is_nncf_available():
600+
raise ImportError(
601+
"Quantization of the weights requires nncf, please install it with `pip install nncf`"
602+
)
603+
from .quantization import _int4_weight_only_quantization
604+
599605
_int4_weight_only_quantization(causal_model, quantization_config)
600606
return causal_model
601607

0 commit comments

Comments
 (0)