Skip to content

[Kernel] Remove cumsum in groupedmatmul #987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
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
9 changes: 4 additions & 5 deletions vllm_ascend/ops/fused_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@ def fused_experts_with_mc2(
0:5]

w1 = w1.transpose(1, 2)
expert_token_nums = torch.cumsum(expert_token_nums,
dim=0,
dtype=torch.int64)

group_list = expert_token_nums.to(torch.int64)
gate_up_out_list = torch_npu.npu_grouped_matmul(
x=[expand_x],
weight=[w1],
split_item=2,
group_list_type=0,
# 1 means count mode, to avoid cumulative operation of the group list
group_list_type=1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add some comments to explain why group_list_type=1 is used here, e.g., to avoid the cumulative calculation of the group list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

group_type=0,
group_list=group_list,
)
Expand All @@ -111,7 +110,7 @@ def fused_experts_with_mc2(
x=[gate_up_out],
weight=[w2],
split_item=2,
group_list_type=0,
group_list_type=1,
group_type=0,
group_list=group_list,
)
Expand Down