Reduce AutoWeightsLoader kwargs (#53106)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -52,6 +52,7 @@ from vllm.sequence import IntermediateTensors
|
||||
from .interfaces import SupportsCrossEncoding, SupportsPP
|
||||
from .utils import (
|
||||
AutoWeightsLoader,
|
||||
WeightsMapper,
|
||||
make_empty_intermediate_tensors_factory,
|
||||
make_layers,
|
||||
maybe_prefix,
|
||||
@@ -182,6 +183,11 @@ class GPT2Block(nn.Module):
|
||||
|
||||
@support_torch_compile
|
||||
class GPT2Model(nn.Module):
|
||||
# Drop attention mask buffers; NOTE: "c_attn.bias" must not be dropped.
|
||||
hf_to_vllm_mapper = WeightsMapper(
|
||||
orig_to_new_substr={".attn.bias": None, ".attn.masked_bias": None}
|
||||
)
|
||||
|
||||
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
|
||||
super().__init__()
|
||||
|
||||
@@ -253,11 +259,10 @@ class GPT2Model(nn.Module):
|
||||
yield name, loaded_weight
|
||||
|
||||
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
|
||||
# Skip attention mask buffers; NOTE: "c_attn.bias" must not be skipped.
|
||||
loader = AutoWeightsLoader(
|
||||
self, skip_substrs=[".attn.bias", ".attn.masked_bias"]
|
||||
loader = AutoWeightsLoader(self)
|
||||
return loader.load_weights(
|
||||
self._transpose_conv1d(weights), mapper=self.hf_to_vllm_mapper
|
||||
)
|
||||
return loader.load_weights(self._transpose_conv1d(weights))
|
||||
|
||||
|
||||
class GPT2LMHeadModel(nn.Module, SupportsPP):
|
||||
|
||||
Reference in New Issue
Block a user