vllm.v1.kv_offload.tiering.p2p.control ¶
Modules:
-
base–Abstract base classes for the P2P control-plane transport.
-
zmq–ZMQ-based transport layer for P2P KV cache sharing.
Classes:
-
ControlConnection–Bidirectional message channel to a single remote peer.
-
ControlTransport–Manages peer connections and drives all control-plane I/O.
-
ZmqConnection–Bidirectional message channel to a single remote peer.
-
ZmqTransport–ZMQ implementation of ControlTransport.
ControlConnection ¶
Bases: ABC
Bidirectional message channel to a single remote peer.
Lifecycle
- Created by ControlTransport (connect() or poll())
- Used for send/recv by sessions
- Marked dead on disconnect (mark_dead())
- Cleaned up with close()
Once mark_dead() is called, alive becomes False and the owning session should stop using this connection. close() releases underlying resources (sockets, monitors).
Methods:
-
close–Release all resources (sockets, monitors).
-
mark_dead–Mark this connection as dead (peer disconnected).
-
recv–Drain and return all messages received since the last call.
-
send–Enqueue a message for delivery to the peer.
Attributes:
Source code in vllm/v1/kv_offload/tiering/p2p/control/base.py
alive abstractmethod property ¶
True if the connection is usable. False after mark_dead/close.
close() abstractmethod ¶
Release all resources (sockets, monitors).
Idempotent. After close(), alive returns False.
mark_dead() abstractmethod ¶
Mark this connection as dead (peer disconnected).
After this call, alive returns False. The session should stop using this connection and the transport will clean it up.
Source code in vllm/v1/kv_offload/tiering/p2p/control/base.py
recv() abstractmethod ¶
Drain and return all messages received since the last call.
Returns an empty sequence if no messages are pending. The returned sequence is read-only — callers must not mutate it. Messages are dicts deserialized from the wire format.
Source code in vllm/v1/kv_offload/tiering/p2p/control/base.py
send(msg) abstractmethod ¶
Enqueue a message for delivery to the peer.
Must not block. Serialization happens internally. Raises on closed connection.
ControlTransport ¶
Bases: ABC
Manages peer connections and drives all control-plane I/O.
Owns the listening socket and all active connections. The caller must invoke poll() periodically to process I/O.
Lifecycle
- Constructed with a local identity and listen address
- connect() to reach remote peers
- poll() to accept inbound peers and process messages
- close() to shut down
Methods:
-
close–Shut down the transport and all connections.
-
connect–Create an outbound connection to a remote peer.
-
poll–Process all pending I/O and return newly accepted connections.
Source code in vllm/v1/kv_offload/tiering/p2p/control/base.py
close() abstractmethod ¶
Shut down the transport and all connections.
Closes the listening socket and all active connections. Idempotent.
connect(peer_id) abstractmethod ¶
Create an outbound connection to a remote peer.
Parameters:
Returns:
-
ControlConnection–A new ControlConnection ready for send/recv.
The connection's send queue is live immediately — messages sent before the remote peer's poll() will be buffered.
Source code in vllm/v1/kv_offload/tiering/p2p/control/base.py
poll() abstractmethod ¶
Process all pending I/O and return newly accepted connections.
This is the main I/O driver. Each call: - Receives messages from all connected peers (buffered in each connection's recv() queue) - Accepts new inbound peers and creates connections for them (first message already in recv() buffer) - Detects disconnections and marks connections dead
Returns:
-
Sequence[ControlConnection]–Newly accepted inbound connections (not previously returned).
-
Sequence[ControlConnection]–The returned sequence is read-only — callers must not mutate
-
Sequence[ControlConnection]–it. The caller is responsible for creating sessions for
-
Sequence[ControlConnection]–these connections.
Source code in vllm/v1/kv_offload/tiering/p2p/control/base.py
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).
Source code in vllm/v1/kv_offload/tiering/p2p/control/zmq.py
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.
Source code in vllm/v1/kv_offload/tiering/p2p/control/zmq.py
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 298 299 300 301 302 303 304 305 306 307 | |
_check_monitors() ¶
Non-blocking: check all monitor sockets for disconnection.
Source code in vllm/v1/kv_offload/tiering/p2p/control/zmq.py
_open_connection(peer_id, direction='outbound') ¶
Create a DEALER socket + monitor and register the connection.
Source code in vllm/v1/kv_offload/tiering/p2p/control/zmq.py
_recv_router() ¶
Non-blocking: receive all pending messages from ROUTER.
Source code in vllm/v1/kv_offload/tiering/p2p/control/zmq.py
connect(peer_id) ¶
Open an outbound connection to a remote peer.
Source code in vllm/v1/kv_offload/tiering/p2p/control/zmq.py
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