@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / c3666f56fd
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 10, 22:45 UTC

[Misc] Fix Qwen2-MoE shared_expert_gate (#31339)

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

Jee Jee Li committed Dec 26, 2025 at 13:10 UTC c3666f56fd23c5149871de844bd22c6a054f77d4
2 files changed +8 -3
vllm/lora/request.py
-1
@@ -20,7 +20,6 @@ class LoRARequest(
20 lora_name: str
21 lora_int_id: int
22 lora_path: str = ""
23 - long_lora_max_len: int | None = None
23 base_model_name: str | None = msgspec.field(default=None)
24 tensorizer_config_dict: dict | None = None
25
vllm/model_executor/models/qwen2_moe.py
+8 -2
@@ -111,7 +111,7 @@ class Qwen2MoeMLP(nn.Module):
111 out, _ = self.down_proj(out)
112
113 if self.expert_gate is not None:
114 - out = F.sigmoid(self.expert_gate(x)) * out
114 + out = F.sigmoid(self.expert_gate(x)[0]) * out
115
116 return out
117
@@ -140,7 +140,13 @@ class Qwen2MoeSparseMoeBlock(nn.Module):
140 prefix=f"{prefix}.gate",
141 )
142
143 - self.shared_expert_gate = torch.nn.Linear(config.hidden_size, 1, bias=False)
143 + self.shared_expert_gate = ReplicatedLinear(
144 + config.hidden_size,
145 + 1,
146 + bias=False,
147 + quant_config=None,
148 + prefix=f"{prefix}.shared_expert_gate",
149 + )
150
151 if config.shared_expert_intermediate_size > 0:
152 self.shared_expert = Qwen2MoeMLP(