Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions python/sglang/srt/models/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def forward_normal(
if hasattr(self, "shared_experts") and use_intel_amx_backend(
self.shared_experts.gate_up_proj
):
return self.forward_cpu(hidden_states)
return self.forward_cpu(hidden_states, can_fuse_mlp_allreduce)

shared_output = self._forward_shared_experts(hidden_states)
# router_logits: (num_tokens, n_experts)
Expand All @@ -479,7 +479,9 @@ def forward_normal(
final_hidden_states = tensor_model_parallel_all_reduce(final_hidden_states)
return final_hidden_states

def forward_cpu(self, hidden_states: torch.Tensor) -> torch.Tensor:
def forward_cpu(
self, hidden_states: torch.Tensor, can_fuse_mlp_allreduce: bool = False
) -> torch.Tensor:
# router_logits: (num_tokens, n_experts)
router_logits = self.gate(hidden_states)
fused_experts_out = self.experts(
Expand Down Expand Up @@ -528,7 +530,7 @@ def forward_cpu(self, hidden_states: torch.Tensor) -> torch.Tensor:
None, # a2_scale
True, # is_vnni
)
if self.tp_size > 1 and not self.can_fuse_mlp_allreduce:
if self.tp_size > 1 and not can_fuse_mlp_allreduce:
final_hidden_states = tensor_model_parallel_all_reduce(final_hidden_states)
return final_hidden_states

Expand Down
Loading