[Model] Add MiMo-V2.5 support (#40967)
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com> Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn> Signed-off-by: Isotr0py <Isotr0py@outlook.com> Signed-off-by: zjy0516 <riverclouds.zhu@qq.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com> Co-authored-by: zjy0516 <riverclouds.zhu@qq.com> Co-authored-by: zjy0516 <zhujiangyun@inferact.ai> Co-authored-by: yasong <yasong.wang@inferact.ai> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
co-authored by
Jee Jee Li
zjy0516
zjy0516
yasong
Claude Opus 4.6
Copilot
parent
f8ac0c7cf0
commit
c245d35ff4
@@ -0,0 +1,65 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
|
||||
from transformers import PretrainedConfig
|
||||
|
||||
|
||||
class Mimo_VLVisionConfig(PretrainedConfig):
|
||||
model_type = "mimovl"
|
||||
base_config_key = "vision_config"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
depth=28,
|
||||
hidden_size=1280,
|
||||
hidden_act="silu",
|
||||
intermediate_size=4608,
|
||||
num_heads=32,
|
||||
in_channels=3,
|
||||
patch_size=16,
|
||||
spatial_merge_size=2,
|
||||
temporal_patch_size=2,
|
||||
tokens_per_second=2,
|
||||
window_size=128,
|
||||
out_hidden_size=2048,
|
||||
fullatt_block_indexes=None,
|
||||
initializer_range=0.02,
|
||||
kv_channels=64, # HACK
|
||||
qk_channels=64,
|
||||
num_query_groups=4,
|
||||
num_key_value_heads=8,
|
||||
vit_window_attn_types=None,
|
||||
visual_token_window_size=64,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.depth = depth
|
||||
self.hidden_size = hidden_size
|
||||
self.hidden_act = hidden_act
|
||||
self.intermediate_size = intermediate_size
|
||||
self.num_heads = num_heads
|
||||
# Support GQA: if num_key_value_heads is not provided,
|
||||
# default to num_heads (MHA)
|
||||
if num_key_value_heads is None:
|
||||
num_key_value_heads = num_heads
|
||||
self.num_key_value_heads = num_key_value_heads
|
||||
self.in_channels = in_channels
|
||||
self.patch_size = patch_size
|
||||
self.spatial_merge_size = spatial_merge_size
|
||||
self.temporal_patch_size = temporal_patch_size
|
||||
self.tokens_per_second = tokens_per_second
|
||||
self.window_size = window_size
|
||||
self.fullatt_block_indexes = (
|
||||
fullatt_block_indexes
|
||||
if fullatt_block_indexes is not None
|
||||
else [7, 15, 23, 31]
|
||||
)
|
||||
self.out_hidden_size = out_hidden_size
|
||||
self.initializer_range = initializer_range
|
||||
self.kv_channels = kv_channels
|
||||
self.qk_channels = qk_channels
|
||||
self.num_query_groups = num_query_groups
|
||||
self.vit_window_attn_types = vit_window_attn_types or [-1] * depth
|
||||
self.visual_token_window_size = visual_token_window_size
|
||||
@@ -445,6 +445,37 @@ class MimoMTPModelArchConfigConvertor(ModelArchConfigConvertorBase):
|
||||
return getattr(self.hf_text_config, "num_nextn_predict_layers", 0)
|
||||
|
||||
|
||||
def _strip_mimo_v2_attention_chunk_size(
|
||||
hf_config: PretrainedConfig, hf_text_config: PretrainedConfig
|
||||
) -> None:
|
||||
# MiMo-V2-Flash's config.json sets `attention_chunk_size=128` but the
|
||||
# architecture does not actually use chunked local attention. Leaving it
|
||||
# set makes vLLM disable the hybrid KV cache manager
|
||||
for cfg in (hf_text_config, hf_config):
|
||||
if cfg is not None and hasattr(cfg, "attention_chunk_size"):
|
||||
delattr(cfg, "attention_chunk_size")
|
||||
|
||||
|
||||
class MimoV2ModelArchConfigConvertor(ModelArchConfigConvertorBase):
|
||||
def __init__(self, hf_config: PretrainedConfig, hf_text_config: PretrainedConfig):
|
||||
super().__init__(hf_config, hf_text_config)
|
||||
_strip_mimo_v2_attention_chunk_size(hf_config, hf_text_config)
|
||||
|
||||
|
||||
class MimoV2MTPModelArchConfigConvertor(ModelArchConfigConvertorBase):
|
||||
def __init__(self, hf_config: PretrainedConfig, hf_text_config: PretrainedConfig):
|
||||
super().__init__(hf_config, hf_text_config)
|
||||
_strip_mimo_v2_attention_chunk_size(hf_config, hf_text_config)
|
||||
|
||||
def get_num_hidden_layers(self) -> int:
|
||||
n = getattr(self.hf_text_config, "num_nextn_predict_layers", None)
|
||||
if n is not None:
|
||||
return n
|
||||
# Fall back to n_predict set by hf_config_override
|
||||
n = getattr(self.hf_text_config, "n_predict", None)
|
||||
return n if n is not None else 0
|
||||
|
||||
|
||||
class GLM4MoeMTPModelArchConfigConvertor(ModelArchConfigConvertorBase):
|
||||
def get_num_hidden_layers(self) -> int:
|
||||
return getattr(self.hf_text_config, "num_nextn_predict_layers", 0)
|
||||
@@ -511,6 +542,10 @@ MODEL_ARCH_CONFIG_CONVERTORS = {
|
||||
"qwen3_next_mtp": Qwen3NextMTPModelArchConfigConvertor,
|
||||
"qwen3_5_mtp": Qwen3_5MTPModelArchConfigConvertor,
|
||||
"mimo_mtp": MimoMTPModelArchConfigConvertor,
|
||||
"mimo_v2_pro": MimoV2ModelArchConfigConvertor,
|
||||
"mimo_v2_flash": MimoV2ModelArchConfigConvertor,
|
||||
"mimo_v2_mtp": MimoV2MTPModelArchConfigConvertor,
|
||||
"mimo_v2_omni_mtp": MimoV2MTPModelArchConfigConvertor,
|
||||
"glm4_moe_mtp": GLM4MoeMTPModelArchConfigConvertor,
|
||||
"glm_ocr_mtp": GLM4MoeMTPModelArchConfigConvertor,
|
||||
"ernie_mtp": ErnieMTPModelArchConfigConvertor,
|
||||
|
||||
@@ -27,6 +27,7 @@ __all__ = [
|
||||
"IsaacProcessor",
|
||||
"KimiAudioProcessor",
|
||||
"KimiK25Processor",
|
||||
"MiMoOmniProcessor",
|
||||
"MistralCommonPixtralProcessor",
|
||||
"MistralCommonVoxtralProcessor",
|
||||
"NanoNemotronVLProcessor",
|
||||
@@ -57,6 +58,7 @@ _CLASS_TO_MODULE: dict[str, str] = {
|
||||
"IsaacProcessor": "vllm.transformers_utils.processors.isaac",
|
||||
"KimiAudioProcessor": "vllm.transformers_utils.processors.kimi_audio",
|
||||
"KimiK25Processor": "vllm.transformers_utils.processors.kimi_k25",
|
||||
"MiMoOmniProcessor": "vllm.transformers_utils.processors.mimo_v2_omni",
|
||||
"MistralCommonPixtralProcessor": "vllm.transformers_utils.processors.pixtral",
|
||||
"MistralCommonVoxtralProcessor": "vllm.transformers_utils.processors.voxtral",
|
||||
"NanoNemotronVLProcessor": "vllm.transformers_utils.processors.nano_nemotron_vl",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user