[PD] Enable all CP ranks for KVCache transfer (#19765)
Signed-off-by: Shangming Cai <csmthu@gmail.com>
This commit is contained in:
@@ -28,7 +28,10 @@ from sglang.srt.disaggregation.common.utils import (
|
||||
from sglang.srt.disaggregation.mooncake.utils import (
|
||||
check_mooncake_custom_mem_pool_enabled,
|
||||
)
|
||||
from sglang.srt.disaggregation.utils import DisaggregationMode
|
||||
from sglang.srt.disaggregation.utils import (
|
||||
DisaggregationMode,
|
||||
filter_kv_indices_for_cp_rank,
|
||||
)
|
||||
from sglang.srt.distributed.parallel_state import get_mooncake_transfer_engine
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
@@ -779,7 +782,12 @@ class MooncakeKVManager(CommonKVManager):
|
||||
)
|
||||
polls = []
|
||||
dst_ranks_infos = []
|
||||
local_rank = self.attn_tp_rank * self.pp_size + self.pp_rank
|
||||
# Unique id per prefill sender so decode's response set size matches expected_response_num.
|
||||
prefill_unique_rank = (
|
||||
self.attn_tp_rank * (self.pp_size * self.attn_cp_size)
|
||||
+ self.pp_rank * self.attn_cp_size
|
||||
+ self.attn_cp_rank
|
||||
)
|
||||
for req in reqs_to_be_processed:
|
||||
if not req.is_dummy:
|
||||
# Early exit if the request has failed
|
||||
@@ -795,7 +803,7 @@ class MooncakeKVManager(CommonKVManager):
|
||||
req.dst_port,
|
||||
req.room,
|
||||
KVPoll.Failed,
|
||||
local_rank,
|
||||
prefill_unique_rank,
|
||||
)
|
||||
break
|
||||
|
||||
@@ -857,7 +865,7 @@ class MooncakeKVManager(CommonKVManager):
|
||||
req.dst_port,
|
||||
req.room,
|
||||
KVPoll.Failed,
|
||||
local_rank,
|
||||
prefill_unique_rank,
|
||||
)
|
||||
break
|
||||
|
||||
@@ -888,7 +896,11 @@ class MooncakeKVManager(CommonKVManager):
|
||||
self.update_status(req.room, status)
|
||||
for endpoint, dst_port, room in dst_ranks_infos:
|
||||
self.sync_status_to_decode_endpoint(
|
||||
endpoint, dst_port, room, status, local_rank
|
||||
endpoint,
|
||||
dst_port,
|
||||
room,
|
||||
status,
|
||||
prefill_unique_rank,
|
||||
)
|
||||
else:
|
||||
# Dummy request means the decode instance is not used, so its status can be marked as success directly
|
||||
@@ -1136,7 +1148,14 @@ class MooncakeKVSender(CommonKVSender):
|
||||
self.curr_idx += len(kv_indices)
|
||||
is_last_chunk = self.curr_idx == self.num_kv_indices
|
||||
|
||||
if self.kv_mgr.is_dummy_cp_rank:
|
||||
# Special handling for cp
|
||||
if self.kv_mgr.enable_all_cp_ranks_for_transfer:
|
||||
kv_indices, index_slice = filter_kv_indices_for_cp_rank(
|
||||
self.kv_mgr,
|
||||
kv_indices,
|
||||
index_slice,
|
||||
)
|
||||
elif self.kv_mgr.is_dummy_cp_rank:
|
||||
if not is_last_chunk:
|
||||
return
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user