[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:
@@ -74,6 +74,9 @@ from vllm.v1.outputs import (
|
||||
ECConnectorOutput,
|
||||
ModelRunnerOutput,
|
||||
)
|
||||
from vllm.v1.ple_offload.connector import PleOffloadConnector
|
||||
from vllm.v1.ple_offload.fatal import fail_ple_execute_model
|
||||
from vllm.v1.ple_offload.test_fault import _FAULT
|
||||
from vllm.v1.watermarking import create_watermarker
|
||||
from vllm.v1.watermarking.gpu_sampler import GPUWatermarkSampler
|
||||
from vllm.v1.watermarking.spec_decode import (
|
||||
@@ -1757,6 +1760,45 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
self.ec_connector.no_forward(scheduler_output).ec_connector_output,
|
||||
)
|
||||
|
||||
def _prepare_ple_forward(
|
||||
self,
|
||||
input_batch: InputBatch,
|
||||
batch_desc: BatchExecutionDescriptor,
|
||||
dummy_run: bool,
|
||||
*,
|
||||
serving: bool = False,
|
||||
transaction_id: str | None = None,
|
||||
correlation_id: str | None = None,
|
||||
) -> None:
|
||||
connector = self._ple_offload_connector
|
||||
assert connector is not None
|
||||
request_num_tokens = int(input_batch.num_tokens_after_padding)
|
||||
if batch_desc.cg_mode == CUDAGraphMode.FULL:
|
||||
manager = self.cudagraph_manager
|
||||
if manager is None:
|
||||
raise RuntimeError("PLE FULL replay has no CUDA graph manager")
|
||||
copy_num_tokens = manager.ple_copy_rows(batch_desc)
|
||||
else:
|
||||
# PIECEWISE/eager execute the Python op with this actual padded view.
|
||||
copy_num_tokens = int(input_batch.input_ids.shape[0])
|
||||
|
||||
if request_num_tokens != copy_num_tokens:
|
||||
raise RuntimeError(
|
||||
"PLE request/selected-forward copy-count mismatch: "
|
||||
f"request={request_num_tokens}, copy={copy_num_tokens}, "
|
||||
f"mode={batch_desc.cg_mode}"
|
||||
)
|
||||
connector.prepare_forward(
|
||||
input_batch.num_reqs,
|
||||
request_num_tokens,
|
||||
dummy_run,
|
||||
consumer_num_tokens=copy_num_tokens,
|
||||
serving=serving,
|
||||
transaction_id=transaction_id,
|
||||
correlation_id=correlation_id,
|
||||
)
|
||||
|
||||
@fail_ple_execute_model
|
||||
@torch.inference_mode()
|
||||
def execute_model(
|
||||
self,
|
||||
@@ -2038,6 +2080,54 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
)
|
||||
self.step_timing.forward_start()
|
||||
|
||||
# prepare_inputs has finalized MRV2's GPU buffers. Stage D2H on this
|
||||
# stream before the PLE placeholder can wait for CPU output.
|
||||
connector = self._ple_offload_connector
|
||||
ple_serving = False
|
||||
ple_sequence = None
|
||||
ple_transaction = None
|
||||
ple_correlation = None
|
||||
if connector is not None:
|
||||
ple_serving = not dummy_run and not is_profile
|
||||
ple_sequence = connector.begin_forward(
|
||||
dummy_run=dummy_run,
|
||||
num_tokens=int(input_batch.num_tokens_after_padding),
|
||||
)
|
||||
if _FAULT is not None and ple_serving:
|
||||
ple_correlation = f"sequence:{ple_sequence}"
|
||||
ple_transaction = connector.fault_transaction(ple_sequence)
|
||||
if _FAULT is not None and _FAULT.fires(
|
||||
"exc_before_prepare",
|
||||
role="gpu",
|
||||
unit="runner-forward",
|
||||
eligible=ple_serving,
|
||||
tp_rank=connector.tp_rank,
|
||||
pp_rank=connector.pp_rank,
|
||||
dp_rank=connector.dp_rank,
|
||||
transaction_id=ple_transaction,
|
||||
correlation_id=ple_correlation,
|
||||
):
|
||||
raise RuntimeError("PLE test fault: exc_before_prepare")
|
||||
self._prepare_ple_forward(
|
||||
input_batch,
|
||||
batch_desc,
|
||||
dummy_run,
|
||||
serving=ple_serving,
|
||||
transaction_id=ple_transaction,
|
||||
correlation_id=ple_correlation,
|
||||
)
|
||||
if _FAULT is not None and _FAULT.fires(
|
||||
"exc_after_prepare",
|
||||
role="gpu",
|
||||
unit="runner-forward",
|
||||
eligible=ple_serving,
|
||||
tp_rank=connector.tp_rank,
|
||||
pp_rank=connector.pp_rank,
|
||||
dp_rank=connector.dp_rank,
|
||||
transaction_id=ple_transaction,
|
||||
correlation_id=ple_correlation,
|
||||
):
|
||||
raise RuntimeError("PLE test fault: exc_after_prepare")
|
||||
connector_kwargs = dict(
|
||||
scheduler_output=scheduler_output,
|
||||
request_state_indices=input_batch.idx_mapping,
|
||||
@@ -2095,6 +2185,26 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
# Eager (NONE): call the raw model directly.
|
||||
model_output = self.model(**model_inputs)
|
||||
|
||||
# The model has consumed every PLE output, so the CPU worker may reuse
|
||||
# the registered buffers for the next request.
|
||||
if connector is not None:
|
||||
connector.release_outputs(
|
||||
serving=ple_serving,
|
||||
transaction_id=ple_transaction,
|
||||
correlation_id=ple_correlation,
|
||||
)
|
||||
if _FAULT is not None and _FAULT.fires(
|
||||
"exc_after_release",
|
||||
role="gpu",
|
||||
unit="runner-forward",
|
||||
eligible=ple_serving,
|
||||
tp_rank=connector.tp_rank,
|
||||
pp_rank=connector.pp_rank,
|
||||
dp_rank=connector.dp_rank,
|
||||
transaction_id=ple_transaction,
|
||||
correlation_id=ple_correlation,
|
||||
):
|
||||
raise RuntimeError("PLE test fault: exc_after_release")
|
||||
self.kv_connector.finish_forward()
|
||||
|
||||
if self.is_last_pp_rank:
|
||||
@@ -2123,6 +2233,9 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
finished_req_ids=finished_req_ids,
|
||||
ec_connector_output=ec_connector_output,
|
||||
cudagraph_stats=cudagraph_stats,
|
||||
ple_serving=ple_serving,
|
||||
ple_sequence=ple_sequence,
|
||||
ple_transaction=ple_transaction,
|
||||
)
|
||||
|
||||
if not self.is_last_pp_rank:
|
||||
@@ -2134,6 +2247,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
)
|
||||
return None
|
||||
|
||||
@fail_ple_execute_model
|
||||
@torch.inference_mode()
|
||||
@step_eplb_after()
|
||||
def sample_tokens(
|
||||
@@ -2152,6 +2266,9 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
finished_req_ids = self.execute_model_state.finished_req_ids
|
||||
ec_connector_output = self.execute_model_state.ec_connector_output
|
||||
cudagraph_stats = self.execute_model_state.cudagraph_stats
|
||||
ple_serving = self.execute_model_state.ple_serving
|
||||
ple_sequence = self.execute_model_state.ple_sequence
|
||||
ple_transaction = self.execute_model_state.ple_transaction
|
||||
self.execute_model_state = None
|
||||
|
||||
if not self.is_last_pp_rank:
|
||||
@@ -2161,6 +2278,26 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
if self.pcp_manager is not None:
|
||||
input_batch = self.pcp_manager.global_batch
|
||||
assert self.pp_handler is not None
|
||||
connector = self._ple_offload_connector
|
||||
if (
|
||||
connector is not None
|
||||
and _FAULT is not None
|
||||
and ple_serving
|
||||
and ple_sequence is not None
|
||||
and connector.completion_is_pending(ple_sequence)
|
||||
and _FAULT.fires(
|
||||
"exc_async_output",
|
||||
role="gpu",
|
||||
unit="runner-output-relay",
|
||||
eligible=True,
|
||||
tp_rank=connector.tp_rank,
|
||||
pp_rank=connector.pp_rank,
|
||||
dp_rank=connector.dp_rank,
|
||||
transaction_id=ple_transaction,
|
||||
correlation_id=f"sequence:{ple_sequence}",
|
||||
)
|
||||
):
|
||||
raise RuntimeError("PLE test fault: exc_async_output")
|
||||
all_decode_next = self.pp_handler.receive(input_batch)
|
||||
# Optimistically update num_computed_tokens for entire batch here.
|
||||
# Will be adjusted for rejections if necessary in update_requests.
|
||||
@@ -2462,6 +2599,9 @@ class ExecuteModelState(NamedTuple):
|
||||
finished_req_ids: set[str]
|
||||
ec_connector_output: ECConnectorOutput | None
|
||||
cudagraph_stats: CUDAGraphStat | None
|
||||
ple_serving: bool
|
||||
ple_sequence: int | None
|
||||
ple_transaction: str | None
|
||||
|
||||
|
||||
class BatchReqState(NamedTuple):
|
||||
|
||||
Reference in New Issue
Block a user