Reduce AutoWeightsLoader kwargs (#53106)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-08-20 15:40:11 +00:00
committed by GitHub
parent 2dd17225c6
commit 1fe3a1571a
84 changed files with 577 additions and 568 deletions
+6 -4
View File
@@ -41,7 +41,7 @@ from vllm.model_executor.layers.vocab_parallel_embedding import ParallelLMHead
from vllm.model_executor.models.qwen2 import Qwen2ForCausalLM, Qwen2Model
from vllm.sequence import IntermediateTensors
from .utils import AutoWeightsLoader, PPMissingLayer, maybe_prefix
from .utils import AutoWeightsLoader, PPMissingLayer, WeightsMapper, maybe_prefix
logger = init_logger(__name__)
@@ -87,6 +87,9 @@ class MiMoModel(Qwen2Model):
class MiMoForCausalLM(Qwen2ForCausalLM, nn.Module):
# MTP layers are loaded by the draft model, not the main model.
hf_to_vllm_mapper = WeightsMapper(orig_to_new_prefix={"model.mtp_layers.": None})
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
nn.Module.__init__(self)
config = vllm_config.model_config.hf_config
@@ -119,9 +122,8 @@ class MiMoForCausalLM(Qwen2ForCausalLM, nn.Module):
)
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
# MTP layers are loaded by the draft model, not the main model.
loader = AutoWeightsLoader(self, skip_prefixes=["model.mtp_layers."])
return loader.load_weights(weights)
loader = AutoWeightsLoader(self)
return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
def compute_logits(
self,