Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NPU] Fix save-load usage of minicpm models #12628

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions python/llm/src/ipex_llm/transformers/npu_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,9 @@ def load_low_bit(cls, pretrained_model_name_or_path: str, *model_args, **kwargs)
from .npu_models.npu_llm_cpp import load_model_from_file
from .npu_models.convert import generate, general_convert
from .npu_models.convert import prepare_input_ids, causal_lm_forward
config = AutoConfig.from_pretrained(
os.path.join(pretrained_model_name_or_path, "config.json"),
trust_remote_code=trust_remote_code)
with torch.device('meta'):
model = cls.HF_Model.from_config(
config, trust_remote_code=trust_remote_code)
model = cls.HF_Model.from_config(config,
trust_remote_code=trust_remote_code)
try:
model_ptr = load_model_from_file(pretrained_model_name_or_path)
model.model_ptr = model_ptr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,11 @@ def convert_llm_for_deploy(model: torch.nn.Module,
else:
lm_head_low_bit = model.lm_head.lm_heads[0].qtype

if model._auto_class is not None:
# For a custom model, copy the file defining it in the folder
from transformers.dynamic_module_utils import custom_object_save
custom_object_save(model, save_directory, config=model.config)

if model.config.model_type == "qwen2":
if group_size == 0:
if model.config.hidden_size == 1536:
Expand Down
Loading