[PLE] Carry the host-mapped pull transport onto v0.30.0

Restores the fork's PLE offload package (not upstream) and its pull
transport: the offload process holds no CUDA context; the captured op waits on
a device-mapped host flag and copies host->GPU on the model stream; publication
is fenced; releases are synchronous across dummy/capture work; failures close
the rank. Includes the test-only fault-injection cuts for the transport.

Co-Authored-By: Hinata <hinata@idihore.id>
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2026-10-09 19:49:16 +07:00
co-authored by Hinata
parent bc0a1cee82
commit 025fd08603
13 changed files with 3755 additions and 5 deletions
+145
View File
@@ -91,6 +91,7 @@ from vllm.v1.outputs import (
DraftTokenIds,
ModelRunnerOutput,
)
from vllm.v1.ple_offload.fatal import fail_ple_execute_model
from vllm.v1.utils import compute_iteration_details, report_usage_stats
from vllm.v1.worker import guard_telemetry
from vllm.v1.worker.sentinel.gpu_worker_sentinel import WorkerSentinel
@@ -238,6 +239,148 @@ class Worker(WorkerBase):
# Resolved lazily on first sleep/wake; persists worker-process state.
self._sleep_mode_backend: SleepModeBackend | None = None
def _has_ple_layers(self) -> bool:
"""Return whether this model configuration constructs PLE layers."""
if not envs.VLLM_PLE_CPU_OFFLOAD:
return False
text_config = self.model_config.hf_text_config
ple_layer_ids = getattr(text_config, "ple_layer_ids", None)
if not ple_layer_ids:
return False
# PP (vllm#54709, carried from the earlier overlay): only the pipeline rank
# that owns a PLE layer takes part in the offload (rank 0 with the
# default partition). Other ranks build PPMissingLayer there and must
# skip the connector entirely.
pp_size = self.parallel_config.pipeline_parallel_size
if pp_size > 1:
from vllm.distributed.utils import get_pp_indices
tp_size = self.parallel_config.tensor_parallel_size
pp_rank = (self.rank // tp_size) % pp_size
start, end = get_pp_indices(
int(text_config.num_hidden_layers), pp_rank, pp_size
)
return any(start <= int(i) - 1 < end for i in ple_layer_ids)
return True
def _validate_ple_offload_config(self) -> None:
"""Reject unsupported PLE offload execution modes."""
parallel_config = self.parallel_config
unsupported = []
if not self.use_v2_model_runner:
unsupported.append("model runner V1")
if not current_platform.is_cuda():
unsupported.append(f"device={current_platform.device_type}")
if parallel_config.nnodes != 1:
unsupported.append(f"nnodes={parallel_config.nnodes}")
if parallel_config.data_parallel_backend != "mp":
unsupported.append(f"DP backend={parallel_config.data_parallel_backend}")
if (
parallel_config.data_parallel_size_local
!= parallel_config.data_parallel_size
):
unsupported.append(
"non-local DP "
f"({parallel_config.data_parallel_size_local}/"
f"{parallel_config.data_parallel_size} local ranks)"
)
# PP allowed (vllm#54709): PLE layers must live on pipeline rank 0
# (enforced placement-based in models/config.py); num_workers stays
# dp_size * tp_size = the ranks of the owning stage.
if parallel_config.prefill_context_parallel_size != 1:
unsupported.append(f"PCP={parallel_config.prefill_context_parallel_size}")
if parallel_config.decode_context_parallel_size != 1:
unsupported.append(f"DCP={parallel_config.decode_context_parallel_size}")
if parallel_config.use_ubatching:
unsupported.append("ubatching/DBO")
if self.model_config.architecture not in {
"Qwen4ExpForCausalLM",
"Qwen4ExpForConditionalGeneration",
}:
unsupported.append("architecture")
if self.vllm_config.weight_transfer_config is not None:
unsupported.append("weight transfer")
if unsupported:
raise ValueError(
"VLLM_PLE_CPU_OFFLOAD does not support the requested "
"configuration. Unsupported settings: "
f"{', '.join(unsupported)}"
)
def spawn_ple_offload(self) -> None:
"""Spawn one node-local PLE CPU worker from DP0/TP0."""
if (
not self._ple_offload_enabled
or self.rank != 0
or self.parallel_config.data_parallel_rank != 0
):
return
from vllm.v1.ple_offload.worker import PleOffloadWorker
ipc_addr = self.parallel_config._ple_offload_ipc_path
if not ipc_addr:
raise RuntimeError("PLE offload IPC address was not initialized")
dp_size = self.parallel_config.data_parallel_size
tp_size = self.parallel_config.tensor_parallel_size
num_workers = dp_size * tp_size
logger.info(
"PleOffload: spawning worker "
"(rank=%d, local_rank=%d, dp_size=%d, tp_size=%d, "
"num_workers=%d, ipc_addr=%s).",
self.rank,
self.local_rank,
dp_size,
tp_size,
num_workers,
ipc_addr,
)
self._ple_offload_worker_handle = PleOffloadWorker.make_process(
self.vllm_config,
num_workers,
ipc_addr,
)
self._start_ple_offload_watchdog()
def _start_ple_offload_watchdog(self) -> None:
"""Fail this worker if the PLE offload process exits unexpectedly.
Host-mapped pull: a dead producer would leave the captured forward
waiting on its host flag forever; turn that into a fast, visible
engine failure instead of a hang. ``shutdown`` sets the stop marker
before closing the handle, so a normal close is not a failure.
"""
import threading
handle = self._ple_offload_worker_handle
self._ple_offload_stopping = False
def watch() -> None:
returncode = handle.proc.wait()
if getattr(self, "_ple_offload_stopping", False):
return
logger.error(
"PLE offload process %s exited unexpectedly (exitcode %s); "
"failing this worker so the engine does not hang on a PLE wait",
handle.proc.pid,
returncode,
)
os._exit(1)
threading.Thread(
target=watch, name="ple-offload-watchdog", daemon=True
).start()
def wait_ple_offload_ready(self) -> None:
"""Wait until weights and every TP registration are ready."""
if self._ple_offload_worker_handle is None:
return
from vllm.v1.ple_offload.worker import PleOffloadWorker
PleOffloadWorker.wait_for_ready(self._ple_offload_worker_handle)
@property
def sleep_mode_backend(self) -> "SleepModeBackend":
if self._sleep_mode_backend is None:
@@ -1263,6 +1406,7 @@ class Worker(WorkerBase):
) -> ModelRunnerOutput | AsyncModelRunnerOutput:
return self.model_runner.sample_tokens(grammar_output)
@fail_ple_execute_model
@torch.inference_mode()
@with_gpu_sync_check
def execute_model(
@@ -1587,6 +1731,7 @@ class Worker(WorkerBase):
self.model_runner.reset_lora_state()
def shutdown(self) -> None:
self._ple_offload_stopping = True
gc.unfreeze()
# Bounds-guard instrumentation: synchronous final read of the guard