Reduce AutoWeightsLoader kwargs (#53106)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -371,6 +371,14 @@ class MiniMaxM2Model(nn.Module, EagleModelMixin):
|
||||
["hidden_states", "residual"], config.hidden_size
|
||||
)
|
||||
|
||||
# Drop spec-decode (MTP) layers; they are appended after the main
|
||||
# decoder layers and have no destination in the main model.
|
||||
if num_mtp := getattr(config, "num_mtp_modules", 0):
|
||||
base = config.num_hidden_layers
|
||||
self.hf_to_vllm_mapper = self.hf_to_vllm_mapper | WeightsMapper(
|
||||
orig_to_new_prefix={f"layers.{base + i}.": None for i in range(num_mtp)}
|
||||
)
|
||||
|
||||
def embed_input_ids(self, input_ids: torch.Tensor) -> torch.Tensor:
|
||||
return self.embed_tokens(input_ids)
|
||||
|
||||
@@ -413,17 +421,7 @@ class MiniMaxM2Model(nn.Module, EagleModelMixin):
|
||||
return hidden_states
|
||||
|
||||
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
|
||||
# Skip spec-decode (MTP) layers; they are appended after the main
|
||||
# decoder layers and have no destination in the main model.
|
||||
skip_prefixes = None
|
||||
num_mtp = getattr(self.config, "num_mtp_modules", 0)
|
||||
if num_mtp:
|
||||
base = self.config.num_hidden_layers
|
||||
skip_prefixes = [f"layers.{base + i}." for i in range(num_mtp)]
|
||||
loader = AutoWeightsLoader(
|
||||
self,
|
||||
skip_prefixes=skip_prefixes,
|
||||
)
|
||||
loader = AutoWeightsLoader(self)
|
||||
return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user