Skip to content

vllm.v1.kv_offload.tiering.p2p.control.zmq

ZMQ-based transport layer for P2P KV cache sharing.

Provides ZmqConnection (per-peer messaging) and ZmqTransport (connection management). Message-content agnostic.

Classes:

  • ZmqConnection –

    Bidirectional message channel to a single remote peer.

  • ZmqTransport –

    ZMQ implementation of ControlTransport.

ZmqConnection

Bases: ControlConnection

Bidirectional message channel to a single remote peer.

Methods:

  • enqueue –

    Buffer an incoming message.

  • mark_dead –

    Mark connection as disconnected.

  • recv –

    Drain and return all buffered incoming messages.

  • send –

    Send a msgpack-encoded message to this peer.

Attributes:

  • monitor_socket (Socket) –

    Monitor socket for disconnect detection (used by ZmqTransport).

monitor_socket property

Monitor socket for disconnect detection (used by ZmqTransport).

enqueue(msg)

Buffer an incoming message.

mark_dead()

Mark connection as disconnected.

Only flips liveness: the sockets stay open until close() releases them, so the owner can still drain recv() before tearing down.

recv()

Drain and return all buffered incoming messages.

send(msg)

Send a msgpack-encoded message to this peer.

Never blocks: callers hold the tiering manager lock. Raises ConnectionError once _SNDHWM messages are queued for the peer, so the owning session marks the connection dead instead of stalling.

ZmqTransport

Bases: ControlTransport

ZMQ implementation of ControlTransport.

Manages a ROUTER socket for accepting connections and DEALER sockets for outbound connections. Message-content agnostic.

Methods:

  • connect –

    Open an outbound connection to a remote peer.

  • poll –

    Process all pending I/O. Returns newly accepted connections.

_check_monitors()

Non-blocking: check all monitor sockets for fatal events.

_open_connection(peer_id, direction='outbound')

Create a DEALER socket + monitor and register the connection.

_recv_router()

Non-blocking: receive all pending messages from ROUTER.

_sweep_dead_connections()

Unregister and release every connection that is no longer alive.

connect(peer_id)

Open an outbound connection to a remote peer.

A dead connection can still be registered: its owning session may mark it dead after this tick's sweep already ran, and poll() only unregisters it on the next pass. Retire such an entry instead of asserting, so a reconnect landing in that window succeeds. A live entry is still a genuine duplicate.

poll()

Process all pending I/O. Returns newly accepted connections.

  • Receives messages (buffered in each connection's inbox)
  • Creates connections for new inbound peers (connect msg in inbox)
  • Checks monitors for disconnections
  • Removes and closes dead connections