[PCP] Support prefill context parallelism with data parallelism (#57075)

Signed-off-by: QiuChunshuo <qiuchunshuo@huawei.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
Co-authored-by: QiuChunshuo <qiuchunshuo@huawei.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
Co-authored-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Lucas Wilkinson
2026-09-23 22:32:36 -04:00
committed by GitHub
co-authored by QiuChunshuo Claude Fable 5.1 Codex Robert Shaw Nick Hill mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 6697a7dd30
commit e6dc16cebd
15 changed files with 268 additions and 26 deletions
+1 -1
View File
@@ -828,7 +828,7 @@ def split_decodes_and_prefills(
(query_lens == query_lens[0]) | (query_lens == 0)
):
return num_reqs, 0, num_tokens, 0 # all decodes
is_prefill = query_lens != query_lens[0]
is_prefill = (query_lens != query_lens[0]) & (query_lens != 0)
else:
is_prefill = query_lens > decode_threshold
+9 -2
View File
@@ -18,8 +18,15 @@ def _gather_prefill_cache_inputs(
assert all(tensor.shape[0] == local_num_tokens for tensor in tensors)
assert 0 <= num_decode_tokens <= local_num_tokens
if num_decode_tokens == local_num_tokens:
return tensors, slot_mapping[:num_decode_tokens]
# Replicated draft decodes use unexpanded slot mappings, even with DP padding.
if (
num_decode_tokens == local_num_tokens
or slot_mapping.shape[0] <= local_num_tokens
):
return (
tuple(tensor[:num_decode_tokens] for tensor in tensors),
slot_mapping[:num_decode_tokens],
)
pcp_group = get_pcp_group()
gathered_prefills = tuple(
+1
View File
@@ -754,6 +754,7 @@ class PCPManager:
def prepare_draft_prefill(
self, input_batch: InputBatch, input_ids: torch.Tensor
) -> None:
self.draft_prefill_batch = None
if input_batch is not self._global_batch or self._local_batch is None:
return
local_batch = self._local_batch
+1 -1
View File
@@ -364,7 +364,7 @@ class DraftModelSpeculator(BaseSpeculator):
kv_cache_config=self.kv_cache_config,
causal=causal,
seq_lens_cpu_upper_bound=draft_seq_lens_cpu_upper_bound,
is_prefilling=self.draft_is_prefilling[:num_reqs],
is_prefilling=self.draft_is_prefilling[:num_reqs_padded],
)
return attn_metadata
+4 -3
View File
@@ -406,13 +406,14 @@ class Worker(WorkerBase):
if dp_local_rank is None:
dp_local_rank = self.parallel_config.data_parallel_index
tp_pp_world_size = (
tp_pcp_pp_world_size = (
self.parallel_config.pipeline_parallel_size
* self.parallel_config.prefill_context_parallel_size
* self.parallel_config.tensor_parallel_size
)
# DP_LOCAL_RANK * TP_PP_WORLD_SIZE + TP_LOCAL_RANK
self.local_rank += dp_local_rank * tp_pp_world_size
# DP_LOCAL_RANK * TP_PCP_PP_WORLD_SIZE + TP_LOCAL_RANK
self.local_rank += dp_local_rank * tp_pcp_pp_world_size
# Publish the logical-to-physical mapping for topology queries
# such as NIC affinity and P2P checks.