Skip to content

Commit f889aab

Browse files
yewentao2560xrushi
authored andcommitted
[Bug] Fix modular_kernel: ZeroDivisionError: integer division or modulo by zero (vllm-project#26528)
Signed-off-by: yewentao256 <zhyanwentao@126.com> Signed-off-by: 0xrushi <6279035+0xrushi@users.noreply.github.com>
1 parent 2938e93 commit f889aab

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

vllm/model_executor/layers/fused_moe/modular_kernel.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,10 +717,13 @@ def _chunk_info(self, M: int) -> tuple[int, int]:
717717
get num_chunks == 1. Take max(M, 1) to avoid divide by zero.
718718
If there are no tokens to process, the number of chunks will be zero.
719719
"""
720-
CHUNK_SIZE = (
721-
max(M, 1)
722-
if not self.fused_experts.supports_chunking()
723-
else min(M, envs.VLLM_FUSED_MOE_CHUNK_SIZE)
720+
CHUNK_SIZE = max(
721+
1,
722+
(
723+
M
724+
if not self.fused_experts.supports_chunking()
725+
else min(M, envs.VLLM_FUSED_MOE_CHUNK_SIZE)
726+
),
724727
)
725728
num_chunks = cdiv(M, CHUNK_SIZE)
726729
# If there are no tokens, then there should be no loop iterations.

0 commit comments

Comments
 (0)