Skip to content

Commit 567228e

Browse files
author
weijinqian
committed
handle clean code
Signed-off-by: weijinqian_v1 <weijinqian@huawei.com>
1 parent c73953c commit 567228e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

vllm_ascend/ops/fused_moe.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ def fused_experts_with_all2all_buffer(
517517
dtype=expert_idx_buffer_scatter.dtype,
518518
device=expert_idx_buffer_scatter.device,
519519
)
520-
non_pad_len = torch.sum((expert_idx_buffer_scatter
521-
!= global_num_experts).to(torch.int32))
520+
non_pad_len = torch.sum(
521+
(expert_idx_buffer_scatter != global_num_experts).to(torch.int32))
522522
hidden_states_pad_idx[expert_idx_buffer_scatter != global_num_experts] = (
523523
torch.arange(
524524
non_pad_len,
@@ -580,8 +580,8 @@ def fused_experts_with_all2all_buffer(
580580
dist.all_to_all_single(hidden_states_gatter,
581581
hidden_states_scatter,
582582
group=ep_group.device_group)
583-
hidden_states_gatter = hidden_states_gatter[expert_idx_buffer_scatter !=
584-
global_num_experts]
583+
hidden_states_gatter = hidden_states_gatter[
584+
expert_idx_buffer_scatter != global_num_experts]
585585
if hidden_states_gatter.shape[0] != row_idx_len:
586586
hidden_states = torch.zeros(
587587
(row_idx_len, hidden_states.shape[1]),
@@ -776,10 +776,9 @@ def fused_experts(
776776
# This created multiple NaN and index_add_ will mix them up which harms accuracy
777777
# remove this mask and filter after it being fixed
778778
num_valid_tokens = mask.sum()
779-
valid_token_mask = (torch.arange(0,
780-
sorted_token_indices.shape[0],
781-
device=device).unsqueeze(1)
782-
< num_valid_tokens)
779+
valid_token_mask = (torch.arange(
780+
0, sorted_token_indices.shape[0], device=device).unsqueeze(1) <
781+
num_valid_tokens)
783782
valid_output = torch.where(
784783
valid_token_mask, weighted_down_out,
785784
torch.zeros_like(weighted_down_out)).to(dtype)

0 commit comments

Comments
 (0)