Skip to content

Commit 7d2f8bb

Browse files
committed
[Bugfix] Fix early return in CustomDeepseekV2MoE.forward during profile_run
1 parent 413657a commit 7d2f8bb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vllm_ascend/models/deepseek_v2.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,24 @@ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
143143
attn_metadata = get_forward_context().attn_metadata
144144
if attn_metadata is None:
145145
# for profile run
146-
return hidden_states
146+
is_prefill = True
147+
else:
148+
is_prefill = attn_metadata.num_prefills > 0
147149
num_tokens, hidden_dim = hidden_states.shape
148150
hidden_states = hidden_states.view(-1, hidden_dim)
149151

150152
if self.n_shared_experts is not None:
151153
shared_output = self.shared_experts(hidden_states)
152154

153-
if (self.tp_size > 1 and self.enable_mc2
154-
and attn_metadata.num_prefills == 0):
155+
if (self.tp_size > 1 and self.enable_mc2 and not is_prefill):
155156
chunks = torch.chunk(hidden_states,
156157
get_tp_group().world_size,
157158
dim=0)
158159
hidden_states = chunks[get_tp_group().rank_in_group]
159160

160161
# router_logits: (num_tokens, n_experts)
161162
router_logits, _ = self.gate(hidden_states)
162-
is_prefill = True if attn_metadata.num_prefills > 0 else False
163-
# is_prefill = attn_metadata.num_prefills > 0
163+
164164
final_hidden_states = self.experts(
165165
hidden_states=hidden_states,
166166
router_logits=router_logits,

0 commit comments

Comments
 (0)