| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | from collections.abc import Iterable |
| 4 | |
| 5 | import torch |
| 6 | from transformers import AutoProcessor |
| 7 | |
| 8 | from vllm.multimodal import MULTIMODAL_REGISTRY |
| 9 | |
| 10 | from .qwen3_5 import Qwen3_5MoeForConditionalGeneration |
| 11 | from .qwen3_vl import ( |
| 12 | Qwen3VLDummyInputsBuilder, |
| 13 | Qwen3VLMultiModalProcessor, |
| 14 | Qwen3VLProcessingInfo, |
| 15 | ) |
| 16 | from .utils import AutoWeightsLoader, WeightsMapper |
| 17 | |
| 18 | |
| 19 | class InternS2PreviewProcessingInfo(Qwen3VLProcessingInfo): |
| 20 | def get_hf_config(self): |
| 21 | return self.ctx.get_hf_config() |
| 22 | |
| 23 | def get_hf_processor(self, **kwargs: object) -> AutoProcessor: |
| 24 | return self.ctx.get_hf_processor(**kwargs) |
| 25 | |
| 26 | |
| 27 | @MULTIMODAL_REGISTRY.register_processor( |
| 28 | Qwen3VLMultiModalProcessor, |
| 29 | info=InternS2PreviewProcessingInfo, |
| 30 | dummy_inputs=Qwen3VLDummyInputsBuilder, |
| 31 | ) |
| 32 | class InternS2PreviewForConditionalGeneration(Qwen3_5MoeForConditionalGeneration): |
| 33 | # `mtp.` is already dropped by `Qwen3_5ForConditionalGeneration`. |
| 34 | hf_to_vllm_mapper = Qwen3_5MoeForConditionalGeneration.hf_to_vllm_mapper | ( |
| 35 | WeightsMapper( |
| 36 | orig_to_new_prefix={"model.time_series.": None, "time_series.": None} |
| 37 | ) |
| 38 | ) |
| 39 | |
| 40 | def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]: |
| 41 | loader = AutoWeightsLoader(self) |
| 42 | return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper) |