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
2 changes: 1 addition & 1 deletion vllm/v1/attention/backends/mla/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def build(
dcp_local_seq_lens[:num_decodes] = seq_lens[
:num_decodes
] // self.dcp_world_size + (
self.dcp_rank <= (seq_lens[:num_decodes] - 1) % self.dcp_world_size
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The previous logic for distributing remainder tokens, self.dcp_rank <= (seq_lens[:num_decodes] - 1) % self.dcp_world_size, was flawed. When a sequence length L is perfectly divisible by the world size W, (L - 1) % W evaluates to W - 1. This caused the condition to be true for all ranks, incorrectly incrementing each rank's local sequence length by one.

The new logic, self.dcp_rank < seq_lens[:num_decodes] % self.dcp_world_size, correctly handles this. When L % W == 0, no rank gets an extra token. When there is a remainder, it is correctly distributed among the first L % W ranks. This change fixes the bug and ensures correct behavior for all cases.

Suggested change
self.dcp_rank <= (seq_lens[:num_decodes] - 1) % self.dcp_world_size
self.dcp_rank < seq_lens[:num_decodes] % self.dcp_world_size

self.dcp_rank < seq_lens[:num_decodes] % self.dcp_world_size
)

assert num_decodes + num_prefills == num_reqs
Expand Down