Skip to content

vllm.v1.kv_offload.tiering.p2p.data.base

Abstract base class for the P2P data-plane transport.

The data plane handles RDMA (or similar) block transfers between peers. It is independent of the control plane — the control plane establishes who can talk to whom, then the data plane moves blocks at wire speed.

Architecture

DataTransport (one per node)
    ├── owns the local KV block memory region
    ├── registers remote peers (add_remote_peer / remove_remote_peer)
    ├── submits block writes (write_blocks → transfer_id)
    ├── polls for completion (poll → done/failed IDs)
    └── cancels inflight transfers (cancel)

Memory model

The local node exposes a contiguous block region:

base_addr ──► ┌─────────────┐  block 0
              ├─────────────┤  block 1
              ├─────────────┤  ...
              └─────────────┘  block (num_blocks - 1)

Each block is block_len bytes.

Remote peers expose the same layout. write_blocks() copies local blocks to a remote peer's block region by index:

write_blocks("peer:1", local_idxs=[0, 3], remote_idxs=[5, 7])
→ writes local block 0 → remote block 5
          local block 3 → remote block 7

Transfer lifecycle

  1. Register remote peer: add_remote_peer(peer_id, metadata, ...)
  2. Provides the remote memory layout so transfers can target it
  3. Submit: write_blocks(peer_id, local_idxs, remote_idxs) → int
  4. Returns a transfer_id (opaque int) for tracking
  5. Returns None if peer not registered or submission fails
  6. Poll: poll() → PollResult(done=[...], failed=[...])
  7. Returns transfer_ids that completed or failed since last poll
  8. Completed transfers are automatically cleaned up
  9. Cancel: cancel(transfer_ids, mode="immediate" | "wait")
  10. Best-effort cancellation of inflight transfers
  11. mode="wait" returns ids still in PROC/PEND so the caller can poll them to completion

Failure model

The transport decides each failure's scope:

  • Transfer: write_blocks() returned None or poll() listed the id in failed. The caller fails that round; the peer recomputes.
  • Peer: the registration for a peer is unusable (one decisive error, such as any failed state check of an inflight transfer, or repeated transfer failures with no success between). poll(peer_id) reports the cause in PollResult.peer_fault until remove_remote_peer(). A transfer whose state check failed stays inflight unless the failure proves it can no longer write, so the peer's teardown is what bounds it.

remove_remote_peer() does not stop a transfer that is still running: the transport retires it instead. A retired transfer leaves every poll(), so a reconnected peer under the same id never sees it; poll_retired() reports it once it has stopped, and only then are its handle and the removed peer's registration released. The caller keeps the transfer's source pins until then, or until it gives up and calls force_release_retired().

The transport never recovers a peer itself. The session turns a peer fault into the same connection death as a missed heartbeat, so the manager's reap is the only teardown: DisconnectMsg makes the peer tear down too, and the next connection re-registers both sides.

write_blocks() and poll() report failures through their return values and must not raise for them.

Implementor contracts

  • write_blocks() must not block. The transfer runs asynchronously.
  • poll() must be called periodically. It drives completion checking.
  • transfer_ids are unique across the lifetime of the transport.
  • add_remote_peer() must be called before write_blocks() to that peer.
  • get_agent_metadata() returns opaque bytes that the remote peer needs to call add_remote_peer() (e.g., RDMA connection info).
  • config_fingerprint is a content hash of the model configuration. Peers with different fingerprints are incompatible and must not exchange blocks (validated during the control-plane handshake).
  • close() releases all resources (memory registrations, handles). After close(), no other methods may be called.

Threading model: no background Python threads. All I/O driven by poll(). More than one caller thread may drive a transport over its lifetime, but never concurrently -- callers serialize themselves (the tiering manager does so with its lock). Note that serialization alone is not obviously sufficient for a backend that binds state to the thread that created it; see NixlTransport.

Classes:

  • DataTransport –

    Abstract data-plane transport for RDMA-style block transfers.

  • PollResult –

    Result of polling inflight transfers.

DataTransport

Bases: ABC

Abstract data-plane transport for RDMA-style block transfers.

Owns the local KV block memory region and manages transfers to/from registered remote peers.

Construction

view: A 2D memoryview (num_blocks × block_len bytes) over the local KV cache block storage. config_fields: Dict of model config values used to compute the compatibility fingerprint. None → empty fingerprint (compatible with any peer).

Methods:

  • add_remote_peer –

    Register a remote peer for block transfers.

  • add_remote_peer_async –

    Register a remote peer without blocking the caller.

  • cancel –

    Cancel inflight transfers by their IDs.

  • close –

    Release all resources (registrations, handles, memory).

  • force_release_retired –

    Release retired transfers that have not stopped.

  • get_agent_metadata –

    Return opaque metadata needed by remote peers to connect.

  • poll –

    Poll inflight transfers for completion.

  • poll_retired –

    Release retired transfers that have stopped; return their ids.

  • remove_remote_peer –

    Unregister a remote peer and release associated resources.

  • write_blocks –

    Submit a WRITE transfer: local blocks → remote peer's blocks.

Attributes:

base_addr property

Base address of the local block memory region.

block_len property

Size of each block in bytes.

config_fingerprint property

Content-hash of the model configuration (hex string).

Peers must have matching fingerprints to exchange blocks. Empty string means no fingerprint (always compatible).

num_blocks property

Number of blocks in the local region.

add_remote_peer(peer_id, agent_metadata, base_addr, num_blocks, block_len) abstractmethod

Register a remote peer for block transfers.

Must be called before write_blocks() to this peer.

Parameters:

  • peer_id

    (str) –

    Unique identifier for the remote peer.

  • agent_metadata

    (bytes) –

    Opaque bytes from the peer's get_agent_metadata().

  • base_addr

    (int) –

    Base address of the peer's block memory region.

  • num_blocks

    (int) –

    Number of blocks in the peer's region.

  • block_len

    (int) –

    Size of each block (must match local block_len).

add_remote_peer_async(peer_id, agent_metadata, base_addr, num_blocks, block_len)

Register a remote peer without blocking the caller.

Registration is O(num_blocks) and can take seconds for a large secondary tier, so the session starts it here and sends ConnectAckMsg only once the returned future resolves. The acknowledgement is therefore the peer's guarantee that this side is ready to serve, and no write_blocks can arrive before it.

The default implementation runs add_remote_peer inline and returns an already-resolved future; transports whose registration is cheap need not override it.

Parameters:

  • peer_id

    (str) –

    Unique identifier for the remote peer.

  • agent_metadata

    (bytes) –

    Opaque bytes from the peer's get_agent_metadata().

  • base_addr

    (int) –

    Base address of the peer's block memory region.

  • num_blocks

    (int) –

    Number of blocks in the peer's region.

  • block_len

    (int) –

    Size of each block (must match local block_len).

Returns:

  • Future[None] –

    A future resolving to None on success. A failed future means

  • Future[None] –

    the peer must be rejected rather than acknowledged.

cancel(transfer_ids, mode='immediate') abstractmethod

Cancel inflight transfers by their IDs.

Best-effort: transfers that already completed are ignored.

Parameters:

  • transfer_ids

    (Iterable[int]) –

    IDs to cancel. Unknown IDs are ignored.

  • mode

    (CancelMode, default: 'immediate' ) –

    "immediate" (default): pop and release each handle and return []. Matches the legacy fire-and-forget behavior — the caller does not wait for the underlying transfer to drain. "wait": release only transfers that have stopped. A transfer still PROC/PEND (or whose release fails) stays in the inflight set and its id is included in the returned list. The caller is expected to keep calling poll() until every returned id surfaces in done/failed.

Returns:

  • list[int] –

    For mode="wait", the subset of transfer_ids still

  • list[int] –

    tracked as inflight after the cancel attempt. For

  • list[int] –

    mode="immediate", always [].

close() abstractmethod

Release all resources (registrations, handles, memory).

Cancels any remaining inflight transfers. Idempotent. After close(), no other methods may be called.

force_release_retired(transfer_ids)

Release retired transfers that have not stopped.

Unsafe while one may still be writing; for a bounded hold only.

get_agent_metadata() abstractmethod

Return opaque metadata needed by remote peers to connect.

The returned bytes are sent during the control-plane handshake and passed to the remote peer's add_remote_peer().

poll(peer_id=None) abstractmethod

Poll inflight transfers for completion.

Parameters:

  • peer_id

    (str | None, default: None ) –

    If given, only poll (and drain) transfers submitted for this peer_id — the value passed to write_blocks. This is required when a single transport is shared across multiple peer sessions: poll() pops completed handles, so an unscoped poll by one session would consume and discard the completions of its siblings, starving them. None polls every peer's transfers (used only for the shutdown drain).

Returns:

  • PollResult –

    PollResult with lists of completed and failed transfer_ids.

  • PollResult –

    Completed/failed transfers are removed from the inflight set.

Must be called periodically to drive progress checking.

poll_retired()

Release retired transfers that have stopped; return their ids.

Must be called periodically while any transfer is retired. The default transport retires nothing.

remove_remote_peer(peer_id) abstractmethod

Unregister a remote peer and release associated resources.

Transfers to this peer still inflight are retired, not released (see "Failure model"); the peer's registration is released once they have stopped.

write_blocks(peer_id, local_idxs, remote_idxs) abstractmethod

Submit a WRITE transfer: local blocks → remote peer's blocks.

Parameters:

  • peer_id

    (str) –

    Target peer (must be registered via add_remote_peer).

  • local_idxs

    (list[int]) –

    Indexes of local blocks to read from.

  • remote_idxs

    (list[int]) –

    Indexes of remote blocks to write to. Must be same length as local_idxs.

Returns:

  • int | None –

    A unique transfer_id (int) to track this transfer, or

  • int | None –

    None if the peer is not registered or submission failed.

PollResult

Bases: NamedTuple

Result of polling inflight transfers.

Attributes:

  • done (Sequence[int]) –

    Transfer IDs that completed successfully.

  • failed (Sequence[int]) –

    Transfer IDs that failed (error, timeout, etc.).

  • peer_fault (str | None) –

    Set only on a peer-scoped poll() once the transport has judged the peer unusable (see "Failure model"); a short human-readable cause. None while the peer is healthy.