From 1d2c014086056c6e013823e215253a05c38aabae Mon Sep 17 00:00:00 2001 From: jinbridge <2635480475@qq.com> Date: Mon, 2 Dec 2024 16:17:01 +0800 Subject: [PATCH 1/2] Fix MiniCPM running on NPU --- python/llm/src/ipex_llm/transformers/npu_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/llm/src/ipex_llm/transformers/npu_model.py b/python/llm/src/ipex_llm/transformers/npu_model.py index 2eb54e515b4..1fdc84796f8 100644 --- a/python/llm/src/ipex_llm/transformers/npu_model.py +++ b/python/llm/src/ipex_llm/transformers/npu_model.py @@ -276,7 +276,7 @@ def optimize_npu_model(cls, *args, **kwargs): model.share_memory() if not pipeline: - if model.config.model_type in ["qwen2", "llama", "minicpm"]: + if not hasattr(model, 'llm') and model.config.model_type in ["qwen2", "llama", "minicpm"]: from ipex_llm.transformers.npu_models.convert import optimize_llm_single_process optimize_llm_single_process( llm, From a325d3b1b3bd5d7467dc7917515539bb317ac9da Mon Sep 17 00:00:00 2001 From: jinbridge <2635480475@qq.com> Date: Mon, 2 Dec 2024 16:24:20 +0800 Subject: [PATCH 2/2] Fix style check --- python/llm/src/ipex_llm/transformers/npu_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/llm/src/ipex_llm/transformers/npu_model.py b/python/llm/src/ipex_llm/transformers/npu_model.py index 1fdc84796f8..c7fc2f18bff 100644 --- a/python/llm/src/ipex_llm/transformers/npu_model.py +++ b/python/llm/src/ipex_llm/transformers/npu_model.py @@ -276,7 +276,8 @@ def optimize_npu_model(cls, *args, **kwargs): model.share_memory() if not pipeline: - if not hasattr(model, 'llm') and model.config.model_type in ["qwen2", "llama", "minicpm"]: + if (not hasattr(model, 'llm') and + model.config.model_type in ["qwen2", "llama", "minicpm"]): from ipex_llm.transformers.npu_models.convert import optimize_llm_single_process optimize_llm_single_process( llm,