From 8fa3609eecab6d6f98787123ccd92dc76900a035 Mon Sep 17 00:00:00 2001 From: cjm <490083538@qq.com> Date: Fri, 17 Jan 2025 11:54:01 +0800 Subject: [PATCH] support minicpm-o 2.6 --- gptqmodel/models/_const.py | 1 + gptqmodel/models/auto.py | 4 +++- gptqmodel/models/definitions/__init__.py | 1 + gptqmodel/models/definitions/minicpmo.py | 29 ++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gptqmodel/models/definitions/minicpmo.py diff --git a/gptqmodel/models/_const.py b/gptqmodel/models/_const.py index bd45e28a4..a3becdd38 100644 --- a/gptqmodel/models/_const.py +++ b/gptqmodel/models/_const.py @@ -155,6 +155,7 @@ def get_best_device(backend: BACKEND = BACKEND.AUTO) -> torch.device: "cohere2", "minicpm", "minicpm3" + "minicpmo" "qwen2_moe", "qwen2_vl", "dbrx_converted", diff --git a/gptqmodel/models/auto.py b/gptqmodel/models/auto.py index 638fd9ed9..244a7b47c 100644 --- a/gptqmodel/models/auto.py +++ b/gptqmodel/models/auto.py @@ -66,6 +66,7 @@ from .definitions.longllama import LongLlamaGPTQ # noqa: E402 from .definitions.minicpm import MiniCPMGPTQ # noqa: E402 from .definitions.minicpm3 import MiniCPM3GPTQ # noqa: E402 +from .definitions.minicpmo import MiniCPMOGPTQ # noqa: E402 from .definitions.mistral import MistralGPTQ # noqa: E402 from .definitions.mixtral import MixtralGPTQ # noqa: E402 from .definitions.mllama import MLlamaGPTQ # noqa: E402 @@ -126,7 +127,8 @@ "phi3": Phi3GPTQ, "mpt": MPTGPTQ, "minicpm": MiniCPMGPTQ, - "minicpm3":MiniCPM3GPTQ, + "minicpm3": MiniCPM3GPTQ, + "minicpmo": MiniCPMOGPTQ, "qwen2_moe": Qwen2MoeGPTQ, "qwen2_vl": Qwen2VLGPTQ, "dbrx": DbrxGPTQ, diff --git a/gptqmodel/models/definitions/__init__.py b/gptqmodel/models/definitions/__init__.py index ad5c0e5a0..2dba44d57 100644 --- a/gptqmodel/models/definitions/__init__.py +++ b/gptqmodel/models/definitions/__init__.py @@ -39,6 +39,7 @@ from .llama import LlamaGPTQ from .longllama import LongLlamaGPTQ from .minicpm3 import MiniCPM3GPTQ +from .minicpmo import MiniCPMOGPTQ from .mistral import MistralGPTQ from .mixtral import MixtralGPTQ from .mllama import MLlamaGPTQ diff --git a/gptqmodel/models/definitions/minicpmo.py b/gptqmodel/models/definitions/minicpmo.py new file mode 100644 index 000000000..0a91e5387 --- /dev/null +++ b/gptqmodel/models/definitions/minicpmo.py @@ -0,0 +1,29 @@ +# Copyright 2025 ModelCloud +# Contact: qubitium@modelcloud.ai, x.com/qubitium +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ..base import BaseGPTQModel + + +class MiniCPMOGPTQ(BaseGPTQModel): + layer_type = "Qwen2DecoderLayer" + layers_node = "llm.model.layers" + base_modules = ["llm.model.embed_tokens", "llm.model.norm", "vpm", "apm", "tts", "audio_projection_layer", + "resampler"] + layer_modules = [ + ["self_attn.k_proj", "self_attn.v_proj", "self_attn.q_proj"], + ["self_attn.o_proj"], + ["mlp.up_proj", "mlp.gate_proj"], + ["mlp.down_proj"], + ]