2727 'LlavaLlamaForCausalLM' : 'LlamaDecoderLayer' ,
2828 'MGMLlamaForCausalLM' : 'LlamaDecoderLayer' , # mini gemini
2929 'InternLMXComposer2ForCausalLM' : 'InternLM2DecoderLayer' ,
30+ 'InternS2PreviewForConditionalGeneration' : 'InternS2PreviewDecoderLayer' ,
3031 'Phi3ForCausalLM' : 'Phi3DecoderLayer' ,
3132 'ChatGLMForConditionalGeneration' : 'GLMBlock' ,
3233 'MixtralForCausalLM' : 'MixtralDecoderLayer' ,
5152 'LlavaLlamaForCausalLM' : 'LlamaRMSNorm' ,
5253 'MGMLlamaForCausalLM' : 'LlamaRMSNorm' , # mini gemini
5354 'InternLMXComposer2ForCausalLM' : 'InternLM2RMSNorm' ,
55+ 'InternS2PreviewForConditionalGeneration' : 'InternS2PreviewRMSNorm' ,
5456 'Phi3ForCausalLM' : 'Phi3RMSNorm' ,
5557 'ChatGLMForConditionalGeneration' : 'RMSNorm' ,
5658 'MixtralForCausalLM' : 'MixtralRMSNorm' ,
7577 'LlavaLlamaForCausalLM' : 'lm_head' ,
7678 'MGMLlamaForCausalLM' : 'lm_head' , # mini gemini
7779 'InternLMXComposer2ForCausalLM' : 'output' ,
80+ 'InternS2PreviewForConditionalGeneration' : 'lm_head' ,
7881 'Phi3ForCausalLM' : 'lm_head' ,
7982 'ChatGLMForConditionalGeneration' : 'output_layer' ,
8083 'MixtralForCausalLM' : 'lm_head' ,
8386 'MistralForCausalLM' : 'lm_head' ,
8487}
8588
86- MOE_MODEL_LIST = [
87- 'Qwen3MoeForCausalLM' ,
88- 'Qwen3_5MoeForConditionalGeneration' ,
89- 'MixtralForCausalLM'
90- ]
91-
9289
9390def check_vl_llm (backend : str , config : dict ) -> bool :
9491 """Check if the model is a vl model from model config."""
@@ -110,7 +107,8 @@ def check_vl_llm(backend: str, config: dict) -> bool:
110107 'Qwen3_5MoeForConditionalGeneration' , 'MllamaForConditionalGeneration' , 'MolmoForCausalLM' ,
111108 'Gemma3ForConditionalGeneration' , 'Llama4ForConditionalGeneration' , 'InternVLForConditionalGeneration' ,
112109 'InternS1ForConditionalGeneration' , 'InternS1ProForConditionalGeneration' ,
113- 'InternS1_1_ForConditionalGeneration' , 'Glm4vForConditionalGeneration'
110+ 'InternS1_1_ForConditionalGeneration' , 'Glm4vForConditionalGeneration' ,
111+ 'InternS2PreviewForConditionalGeneration'
114112 ])
115113 if arch == 'QWenLMHeadModel' and 'visual' in config :
116114 return True
@@ -125,11 +123,7 @@ def check_vl_llm(backend: str, config: dict) -> bool:
125123
126124def get_task (backend : str , model_path : str ):
127125 """Get pipeline type and pipeline class from model config."""
128- import os
129126
130- if os .path .exists (os .path .join (model_path , 'triton_models' , 'weights' )):
131- # workspace model
132- return 'llm'
133127 _ , config = get_model_arch (model_path )
134128 if check_vl_llm (backend , config .to_dict ()):
135129 return 'vlm'
@@ -260,22 +254,23 @@ def update_moe_mapping(model, model_type):
260254
261255def load_model_and_tokenizer (model : str ,
262256 dtype : Literal ['float16' , 'bfloat16' , 'auto' ] = 'auto' ,
263- work_dir : str = './work_dir' ):
257+ work_dir : str = './work_dir' ,
258+ trust_remote_code : bool = False ):
264259 """Load model and tokenizer."""
265260 model_type = get_task (backend = 'turbomind' , model_path = model )
266261 make_compatible_internvl_config (model )
267262
268263 # Load tokenizer
269- tokenizer = AutoTokenizer .from_pretrained (model , trust_remote_code = True )
264+ tokenizer = AutoTokenizer .from_pretrained (model , trust_remote_code = trust_remote_code )
270265
271266 # get model arch and config
272- arch , original_config = get_model_arch (model )
267+ arch , original_config = get_model_arch (model , trust_remote_code = trust_remote_code )
273268
274269 if model_type == 'llm' :
275- model = load_hf_from_pretrained (model , dtype = dtype , trust_remote_code = True )
270+ model = load_hf_from_pretrained (model , dtype = dtype , trust_remote_code = trust_remote_code )
276271 vl_model = None
277272 elif model_type == 'vlm' :
278- vl_model = load_vl_model (model , backend = None , with_llm = True ).vl_model
273+ vl_model = load_vl_model (model , backend = None , with_llm = True , trust_remote_code = trust_remote_code ).vl_model
279274 model = vl_model
280275 if hasattr (vl_model , 'language_model' ): # deepseek-vl, ...
281276 model = vl_model .language_model
@@ -355,7 +350,7 @@ def calibrate(model: str,
355350 '`neuralmagic_calibration`, `open-platypus`, `openwebtext`.'
356351
357352 arch , vl_model , model , tokenizer , model_type , work_dir = load_model_and_tokenizer (
358- model , dtype = dtype , work_dir = work_dir )
353+ model , dtype = dtype , work_dir = work_dir , trust_remote_code = trust_remote_code )
359354
360355 if model_type in ['MixtralForCausalLM' ]:
361356 update_moe_mapping (model , model_type )
@@ -401,7 +396,7 @@ def calibrate(model: str,
401396
402397 calib_ctx .export (work_dir )
403398
404- return arch , vl_model , model , tokenizer
399+ return arch , vl_model , model , tokenizer , work_dir
405400
406401
407402if __name__ == '__main__' :
0 commit comments