Skip to content

Commit 689c431

Browse files
author
sangchengmeng
committed
internvl-llm support qwen3_moe
1 parent 60efbef commit 689c431

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lightllm/models/internvl/model.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from lightllm.models.phi3.model import Phi3TpPartModel
1111
from lightllm.models.qwen2.model import Qwen2TpPartModel
1212
from lightllm.models.qwen3.model import Qwen3TpPartModel
13+
from lightllm.models.qwen3_moe.model import Qwen3MOEModel
1314
from lightllm.models.deepseek2.model import Deepseek2TpPartModel
1415
from lightllm.models.qwen_vl.layer_infer.pre_layer_infer import LlamaMultimodalPreLayerInfer
1516
from lightllm.models.internvl.layer_weights.pre_and_post_layer_weight import (
@@ -297,3 +298,27 @@ def _init_config(self):
297298
if self.finetune_config:
298299
self.config["vocab_size"] = self.finetune_config.vocab_size
299300
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

Comments
 (0)