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, 23:45 UTC
Fix GLM-4 PP Missing Layer When using with PP. (#21531)
Signed-off-by: zRzRzRzRzRzRzR <2448370773@qq.com>
Yuxuan Zhang committed
Jul 25, 2025 at 11:07 UTC
2ce90e5b01aafca68cc821ff778de3ca65c75439
1 file changed
+9
-3
vllm/model_executor/models/glm4_moe.py
+9
-3
@@ -612,14 +612,20 @@ class Glm4MoeForCausalLM(nn.Module, SupportsPP):
612
self.num_expert_groups = config.n_group
613
614
self.moe_layers: list[FusedMoE] = []
615
+ example_moe = None
616
for layer in self.model.layers:
617
+ if isinstance(layer, PPMissingLayer):
618
+ continue
619
+
620
assert isinstance(layer, Glm4MoeDecoderLayer)
621
if isinstance(layer.mlp, Glm4MoE):
622
+ # Pick last one layer since the first ones may be dense layers.
623
+ example_moe = layer.mlp
624
self.moe_layers.append(layer.mlp.experts)
625
620
- # Pick last one layer since the first ones may be dense layers.
621
- example_moe = typing.cast(
622
- Glm4MoE, self.model.layers[config.num_hidden_layers - 1].mlp)
626
+ if example_moe is None:
627
+ raise RuntimeError("No Glm4MoE layer found in model.layers.")
628
+
629
self.num_logical_experts = example_moe.n_logical_experts
630
self.num_physical_experts = example_moe.n_physical_experts
631
self.num_local_physical_experts = example_moe.n_local_physical_experts