From 96fa5cdd9e7a6be0148718ee594da9f33d3edef0 Mon Sep 17 00:00:00 2001 From: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Date: Sat, 13 Jun 2026 05:38:37 -0400 Subject: [PATCH] [CI Bug] Fix `ValueError: There is no module or parameter named 'model.vision_tower.vision_model'` (#45478) Signed-off-by: yewentao256 --- vllm/model_executor/models/transformers/base.py | 8 ++------ vllm/model_executor/models/utils.py | 8 ++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vllm/model_executor/models/transformers/base.py b/vllm/model_executor/models/transformers/base.py index 234ae9570b..55d9460049 100644 --- a/vllm/model_executor/models/transformers/base.py +++ b/vllm/model_executor/models/transformers/base.py @@ -303,17 +303,13 @@ class Base( - Any quantization config specific mappings """ self.hf_to_vllm_mapper = WeightsMapper() + orig_to_new_renamings = self.hf_to_vllm_mapper.orig_to_new_renamings orig_to_new_regex = self.hf_to_vllm_mapper.orig_to_new_regex for mapping in get_model_conversion_mapping(self.model): # Handle weights which have been renamed in Transformers if isinstance(mapping, WeightRenaming): - # Recompile using regex (Transformers used re) - compiled_sources = re.compile( - mapping.compiled_sources.pattern, mapping.compiled_sources.flags - ) - target_pattern = mapping.target_patterns[0] - orig_to_new_regex[compiled_sources] = target_pattern + orig_to_new_renamings.append(mapping) # TODO: Handle WeightConverter to enable layer merging # Handle unexpected weights which should be ignored diff --git a/vllm/model_executor/models/utils.py b/vllm/model_executor/models/utils.py index 02b1352ca9..730dc81ed2 100644 --- a/vllm/model_executor/models/utils.py +++ b/vllm/model_executor/models/utils.py @@ -44,6 +44,7 @@ class WeightsMapper: If a key maps to a value of `None`, the corresponding weight is ignored.""" + orig_to_new_renamings: list[Any] = field(default_factory=list) orig_to_new_regex: Mapping[re.Pattern, str | None] = field(default_factory=dict) orig_to_new_substr: Mapping[str, str | None] = field(default_factory=dict) orig_to_new_prefix: Mapping[str, str | None] = field(default_factory=dict) @@ -52,6 +53,10 @@ class WeightsMapper: def __or__(self, other: "WeightsMapper") -> "WeightsMapper": """Combine two `WeightsMapper`s by merging their mappings.""" return WeightsMapper( + orig_to_new_renamings=[ + *self.orig_to_new_renamings, + *other.orig_to_new_renamings, + ], orig_to_new_regex={**self.orig_to_new_regex, **other.orig_to_new_regex}, orig_to_new_substr={**self.orig_to_new_substr, **other.orig_to_new_substr}, orig_to_new_prefix={**self.orig_to_new_prefix, **other.orig_to_new_prefix}, @@ -59,6 +64,9 @@ class WeightsMapper: ) def _map_name(self, key: str) -> str | None: + for renaming in self.orig_to_new_renamings: + key, _ = renaming.rename_source_key(key) + for pattern, new_key in self.orig_to_new_regex.items(): if pattern.search(key): if new_key is None: