[Model] Support InternS2 Preview (#42705)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
Co-authored-by: zxy <46674730+CUHKSZzxy@users.noreply.github.com>
This commit is contained in:
Isotr0py
2026-05-14 21:30:26 -07:00
committed by GitHub
co-authored by zxy
parent f351455f0f
commit faa4b76afa
6 changed files with 60 additions and 0 deletions
+11
View File
@@ -467,6 +467,17 @@ class SpeculativeConfig:
"architectures": ["Qwen3_5MoeMTP" if is_moe else "Qwen3_5MTP"],
}
)
if hf_config.model_type == "intern_s2_preview":
text_config = getattr(hf_config, "text_config", None)
is_moe = getattr(text_config, "model_type", None) == "qwen3_5_moe_text"
hf_config.model_type = "qwen3_5_mtp"
n_predict = getattr(text_config, "mtp_num_hidden_layers", None)
hf_config.update(
{
"n_predict": n_predict,
"architectures": ["Qwen3_5MoeMTP" if is_moe else "Qwen3_5MTP"],
}
)
if hf_config.model_type == "longcat_flash":
hf_config.model_type = "longcat_flash_mtp"
n_predict = getattr(hf_config, "num_nextn_predict_layers", 1)
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Iterable
import torch
from transformers import AutoProcessor
from vllm.multimodal import MULTIMODAL_REGISTRY
from .qwen3_5 import Qwen3_5MoeForConditionalGeneration
from .qwen3_vl import (
Qwen3VLDummyInputsBuilder,
Qwen3VLMultiModalProcessor,
Qwen3VLProcessingInfo,
)
from .utils import AutoWeightsLoader
class InternS2PreviewProcessingInfo(Qwen3VLProcessingInfo):
def get_hf_config(self):
return self.ctx.get_hf_config()
def get_hf_processor(self, **kwargs: object) -> AutoProcessor:
return self.ctx.get_hf_processor(**kwargs)
@MULTIMODAL_REGISTRY.register_processor(
Qwen3VLMultiModalProcessor,
info=InternS2PreviewProcessingInfo,
dummy_inputs=Qwen3VLDummyInputsBuilder,
)
class InternS2PreviewForConditionalGeneration(Qwen3_5MoeForConditionalGeneration):
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
loader = AutoWeightsLoader(
self,
skip_prefixes=["mtp.", "model.time_series.", "time_series."],
)
return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
+4
View File
@@ -435,6 +435,10 @@ _MULTIMODAL_MODELS = {
"interns1_pro",
"InternS1ProForConditionalGeneration",
),
"InternS2PreviewForConditionalGeneration": (
"interns2_preview",
"InternS2PreviewForConditionalGeneration",
),
"Idefics3ForConditionalGeneration": (
"idefics3",
"Idefics3ForConditionalGeneration",
+1
View File
@@ -1218,6 +1218,7 @@ class SpecDecodeBaseProposer:
"Exaone4_5_ForConditionalGeneration",
"GlmOcrForConditionalGeneration",
"HunYuanVLForConditionalGeneration",
"InternS2PreviewForConditionalGeneration",
"MiMoV2OmniForCausalLM",
"Qwen2_5_VLForConditionalGeneration",
"Qwen3_5ForConditionalGeneration",