[BugFix][Pooling] Skip weight-prefix probe when model has WeightsMapper (#50890)
Signed-off-by: Juqi Li <2223621784@qq.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -175,6 +175,11 @@ def _create_pooling_model_cls(orig_cls: _T) -> _T:
|
||||
|
||||
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]):
|
||||
params_dict = dict(self.named_parameters())
|
||||
# Use model-owned remapping only for the probe membership check
|
||||
# (e.g. Gemma4 model.language_model.* -> language_model.model.*)
|
||||
# so the "" / "model." scan can early-exit. Forwarded names stay
|
||||
# unmapped to avoid double-applying the mapper in the parent loader.
|
||||
hf_to_vllm_mapper = getattr(self, "hf_to_vllm_mapper", None)
|
||||
|
||||
# We support loading from both `*ForCausalLM` and `*Model`
|
||||
candidate_prefixes = ["", "model."]
|
||||
@@ -185,11 +190,18 @@ def _create_pooling_model_cls(orig_cls: _T) -> _T:
|
||||
# Clone because the iterator may reuse the tensor buffer
|
||||
seen_weights.append((name, loaded_weight.clone()))
|
||||
|
||||
lookup_name = name
|
||||
if hf_to_vllm_mapper is not None:
|
||||
mapped = hf_to_vllm_mapper._map_name(name)
|
||||
if mapped is None:
|
||||
continue
|
||||
lookup_name = mapped
|
||||
|
||||
try:
|
||||
target_prefix = next(
|
||||
prefix
|
||||
for prefix in candidate_prefixes
|
||||
if prefix + name in params_dict
|
||||
if prefix + lookup_name in params_dict
|
||||
)
|
||||
break
|
||||
except StopIteration:
|
||||
|
||||
Reference in New Issue
Block a user