Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 10 additions & 2 deletions python/sglang/srt/managers/scheduler_pp_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ def _pp_commit_send_output_work_and_preprocess_output_tensors(

def _pp_send_pyobj_to_next_stage(self: Scheduler, data, async_send: bool = False):
p2p_work = []
if self.attn_tp_rank == 0:
if self.attn_tp_rank == 0 and self.attn_cp_rank == 0:
dp_offset = self.attn_dp_rank * self.attn_tp_size
p2p_work = point_to_point_pyobj(
data,
Expand All @@ -872,7 +872,7 @@ def _pp_send_pyobj_to_next_stage(self: Scheduler, data, async_send: bool = False
return p2p_work

def _pp_recv_pyobj_from_prev_stage(self: Scheduler):
if self.attn_tp_rank == 0:
if self.attn_tp_rank == 0 and self.attn_cp_rank == 0:
dp_offset = self.attn_dp_rank * self.attn_tp_size
data = point_to_point_pyobj(
[],
Expand All @@ -892,6 +892,14 @@ def _pp_recv_pyobj_from_prev_stage(self: Scheduler):
src=self.attn_tp_group.ranks[0],
)

if self.attn_cp_size > 1:
data = broadcast_pyobj(
data,
self.attn_cp_group.rank,
self.attn_cp_cpu_group,
src=self.attn_cp_group.ranks[0],
)

return data

def _pp_prepare_tensor_dict(
Expand Down
4 changes: 3 additions & 1 deletion python/sglang/srt/server_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ def _handle_model_specific_adjustments(self):
assert (
self.tp_size == 8
), "Current multi-machine CP support suffers from precision issues. So context parallel only support Single machine(tp_size == 8)"
self.attn_cp_size = self.tp_size

logger.warning(
f"Enable Context Parallel opt for deeeseekv3.2-DSA, Setting dp_size == {self.dp_size} and moe_dense_tp_size == {self.moe_dense_tp_size}, ep_size == {self.ep_size}, tp_size == {self.tp_size}, kv_cache_dtype == {self.kv_cache_dtype}, moe_a2a_backend {self.moe_a2a_backend} "
Expand Down Expand Up @@ -2116,7 +2117,8 @@ def _handle_context_parallelism(self):
assert (
self.tp_size % (self.dp_size * self.attn_cp_size) == 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we clarify the attn_cp_size ? Currently cp is used as attn_dp_size = tp / dp. It can be confusing .

), "tp_size must be divisible by dp_size * attn_cp_size"
assert self.pp_size == 1, "PP is not supported with context parallelism"
if not self.enable_nsa_prefill_context_parallel:
assert self.pp_size == 1, "PP is not supported with context parallelism"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be reomved.

with TP=2, we can support CP for H800/H20x8.

For H200, there is no such constraints.


if self.moe_dp_size > 1:
# The tp_size is the world size, not the real tensor parallel size
Expand Down
Loading