vllm.v1.kv_offload.tiering.p2p.session ¶
Modules:
-
client–Client-role state machine for a single peer session.
-
protocol–P2P KV cache sharing protocol constants and documentation.
-
server–Server-role state machine for a single peer session.
-
session–P2PSession — bidirectional session combining client + server roles.
Classes:
-
LoadResult–Result from a session poll, client side.
-
P2PSession–Bidirectional session — coordinator over ClientRole + ServerRole.
-
SessionCloseResult–Result of tearing down a P2PSession.
-
SessionPollResult–Result of one P2PSession.poll() tick.
-
StoreResult–Result from a session poll, server side.
LoadResult ¶
P2PSession ¶
Bidirectional session — coordinator over ClientRole + ServerRole.
Lifecycle
- Constructor with conn=None ⇒ pending. Accepts add_stored_blocks but cannot send (used by the prefiller to buffer blocks before the decoder connects).
- Constructor with conn != None ⇒ connected. Sends our own ConnectMsg immediately; the peer's ConnectMsg arrives in poll() and is dispatched to _on_connect (which calls transport.add_remote_peer and replies with ConnectAckMsg). Outgoing sends are queued until ConnectAckMsg confirms our metadata reached the peer.
- attach_connection(conn) on a pending session ⇒ same as above, starting from pending.
Methods:
-
add_stored_blocks–New blocks stored locally — match against pending fetch demand.
-
attach_connection–Attach a connection to a pending session and announce ourselves.
-
close–Shut down.
-
finish_request–Called when the request is finishing locally.
-
flush_pending_lookups–Flush any aggregated symmetric-P2P lookups for this peer.
-
poll–Process incoming messages, drive transfers, apply timeouts.
-
register_lookup–Register or resolve one (kv_request_id, key) probe.
-
request_blocks–Send fetch to the peer.
-
serve_external_requests–Resolve inbound peer lookups against the tiering manager.
Attributes:
-
has_pending_work(bool) –True while inbound loads or outbound transfers are outstanding.
-
ready(bool) –True after the peer acked our ConnectMsg (we may send freely).
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
has_pending_work property ¶
True while inbound loads or outbound transfers are outstanding.
ready property ¶
True after the peer acked our ConnectMsg (we may send freely).
_protocol_error(reason) ¶
Log a protocol violation and disconnect.
Best-effort sends DisconnectMsg so the peer learns why we're going away, then marks the connection dead. The manager reaps the session on the next poll via alive.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
_send_connect() ¶
Send our ConnectMsg announcing local NIXL metadata.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
add_stored_blocks(kv_request_id, keys, block_ids, job_id) ¶
New blocks stored locally — match against pending fetch demand.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
attach_connection(conn) ¶
Attach a connection to a pending session and announce ourselves.
Symmetric: every side advertises its NIXL metadata on connect, so whichever peer receives a session first can register the other.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
close() ¶
Shut down.
failed_jobs: client load job_ids to fail. failed_req_ids: client kv_request_ids to fail — in-flight loads plus requests with an unresolved symmetric-P2P probe toward the now-dead peer. The manager fails these so the consumer's lookup() falls back to local prefill instead of deferring forever on an answer that can never arrive. failed_stores: server store job_ids to fail. failed_serves: synthetic lookup ctxs still owing parent.on_request_finished (the manager flushes these on its next serve_external_requests).
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
finish_request(kv_request_id) ¶
Called when the request is finishing locally.
Finishes the client role (aborts any inbound load and drops any pending symmetric-P2P lookup state) and finalizes any outbound serving (server role) for this id. Roles that aren't active for this id are silent no-ops.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
flush_pending_lookups() ¶
Flush any aggregated symmetric-P2P lookups for this peer.
Called once per scheduler step from the manager's on_schedule_end(). Send-gating is handled inside the client's _send callback (queues until ConnectAckMsg).
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
poll() ¶
Process incoming messages, drive transfers, apply timeouts.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
register_lookup(kv_request_id, key) ¶
Register or resolve one (kv_request_id, key) probe.
Called from the manager's lookup() for symmetric-P2P consumers (remote_kv_source sub-dict in kv_transfer_params). See ClientRole.register_lookup for the state-machine contract.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
request_blocks(job_id, kv_request_id, keys, block_ids) ¶
Send fetch to the peer.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
serve_external_requests(parent) ¶
Resolve inbound peer lookups against the tiering manager.
Delegates to the server role; the parent handle is valid only for the duration of this call.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
SessionCloseResult ¶
Bases: NamedTuple
Result of tearing down a P2PSession.
failed_jobs/failed_stores are the in-flight jobs (client loads / server stores) the manager must mark failed. failed_req_ids is every client-side kv_request_id whose lookup() must fail (in-flight loads plus unresolved probes); failed_serves is the server-side lookup state the dead peer can no longer resolve.
Source code in vllm/v1/kv_offload/tiering/p2p/session/session.py
SessionPollResult ¶
Bases: NamedTuple
Result of one P2PSession.poll() tick.
loads/stores are the same per-role results the manager has always consumed. new_fetch_ids reports kv_request_ids whose FetchMsg arrived this tick — the manager uses them to bind kv_request_id → session and replay any submit_store batches parked while no peer had asked yet. Reporting (rather than calling back into the manager mid-dispatch) keeps the dependency strictly top-down.