[CI Bug] Fix ValueError: There is no module or parameter named 'model.vision_tower.vision_model' (#45478)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user