Skip to content

[Bugfix] Fix wrong num_experts in invoke_fused_moe_wna16 kernels - #36026

Closed
weiguangli-io wants to merge 1 commit into
vllm-project:mainfrom
weiguangli-io:codex/vllm-36008-fused-moe-num-experts
Closed

weiguangli-io wants to merge 1 commit into
vllm-project:mainfrom
weiguangli-io:codex/vllm-36008-fused-moe-num-experts

Conversation

@weiguangli-io

Copy link
Copy Markdown
Contributor

Summary

Both invoke_fused_moe_wna16_cuda_kernel and invoke_fused_moe_wna16_triton_kernel pass B.size(1) (output dimension N) as num_experts to get_moe_wna16_block_config. The expert dimension is actually B.size(0).

This causes incorrect block configuration and can lead to a CUDA runtime crash:

RuntimeError: BLOCK_SIZE_K // group_size must be one of [1, 2, 4, 8]

Fix: Change num_experts=B.size(1) to num_experts=B.size(0) in both kernel invocation functions.

Fixes #36008

Test plan

  • The fix is a straightforward parameter correction (dimension 1 → dimension 0) with no behavioral change for correctly-shaped inputs
  • Verified that tensor B has shape (num_experts, N, K // pack_factor), confirming B.size(0) is the expert count

…rnels

Both `invoke_fused_moe_wna16_cuda_kernel` and
`invoke_fused_moe_wna16_triton_kernel` pass `B.size(1)` (output
dimension N) as `num_experts` to `get_moe_wna16_block_config`, but the
expert dimension is `B.size(0)`. This causes incorrect block
configuration and can lead to a CUDA runtime crash with
"BLOCK_SIZE_K // group_size must be one of [1, 2, 4, 8]".

Fix by using `B.size(0)` instead.

Fixes vllm-project#36008

Signed-off-by: OiPunk <codingpunk@gmail.com>
@mergify mergify Bot added the bug Something isn't working label Mar 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug in the invoke_fused_moe_wna16_cuda_kernel and invoke_fused_moe_wna16_triton_kernel functions. The num_experts parameter passed to get_moe_wna16_block_config was incorrectly using B.size(1) instead of B.size(0). This change aligns with the tensor shape documentation, where the first dimension of the weight tensor B represents the number of experts, and resolves a potential CUDA runtime crash. The fix is straightforward and correct.

@weiguangli-io

Copy link
Copy Markdown
Contributor Author

Friendly ping — this PR has been open for a few weeks. Would appreciate a review when you get a chance. Happy to address any feedback. Thanks!

@weiguangli-io

Copy link
Copy Markdown
Contributor Author

Closing this PR as it has been open for 8+ weeks with no maintainer review despite follow-up. The fix is straightforward, so feel free to reopen if this becomes relevant. Happy to rebase if needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: invoke_fused_moe_wna16_*_kernel calls get_moe_wna16_block_config with bad parameters

1 participant