vllm.v1.kv_offload.tiering.p2p.session.server ¶
Server-role state machine for a single peer session.
Owns block matching (supply vs. demand), inflight RDMA transfers, store-job timeouts, abort-drain, and produces StoreResult for completed stores. The session coordinator parses wire messages and dispatches typed arguments here; this module never touches ControlConnection directly — it emits via the send callback injected by the coordinator (which gates on ConnectAck).
Protocol violations the role can detect (today: duplicate FetchMsg for the same kv_request_id) are surfaced as ValueError so the coordinator's _dispatch_message can reuse its existing _protocol_error path.
Classes:
-
ServerRole–Server-side store/serve state machine for one peer session.
-
StoreResult–Result from a session poll, server side.
ServerRole ¶
Server-side store/serve state machine for one peer session.
The coordinator owns the connection and the send-gating; this role is given a send callback, the DataTransport, and the peer_id for transport calls and log messages.
Methods:
-
add_stored_blocks–New blocks stored locally — match against pending fetch demand.
-
close–Tear down. Cancels inflight, returns failed store job ids.
-
collect_idle_timeouts–Run only the store-job timeout sweep.
-
collect_results–Drain timeouts, deferred results, and transport completions.
-
drain_pending_aborts–Re-attempt every parked abort once per poll tick.
-
finish–Mark an outbound request finishing.
-
on_abort_fetch–Handle an AbortFetchMsg from the peer.
-
on_fetch–Handle a FetchMsg from the peer.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
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 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
_drain_abort(kv_request_id) ¶
One drain attempt for a pending abort.
Stops accepting more blocks for kv_request_id, then asks the transport to cancel any matching inflight transfers in mode="wait". Sends AbortAckMsg once nothing remains inflight, or after _CANCEL_DRAIN_TIMEOUT_S falls back to mode="immediate" and acks anyway.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
_finalize_outbound(kv_request_id, success=None) ¶
Pop the outbound state and emit terminal results.
Called when no further work will happen for this kv_request_id on the server side: either request_finish has fired and there are no inflight transfers, or the last inflight just completed while finishing.
If success is None, derive it from req.remaining == 0. The same flag is used for both the peer's TransferDoneMsg and the StoreResult(s) emitted for any leftover pending job_ids.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
_inflight_add(tid, xfer) ¶
Insert an inflight transfer and bump the per-request count.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
_inflight_pop(tid) ¶
Pop an inflight transfer and decrement the per-request count.
Removes the per-request entry once the count hits zero so the dict stays bounded and _has_inflight_for remains exact.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.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/server.py
close() ¶
Tear down. Cancels inflight, returns failed store job ids.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
collect_idle_timeouts() ¶
Run only the store-job timeout sweep.
Used by the coordinator's no-conn poll path: a pending session cannot have inflight transfers (no peer registered yet), so we skip the transport poll and the deferred-result drain.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
collect_results() ¶
Drain timeouts, deferred results, and transport completions.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
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 | |
drain_pending_aborts() ¶
Re-attempt every parked abort once per poll tick.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
finish(kv_request_id) ¶
Mark an outbound request finishing.
No more submit_store calls will arrive for this id. Any blocks the peer demanded but we never stored will never come; tell the peer to stop waiting (TransferDoneMsg success=False) instead of letting it hit _LOAD_TIMEOUT_S.
If the decoder hasn't sent fetch yet (no demand received), defer — on_fetch will finalize once demand arrives.
If inflight transfers exist for this id, defer — the last completing transfer in collect_results will fire the message.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
on_abort_fetch(kv_request_id) ¶
Handle an AbortFetchMsg from the peer.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
on_fetch(kv_request_id, block_hashes, block_indexes) ¶
Handle a FetchMsg from the peer.
Raises ValueError on a duplicate fetch for the same kv_request_id; the coordinator's dispatch loop turns that into a protocol-error disconnect.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
StoreResult ¶
_InflightXfer ¶
Bases: NamedTuple
Metadata for a single inflight RDMA transfer, keyed by transfer_id.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
_MatchResult ¶
Bases: NamedTuple
Result of block matching: pairs ready for transfer.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
_OutboundRequestState dataclass ¶
Server-role state for a single peer fetch request.
The owning kv_request_id is the dict key in ServerRole._outbound and is not duplicated on the value.
Methods:
-
add_fetch_demand–Register the peer's fetch demand. Returns matched pairs.
-
add_stored_blocks–Add locally-stored blocks. Returns matched pairs.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
add_fetch_demand(block_hashes, block_indexes) ¶
Register the peer's fetch demand. Returns matched pairs.
Source code in vllm/v1/kv_offload/tiering/p2p/session/server.py
add_stored_blocks(block_hashes, block_ids, job_id) ¶
Add locally-stored blocks. Returns matched pairs.