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 4, 11:15 UTC
Fix Gemma4 MoE expert weight remapping (#41206)
Signed-off-by: sunghoon.baek <sunghoon.baek@connectfy.cloud> Co-authored-by: sunghoon.baek <sunghoon.baek@connectfy.cloud> Co-authored-by: OpenAI Codex <codex@openai.com>
Baekpica committed
Apr 30, 2026 at 16:12 UTC
ca97f7b9bbf2e904065dafc6918af3f9f386fdf0
1 file changed
+5
-1
vllm/model_executor/models/gemma4.py
+5
-1
@@ -84,6 +84,10 @@ from .utils import (
84
logger = init_logger(__name__)
85
86
87
+def _remap_gemma4_expert_weight_name(name: str) -> str:
88
+ return re.sub(r"(?<!\.moe)\.experts\.(\d+)\.", r".moe.experts.\1.", name)
89
+
90
+
91
@triton.jit
92
def _gemma4_routing_kernel(
93
gating_ptr,
@@ -1650,7 +1654,7 @@ class Gemma4ForCausalLM(
1654
# Remap individual 2D expert weights:
1655
# .experts.{id}.{proj} → .moe.experts.{id}.{proj}
1656
# (This handles per-expert 2D quantized weights)
1653
- name = re.sub(r"\.experts\.(\d+)\.", r".moe.experts.\1.", name)
1657
+ name = _remap_gemma4_expert_weight_name(name)
1658
1659
# MoE expert weights: checkpoint stores as 3D packed
1660
# tensors. Explode into per-expert 2D weights for