@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / f0a30a067b
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[Bugfix] Fix qwen-moe packed_modules_mapping (#26634)

Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>

Jee Jee Li committed Oct 11, 2025 at 23:21 UTC f0a30a067bacb9f3aaec1cc7a7efe005d6b2ff30
3 files changed +23 -11
vllm/model_executor/models/interfaces.py
+1 -1
@@ -325,7 +325,7 @@ class SupportsLoRA(Protocol):
325 # are empty by default.
326 embedding_modules: ClassVar[dict[str, str]] = {}
327 embedding_padding_modules: ClassVar[list[str]] = []
328 - packed_modules_mapping: ClassVar[dict[str, list[str]]] = {}
328 + packed_modules_mapping: dict[str, list[str]] = {}
329
330
331 # We can't use runtime_checkable with ClassVar for issubclass checks
vllm/model_executor/models/qwen2_moe.py
+13 -5
@@ -534,11 +534,7 @@ class Qwen2MoeForCausalLM(nn.Module, SupportsPP, SupportsLoRA):
534 "q_proj",
535 "k_proj",
536 "v_proj",
537 - ],
538 - "gate_up_proj": [
539 - "gate_proj",
540 - "up_proj",
541 - ],
537 + ]
538 }
539
540 def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
@@ -547,6 +543,18 @@ class Qwen2MoeForCausalLM(nn.Module, SupportsPP, SupportsLoRA):
543 quant_config = vllm_config.quant_config
544 self.config = config
545 self.quant_config = quant_config
546 + # Only perform the following mapping when Qwen2MoeMLP exists
547 + if (
548 + getattr(config, "mlp_only_layers", [])
549 + or config.shared_expert_intermediate_size > 0
550 + ):
551 + self.packed_modules_mapping["gate_up_proj"] = (
552 + [
553 + "gate_proj",
554 + "up_proj",
555 + ],
556 + )
557 +
558 self.model = Qwen2MoeModel(
559 vllm_config=vllm_config, prefix=maybe_prefix(prefix, "model")
560 )
vllm/model_executor/models/qwen3_moe.py
+9 -5
@@ -634,11 +634,7 @@ class Qwen3MoeForCausalLM(
634 "q_proj",
635 "k_proj",
636 "v_proj",
637 - ],
638 - "gate_up_proj": [
639 - "gate_proj",
640 - "up_proj",
641 - ],
637 + ]
638 }
639
640 fall_back_to_pt_during_load = False
@@ -649,6 +645,14 @@ class Qwen3MoeForCausalLM(
645 quant_config = vllm_config.quant_config
646 self.config = config
647 self.quant_config = quant_config
648 + # Only perform the following mapping when Qwen3MoeMLP exists
649 + if getattr(config, "mlp_only_layers", []):
650 + self.packed_modules_mapping["gate_up_proj"] = (
651 + [
652 + "gate_proj",
653 + "up_proj",
654 + ],
655 + )
656 self.model = Qwen3MoeModel(
657 vllm_config=vllm_config, prefix=maybe_prefix(prefix, "model")
658 )