3737import torch .nn .functional as F
3838from einops import rearrange
3939from transformers import BatchFeature
40- from transformers .models .glm4v .configuration_glm4v import (Glm4vConfig ,
41- Glm4vVisionConfig )
40+ from transformers .models .glm4v .configuration_glm4v import Glm4vVisionConfig
4241from transformers .models .glm4v .image_processing_glm4v import (
4342 Glm4vImageProcessor , smart_resize )
4443from transformers .models .glm4v .video_processing_glm4v import (
@@ -801,7 +800,7 @@ def load_weights(self, weights: Iterable[tuple[str,
801800class Glm4vProcessingInfo (BaseProcessingInfo ):
802801
803802 def get_hf_config (self ):
804- return self .ctx .get_hf_config (Glm4vConfig )
803+ return self .ctx .get_hf_config ()
805804
806805 def get_tokenizer (self ):
807806 return self .ctx .tokenizer
@@ -1253,7 +1252,7 @@ def get_placeholder_str(cls, modality: str, i: int) -> Optional[str]:
12531252
12541253 def __init__ (self , * , vllm_config : VllmConfig , prefix : str = "" ):
12551254 super ().__init__ ()
1256- config : Glm4vConfig = vllm_config .model_config .hf_config
1255+ config = vllm_config .model_config .hf_config
12571256 quant_config = vllm_config .quant_config
12581257 multimodal_config = vllm_config .model_config .multimodal_config
12591258
@@ -1267,12 +1266,18 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
12671266 prefix = maybe_prefix (prefix , "visual" ),
12681267 )
12691268
1269+ if config .model_type == "glm4v" :
1270+ architectures = ["Glm4ForCausalLM" ]
1271+ elif config .model_type == "glm4v_moe" :
1272+ architectures = ["Glm4MoeForCausalLM" ]
1273+ else :
1274+ architectures = None
1275+
12701276 self .language_model = init_vllm_registered_model (
12711277 vllm_config = vllm_config ,
1272- prefix = maybe_prefix (prefix , "" ),
1273- architectures = ["Glm4ForCausalLM" ],
1274- hf_config = self .config .get_text_config (),
1275- )
1278+ hf_config = config .text_config ,
1279+ prefix = maybe_prefix (prefix , "language_model" ),
1280+ architectures = architectures )
12761281
12771282 self .make_empty_intermediate_tensors = (
12781283 self .language_model .make_empty_intermediate_tensors )
0 commit comments