Correct model layer aliasing for Bert style models (#43896)
ap9272 committed
Jul 9, 2026 at 16:46 UTC
cac3e70cd4f522eaab9d28323285d5e31238f907
2 files changed
+9
-4
vllm/model_executor/models/modernbert.py
+7
-1
@@ -237,7 +237,11 @@ class ModernBertEncoderLayer(nn.Module):
237
@default_pooling_type(seq_pooling_type="CLS")
238
class ModernBertModel(nn.Module):
239
hf_to_vllm_mapper = WeightsMapper(
240
- orig_to_new_prefix={"layers.": "encoder_layer.layers."}
240
+ orig_to_new_prefix={
241
+ "model.layers.": "encoder_layer.layers.",
242
+ "layers.": "encoder_layer.layers.",
243
+ "model.": "",
244
+ }
245
)
246
247
def __init__(
@@ -266,6 +270,8 @@ class ModernBertModel(nn.Module):
270
for name, loaded_weight in weights:
271
if name.endswith(".bias") and name not in params_dict:
272
continue
273
+ if name not in params_dict:
274
+ continue
275
param = params_dict[name]
276
weight_loader = getattr(param, "weight_loader", default_weight_loader)
277
weight_loader(param, loaded_weight)
vllm/model_executor/warmup/deep_gemm_warmup.py
+2
-3
@@ -138,9 +138,6 @@ def _fp8_linear_may_use_deep_gemm(module: torch.nn.Module) -> bool:
138
Return True if the input module/layer could be processed with DeepGEMM.
139
"""
140
141
- # FIXME: this logic is brittle and incorrect - since we
142
- # could use DeepGEMM with for than just Fp8LinearMethod
143
- block_size = get_mk_alignment_for_contiguous_layout()[0]
141
if not (
142
isinstance(module, LinearBase)
143
and isinstance(module.quant_method, Fp8LinearMethod)
@@ -156,6 +153,8 @@ def _fp8_linear_may_use_deep_gemm(module: torch.nn.Module) -> bool:
153
):
154
return False
155
156
+ block_size = get_mk_alignment_for_contiguous_layout()[0]
157
+
158
w, _, block_sizes = _extract_data_from_linear_base_module(module)
159
return (
160
block_sizes == get_mk_alignment_for_contiguous_layout()