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¶
- Register remote peer: add_remote_peer(peer_id, metadata, ...)
- Provides the remote memory layout so transfers can target it
- Submit: write_blocks(peer_id, local_idxs, remote_idxs) → int
- Returns a transfer_id (opaque int) for tracking
- Returns None if peer not registered or submission fails
- Poll: poll() → PollResult(done=[...], failed=[...])
- Returns transfer_ids that completed or failed since last poll
- Completed transfers are automatically cleaned up
- Cancel: cancel(transfer_ids, mode="immediate" | "wait")
- Best-effort cancellation of inflight transfers
- mode="wait" returns ids still in PROC/PEND so the caller can poll them to completion
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 threads. All I/O driven by poll().
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.
-
cancel–Cancel inflight transfers by their IDs.
-
close–Release all resources (registrations, handles, memory).
-
get_agent_metadata–Return opaque metadata needed by remote peers to connect.
-
poll–Poll all inflight transfers for completion.
-
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(int) –Base address of the local block memory region.
-
block_len(int) –Size of each block in bytes.
-
config_fingerprint(str) –Content-hash of the model configuration (hex string).
-
num_blocks(int) –Number of blocks in the local region.
Source code in vllm/v1/kv_offload/tiering/p2p/data/base.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
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).
Source code in vllm/v1/kv_offload/tiering/p2p/data/base.py
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": attempt to release each handle. If the release cannot complete because the transfer is still PROC/PEND, the entry 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 [].
Source code in vllm/v1/kv_offload/tiering/p2p/data/base.py
close() abstractmethod ¶
Release all resources (registrations, handles, memory).
Cancels any remaining inflight transfers. Idempotent. After close(), no other methods may be called.
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().
Source code in vllm/v1/kv_offload/tiering/p2p/data/base.py
poll() abstractmethod ¶
Poll all inflight transfers for completion.
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.
Source code in vllm/v1/kv_offload/tiering/p2p/data/base.py
remove_remote_peer(peer_id) abstractmethod ¶
Unregister a remote peer and release associated resources.
Inflight transfers to this peer should be cancelled first.
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.