huggingface / optimum-intel

🤗 Optimum Intel: Accelerate inference with Intel optimization tools
https://huggingface.co/docs/optimum/main/en/intel/index
Apache License 2.0
355 stars 99 forks source link

fallback load model #752

Closed jiqing-feng closed 2 weeks ago

jiqing-feng commented 4 weeks ago

Hi @echarlaix . The IPEXModel has 2 loading methods:

  1. _from_transformers accepts a model_path_or_id with an original transformers model and exports this model.
  2. _from_pretrained only accepts an exported model; otherwise, it will raise ValueError.

I was thinking of falling back the _from_pretrained to _from_transformers if the model has not been exported yet and logging a warning to alert users. WDYT?

Besides, check the model type before using torch.jit.save in save_pretrained.

HuggingFaceDocBuilderDev commented 4 weeks ago

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

jiqing-feng commented 2 weeks ago

Hi @echarlaix . As we discussed before, I have removed _from_transformers.

jiqing-feng commented 2 weeks ago

Hi @echarlaix . I have fixed all your comments, pls take a review thx!

jiqing-feng commented 2 weeks ago

Tests fixed! @echarlaix