Skip to content

Commit

Permalink
add nncf check
Browse files Browse the repository at this point in the history
  • Loading branch information
echarlaix committed Feb 15, 2024
1 parent f1c9d6f commit 0abed19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion optimum/intel/openvino/modeling_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

from ...exporters.openvino import ensure_stateful_is_available, main_export, patch_stateful
from ...exporters.openvino.stateful import model_has_state
from ..utils.import_utils import is_nncf_available
from ..utils.modeling_utils import MULTI_QUERY_ATTN_MODELS
from .configuration import OVWeightQuantizationConfig
from .modeling import _TOKENIZER_FOR_DOC, INPUTS_DOCSTRING, MODEL_START_DOCSTRING, OVModel
from .quantization import _int4_weight_only_quantization
from .utils import ONNX_WEIGHTS_NAME, OV_XML_FILE_NAME, STR_TO_OV_TYPE


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

if load_in_4bit:
if not is_nncf_available():
raise ImportError(
"Quantization of the weights requires nncf, please install it with `pip install nncf`"
)
from .quantization import _int4_weight_only_quantization

_int4_weight_only_quantization(causal_model, quantization_config)
return causal_model

Expand Down

0 comments on commit 0abed19

Please sign in to comment.