[Qwen4Exp] Pipeline-stage ownership for PLE, the MTP drafter and the vision tower
Each pipeline stage builds only the parts it owns: PLE when every PLE layer lives on stage 0, MTP under PP (port of vLLM PR #46994 minus its ROCm MLA file and tests) with the drafter on the last stage, and the vision tower on the first stage only. Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -238,6 +238,118 @@ 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,
|
||||
)
|
||||
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user