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>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
"""IPC message definitions for PLE CPU offload (host-mapped pull design).
|
|
|
|
The offload process owns no CUDA context. Every GPU worker owns, per PLE
|
|
layer, a shared host output buffer and a shared host int32 flag, both
|
|
page-locked and device-mapped in the worker's context. The offload process
|
|
waits for ``flag == 0``, writes the layer result into the host buffer and
|
|
stores ``flag = 1`` with plain CPU stores; the GPU's captured forward waits on
|
|
the host flag, DMAs host -> GPU on the model stream, and ``release_outputs``
|
|
resets the flag after the forward.
|
|
"""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
import msgspec
|
|
import torch
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# IPC message dataclasses
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
@dataclass
|
|
class PleOffloadRegistration:
|
|
"""Sent once from each GPU worker during offload setup."""
|
|
|
|
worker_id: int
|
|
tp_rank: int
|
|
dp_rank: int
|
|
# Shared CPU tensors per PLE layer, filled by the offload process.
|
|
host_output_buffers: dict[str, torch.Tensor]
|
|
# Shared CPU int32 tensors per PLE layer; element 0 is the ready flag.
|
|
host_flag_tensors: dict[str, torch.Tensor]
|
|
# CPU tensors are allocated in shared memory and registered once.
|
|
input_ids_buf: torch.Tensor
|
|
query_start_loc_buf: torch.Tensor
|
|
ngram_context_buf: torch.Tensor | None
|
|
|
|
|
|
@dataclass
|
|
class PleOffloadRequest:
|
|
"""Sent by each DP rank's TP rank zero at every inference step."""
|
|
|
|
dp_rank: int
|
|
num_tokens: int
|
|
num_reqs: int
|
|
|
|
|
|
_PLE_OFFLOAD_REQUEST_DECODER = msgspec.msgpack.Decoder(PleOffloadRequest)
|