|
10 | 10 | from lightllm.models.phi3.model import Phi3TpPartModel |
11 | 11 | from lightllm.models.qwen2.model import Qwen2TpPartModel |
12 | 12 | from lightllm.models.qwen3.model import Qwen3TpPartModel |
| 13 | +from lightllm.models.qwen3_moe.model import Qwen3MOEModel |
13 | 14 | from lightllm.models.deepseek2.model import Deepseek2TpPartModel |
14 | 15 | from lightllm.models.qwen_vl.layer_infer.pre_layer_infer import LlamaMultimodalPreLayerInfer |
15 | 16 | from lightllm.models.internvl.layer_weights.pre_and_post_layer_weight import ( |
@@ -297,3 +298,27 @@ def _init_config(self): |
297 | 298 | if self.finetune_config: |
298 | 299 | self.config["vocab_size"] = self.finetune_config.vocab_size |
299 | 300 | return |
| 301 | + |
| 302 | + |
| 303 | +@ModelRegistry(["internvl_chat"], is_multimodal=True, condition=llm_model_type_is("qwen3_moe")) |
| 304 | +class InternVLQwen3MOETpPartModel(Qwen3MOEModel): |
| 305 | + # weight class |
| 306 | + pre_and_post_weight_class = InternVLLlamaPreAndPostLayerWeight |
| 307 | + |
| 308 | + # infer class |
| 309 | + pre_layer_infer_class = LlamaMultimodalPreLayerInfer |
| 310 | + |
| 311 | + def __init__(self, kvargs): |
| 312 | + super().__init__(kvargs) |
| 313 | + return |
| 314 | + |
| 315 | + def _init_config(self): |
| 316 | + with open(os.path.join(self.weight_dir_, "config.json"), "r") as json_file: |
| 317 | + self.config = json.load(json_file)["llm_config"] |
| 318 | + # rename keys |
| 319 | + repair_config(self.config, same_names=["num_attention_heads", "n_head"]) |
| 320 | + repair_config(self.config, same_names=["hidden_size", "n_embd", "n_embed"]) |
| 321 | + repair_config(self.config, same_names=["num_hidden_layers", "n_layer"]) |
| 322 | + if self.finetune_config: |
| 323 | + self.config["vocab_size"] = self.finetune_config.vocab_size |
| 324 | + return |
0 commit comments