[Bugfix][Core] Wait for the previous PP tensor sends before the next forward pass (#54962)

Signed-off-by: Derek Weitzel <djw8605@gmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Derek Weitzel
2026-09-03 08:01:36 +00:00
committed by GitHub
co-authored by Claude Fable 5.1
parent ee17d0d869
commit 859dd39512
3 changed files with 85 additions and 7 deletions
+15 -6
View File
@@ -219,6 +219,9 @@ class Worker(WorkerBase):
self.use_v2_model_runner = vllm_config.use_v2_model_runner
# Device handles of the previous step's PP intermediate-tensor send.
self._pp_send_work: list[Handle] = []
# Resolved lazily on first sleep/wake; persists worker-process state.
self._sleep_mode_backend: SleepModeBackend | None = None
@@ -1113,6 +1116,13 @@ class Worker(WorkerBase):
def execute_model(
self, scheduler_output: "SchedulerOutput"
) -> ModelRunnerOutput | AsyncModelRunnerOutput | None:
# Wait for the previous step's sends so this forward pass cannot
# overwrite buffers they are still reading.
if self._pp_send_work:
for handle in self._pp_send_work:
handle.wait()
self._pp_send_work = []
intermediate_tensors = None
forward_pass = scheduler_output.total_num_scheduled_tokens > 0
num_scheduled_tokens = scheduler_output.total_num_scheduled_tokens
@@ -1185,16 +1195,15 @@ class Worker(WorkerBase):
and not get_pp_group().is_last_rank
)
# launch non-blocking send of intermediate tensors; the
# GroupCoordinator self-retains the source tensors and the
# metadata handle in ``_pending_isends`` and reaps them lazily on
# the next ``isend_tensor_dict(is_async=True)`` call, so this
# step returns without waiting for the receiver to drain.
get_pp_group().isend_tensor_dict(
# Non-blocking send of the intermediate tensors. The metadata handle
# is reaped lazily by the GroupCoordinator; the device handles are
# waited at the top of the next step.
handles = get_pp_group().isend_tensor_dict(
output.tensors,
all_gather_group=get_tp_group(),
all_gather_tensors=all_gather_tensors,
)
self._pp_send_work = handles[1:]
return None