Skip to content

vllm.v1.engine.tensor_ipc

Tensor IPC transport via torch.multiprocessing.Queue.

This module contains the queue-based transport logic for sharing tensors between processes (e.g., API server -> engine core). The msgpack layer emits/consumes lightweight TensorIpcData values, while transport state such as request association, handle generation, queue routing, buffering, and cleanup lives here.

Classes:

  • TensorIpcData –

    Data sent via torch.multiprocessing.Queue for zero-copy IPC.

  • TensorIpcReceiver –

    Receive-side logic for tensor IPC via torch.multiprocessing.Queue.

  • TensorIpcSender –

    Send-side logic for tensor IPC via torch.multiprocessing.Queue.

TensorIpcData dataclass

Data sent via torch.multiprocessing.Queue for zero-copy IPC.

Contains the tensor_id and the actual tensor. The tensor is shared in memory (GPU or CPU) for efficient inter-process communication.

TensorIpcReceiver

Receive-side logic for tensor IPC via torch.multiprocessing.Queue.

Wraps the queue receive logic previously embedded in MsgpackDecoder.

Methods:

  • __call__ –

    Retrieve a tensor from torch.multiprocessing.Queue.

__call__(dtype, shape, meta)

Retrieve a tensor from torch.multiprocessing.Queue.

Uses a drain-and-buffer pattern: drains all available tensors from the queue, buffering them, until the requested tensor is found. Works for CUDA and CPU.

TensorIpcSender

Bases: OOBTensorConsumer

Send-side logic for tensor IPC via torch.multiprocessing.Queue.

Uses a single queue targeting rank 0 (the only rank that consumes multimodal tensors during TP>1 / PP>1. Note: DP>1 not supported).

Methods:

  • __call__ –

    Send tensor via queue, return its handle. Returns None if failed.

__call__(tensor)

Send tensor via queue, return its handle. Returns None if failed.