Skip to content

Commit 5c8f2ad

Browse files
authored
[Bugfix] Fix block size in block_table with PCP (#29094)
Signed-off-by: Livinfly <[email protected]>
1 parent ed8e684 commit 5c8f2ad

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

vllm/v1/worker/block_table.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(
8484
self.pcp_world_size = get_pcp_group().world_size
8585
self.pcp_rank = get_pcp_group().rank_in_group
8686
except AssertionError:
87-
# DCP might not be initialized in testing
87+
# PCP might not be initialized in testing
8888
self.pcp_world_size = 1
8989
self.pcp_rank = 0
9090
try:
@@ -268,6 +268,11 @@ def __init__(
268268
# (max_model_len//dcp_world_size) tokens in kvcache,
269269
# so the block_size which used for calc max_num_blocks_per_req
270270
# must be multiplied by dcp_world_size.
271+
try:
272+
pcp_world_size = get_pcp_group().world_size
273+
except AssertionError:
274+
# PCP might not be initialized in testing
275+
pcp_world_size = 1
271276
try:
272277
dcp_world_size = get_dcp_group().world_size
273278
except AssertionError:
@@ -280,12 +285,14 @@ def __init__(
280285
f"must match block_sizes length ({len(block_sizes)})"
281286
)
282287

288+
total_cp_world_size = dcp_world_size * pcp_world_size
289+
283290
self.block_tables = [
284291
BlockTable(
285292
block_size,
286293
max_num_reqs,
287294
max(
288-
cdiv(max_model_len, block_size * dcp_world_size),
295+
cdiv(max_model_len, block_size * total_cp_world_size),
289296
1 + num_speculative_tokens,
290297
),
291298
max_num_batched_tokens,

0 commit comments

Comments
 (0)