Skip to content

Commit ad6c2e1

Browse files
authored
Correct PPMissingLayer handling in Deepseek-V2-Lite PP deployment (#20665)
Signed-off-by: Seiji Eicher <seiji@anyscale.com>
1 parent 49e8c7e commit ad6c2e1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

vllm/model_executor/models/deepseek_v2.py

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

741741
self.moe_layers: list[FusedMoE] = []
742+
example_moe = None
742743
for layer in self.model.layers:
744+
if isinstance(layer, PPMissingLayer):
745+
continue
746+
743747
assert isinstance(layer, DeepseekV2DecoderLayer)
744748
if isinstance(layer.mlp, DeepseekV2MoE):
749+
# Pick last one layer since the first ones may be dense layers.
750+
example_moe = layer.mlp
745751
self.moe_layers.append(layer.mlp.experts)
746752

747-
# Pick last one layer since the first ones may be dense layers.
748-
example_moe = typing.cast(
749-
DeepseekV2MoE, self.model.layers[config.num_hidden_layers - 1].mlp)
753+
if example_moe is None:
754+
raise RuntimeError("No DeepseekV2MoE layer found in model.layers.")
755+
750756
self.num_logical_experts = example_moe.n_logical_experts
751757
self.num_physical_experts = example_moe.n_physical_experts
752758
self.num_local_physical_experts = example_moe.n_local_physical_experts

0 commit comments

Comments
 (0)