vllm.v1.kv_offload.tiering.p2p.data ¶
Modules:
-
base–Abstract base class for the P2P data-plane transport.
-
nixl–NixlTransport: Data-plane transport for RDMA-based KV block transfers via NIXL.
Classes:
-
DataTransport–Abstract data-plane transport for RDMA-style block transfers.
-
NixlTransport–Manages a NIXL agent, memory registration, and 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.
Source code in vllm/v1/kv_offload/tiering/p2p/data/base.py
NixlTransport ¶
Bases: DataTransport
Manages a NIXL agent, memory registration, and block transfers.
Wraps the NIXL C library behind a Python interface so the rest of the P2P tier code never touches NIXL types directly. Tracks inflight handles internally and returns completed/failed tags on poll.
Methods:
-
cancel–Cancel inflight transfers by their IDs.
-
poll–Poll all inflight transfers.
-
write_blocks–Submit a WRITE transfer to peer_id.
Source code in vllm/v1/kv_offload/tiering/p2p/data/nixl.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
cancel(transfer_ids, mode='immediate') ¶
Cancel inflight transfers by their IDs.
See DataTransport.cancel for the contract. In "wait" mode, transfers whose release_xfer_handle raises (NIXL could not complete the abort because the backend is still draining) stay in self._inflight so a later poll() will observe them.
Source code in vllm/v1/kv_offload/tiering/p2p/data/nixl.py
poll() ¶
Poll all inflight transfers.
Returns PollResult(done=..., failed=...) with transfer IDs. Completed handles are released automatically.
Source code in vllm/v1/kv_offload/tiering/p2p/data/nixl.py
write_blocks(peer_id, local_idxs, remote_idxs) ¶
Submit a WRITE transfer to peer_id.
Returns a transfer ID, or None if the peer is not registered. The ID is returned via poll() when the transfer completes or fails.