Skip to content

Commit ed8e8b7

Browse files
LostFox11LostFox11
andauthored
[BugFix]Resolve the bubble in the PP pipeline of PP+MTP and fix the verification of PP in the pd separation scenario. (vllm-project#10855)
### What this PR does / why we need it? In the pd separation + pp + mtp scenario, synchronization is avoided and bubbles are eliminated by skipping the broadcast of the p node. Fix the verification of PP in the pd separation scenario. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? ran GLM5.1 gpqa test 87.37 - vLLM version: v0.23.0 - vLLM main: vllm-project/vllm@967c5c3 Signed-off-by: LostFox11 <wangziyue17@huawei.com> Co-authored-by: LostFox11 <wangziyue17@huawei.com>
1 parent 8f8c56f commit ed8e8b7

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

vllm_ascend/distributed/kv_transfer/kv_p2p/mooncake_connector.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,15 @@ def set_xfer_handshake_metadata(self, metadata: dict[int, KVConnectorHandshakeMe
14111411
assert self.connector_scheduler is not None
14121412
self.connector_scheduler.set_xfer_handshake_metadata(metadata)
14131413

1414+
def set_xfer_handshake_metadata_pp_aware(
1415+
self, metadata: dict[tuple[int, int], KVConnectorHandshakeMetadata]
1416+
) -> None:
1417+
tp_size = max(tp_rank for (_, tp_rank) in metadata) + 1
1418+
flat_metadata: dict[int, KVConnectorHandshakeMetadata] = {
1419+
pp_rank * tp_size + tp_rank: meta for (pp_rank, tp_rank), meta in metadata.items()
1420+
}
1421+
self.set_xfer_handshake_metadata(flat_metadata)
1422+
14141423

14151424
class MooncakeConnectorScheduler:
14161425
"""Implementation of Scheduler side methods"""
@@ -1782,7 +1791,11 @@ def __init__(self, vllm_config: VllmConfig, engine_id: str, kv_cache_config: KVC
17821791
device_index = (self.pp_rank + self.pcp_rank) * self.tp_size + self.tp_rank
17831792
self.handshake_port = self.side_channel_port + device_index
17841793
self.sockets: dict = {}
1785-
self.engine = global_te.get_transfer_engine(self.side_channel_host, device_name=None)
1794+
device_name = str(torch.npu.current_device()) if self.pp_size > 1 else None
1795+
self.engine = global_te.get_transfer_engine(
1796+
self.side_channel_host,
1797+
device_name=device_name,
1798+
)
17861799
self.te_rpc_port = self.engine.get_rpc_port()
17871800

17881801
# Background thread for sending or receiving KV caches.

vllm_ascend/worker/model_runner_v1.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,13 +2394,15 @@ def sample_tokens(
23942394
) -> ModelRunnerOutput | AsyncModelRunnerOutput | IntermediateTensors:
23952395
kv_connector_output = self.kv_connector_output
23962396
self.kv_connector_output = None
2397+
pp = get_pp_group()
2398+
skip_pp_pd_broadcast = self.is_kv_producer and pp.world_size > 1
23972399

23982400
if self.execute_model_state is None:
23992401
# Nothing to do (PP non-final rank case), output isn't used.
24002402
# receive sampled token ids from the last PP rank when using
24012403
# async scheduling + pipeline parallelism so downstream code
24022404
# (e.g., PCP input preparation) can access them.
2403-
if self.use_async_scheduling and get_pp_group().world_size > 1:
2405+
if self.use_async_scheduling and pp.world_size > 1 and not skip_pp_pd_broadcast:
24042406
self._pp_receive_prev_sampled_token_ids_to_input_batch()
24052407
if not kv_connector_output:
24062408
return None # noqa
@@ -2546,8 +2548,7 @@ def propose_draft_token_ids(sampled_token_ids):
25462548
# last PP rank so other PP ranks can receive them without going
25472549
# through the scheduler/engine IPC path.
25482550
if self.use_async_scheduling:
2549-
pp = get_pp_group()
2550-
if pp.world_size > 1 and pp.is_last_rank:
2551+
if pp.world_size > 1 and pp.is_last_rank and not skip_pp_pd_broadcast:
25512552
self._pp_broadcast_prev_sampled_token_ids(sampler_output.sampled_token_ids)
25522553

25532554
if not self.use_async_scheduling:

0 commit comments

Comments
 (0)