From 539924037fbc6b64a75c554ed338cb8c5abe5343 Mon Sep 17 00:00:00 2001 From: Mahdi-CV <33104503+Mahdi-CV@users.noreply.github.com> Date: Mon, 26 Jan 2026 13:02:54 -0800 Subject: [PATCH] fix(processor): support InternS1 text_config in InternVL processor (#17040) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .../sglang/srt/multimodal/processors/internvl.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/multimodal/processors/internvl.py b/python/sglang/srt/multimodal/processors/internvl.py index 9b1cf3ffd..31d45c9c8 100644 --- a/python/sglang/srt/multimodal/processors/internvl.py +++ b/python/sglang/srt/multimodal/processors/internvl.py @@ -72,7 +72,17 @@ class InternVLProcessor(BaseMultimodalProcessor): tokenizer = self._processor self.tokenizer = tokenizer - llm_arch = hf_config.llm_config.architectures[0] + # Support both InternVL (llm_config) and InternS1 (text_config). + # Different multimodal models use different field names for the text backbone: + # - InternVL uses: hf_config.llm_config + # - InternS1 uses: hf_config.text_config + # - Some store architectures at top-level + text_cfg = ( + getattr(hf_config, "llm_config", None) + or getattr(hf_config, "text_config", None) + or hf_config + ) + llm_arch = (getattr(text_cfg, "architectures", []) or [None])[0] self.llm_arch = llm_arch video_token_map = { "Qwen2ForCausalLM": "<|video_pad|>", @@ -121,9 +131,7 @@ class InternVLProcessor(BaseMultimodalProcessor): getattr(server_args, "context_length", None) or getattr(server_args, "max_context_len", None) or getattr(hf_config, "max_position_embeddings", None) - or getattr( - getattr(hf_config, "llm_config", None), "max_position_embeddings", None - ) + or getattr(text_cfg, "max_position_embeddings", None) or self.CONTEXT_FALLBACK )