forked from Karylab-cklius/vllm
Correct model layer aliasing for Bert style models (#43896)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -138,9 +138,6 @@ def _fp8_linear_may_use_deep_gemm(module: torch.nn.Module) -> bool:
|
||||
Return True if the input module/layer could be processed with DeepGEMM.
|
||||
"""
|
||||
|
||||
# FIXME: this logic is brittle and incorrect - since we
|
||||
# could use DeepGEMM with for than just Fp8LinearMethod
|
||||
block_size = get_mk_alignment_for_contiguous_layout()[0]
|
||||
if not (
|
||||
isinstance(module, LinearBase)
|
||||
and isinstance(module.quant_method, Fp8LinearMethod)
|
||||
@@ -156,6 +153,8 @@ def _fp8_linear_may_use_deep_gemm(module: torch.nn.Module) -> bool:
|
||||
):
|
||||
return False
|
||||
|
||||
block_size = get_mk_alignment_for_contiguous_layout()[0]
|
||||
|
||||
w, _, block_sizes = _extract_data_from_linear_base_module(module)
|
||||
return (
|
||||
block_sizes == get_mk_alignment_for_contiguous_layout()
|
||||
|
||||
Reference in New Issue
Block a user