Correct model layer aliasing for Bert style models (#43896)

This commit is contained in:
ap9272
2026-07-09 19:46:22 -04:00
committed by GitHub
parent e12b91b032
commit cac3e70cd4
2 changed files with 9 additions and 4 deletions
+7 -1
View File
@@ -237,7 +237,11 @@ class ModernBertEncoderLayer(nn.Module):
@default_pooling_type(seq_pooling_type="CLS")
class ModernBertModel(nn.Module):
hf_to_vllm_mapper = WeightsMapper(
orig_to_new_prefix={"layers.": "encoder_layer.layers."}
orig_to_new_prefix={
"model.layers.": "encoder_layer.layers.",
"layers.": "encoder_layer.layers.",
"model.": "",
}
)
def __init__(
@@ -266,6 +270,8 @@ class ModernBertModel(nn.Module):
for name, loaded_weight in weights:
if name.endswith(".bias") and name not in params_dict:
continue
if name not in params_dict:
continue
param = params_dict[name]
weight_loader = getattr(param, "weight_loader", default_weight_loader)
weight_loader(param, loaded_weight)