Skip to content

Commit 2ce90e5

Browse files
Fix GLM-4 PP Missing Layer When using with PP. (vllm-project#21531)
Signed-off-by: zRzRzRzRzRzRzR <[email protected]>
1 parent 633f6e8 commit 2ce90e5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

vllm/model_executor/models/glm4_moe.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,20 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
612612
self.num_expert_groups = config.n_group
613613

614614
self.moe_layers: list[FusedMoE] = []
615+
example_moe = None
615616
for layer in self.model.layers:
617+
if isinstance(layer, PPMissingLayer):
618+
continue
619+
616620
assert isinstance(layer, Glm4MoeDecoderLayer)
617621
if isinstance(layer.mlp, Glm4MoE):
622+
# Pick last one layer since the first ones may be dense layers.
623+
example_moe = layer.mlp
618624
self.moe_layers.append(layer.mlp.experts)
619625

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+
623629
self.num_logical_experts = example_moe.n_logical_experts
624630
self.num_physical_experts = example_moe.n_physical_experts
625631
self.num_local_physical_experts = example_moe.n_local_physical_experts

0 commit comments

Comments
 (0)