vllm.v1.kv_offload.tiering.p2p.manager ¶
P2PSecondaryTierManager: Secondary tier for P2P KV cache sharing.
Owns transports and a single bidirectional P2PSession per remote peer.
Classes:
-
P2PDestInfo–Producer side: a remote fetches this request's blocks from us.
-
P2PSecondaryTierManager–Secondary tier for P2P KV cache sharing.
-
P2PSourceInfo–Consumer side: this request fetches from a remote (prefiller or peer).
P2PDestInfo dataclass ¶
Producer side: a remote fetches this request's blocks from us.
kv_request_id is None when the remote_decoder block is present but malformed (no id); the block's presence still marks the request as remote-decode, so submit_store must fail rather than store locally.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
P2PSecondaryTierManager ¶
Bases: SecondaryTierManager
Secondary tier for P2P KV cache sharing.
A single P2PSession per remote peer handles both client-role (loading blocks from the peer) and server-role (serving blocks to the peer) over the same control connection.
Single-threaded: every public method runs on the scheduler thread, and the engine drives polling via get_finished_jobs() once per step. has_pending_work() keeps the engine ticking so the control transport and existing sessions are polled even when no requests are scheduled.
Methods:
-
__init__–Initialize the P2P secondary tier manager.
-
drain_jobs–Block until every submitted load/store job has completed or failed.
-
on_new_request–Parse kv_transfer_params once and open the outbound session.
-
on_request_finished–Cancels pending loads and prunes session-scoped state.
-
serve_external_requests–Serve inbound peer lookups against the tiering manager.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
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 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
__init__(offloading_spec, primary_kv_view, tier_type='p2p', host=None, port=None, backends=None, num_threads=4, **kwargs) ¶
Initialize the P2P secondary tier manager.
All keyword arguments after primary_kv_view come from the secondary_tiers entry in kv_connector_extra_config. See docs/features/kv_offloading_usage.md for the user-facing configuration reference.
Parameters:
-
(offloading_spec¶OffloadingSpec) –Owning
OffloadingSpec(provides normalized model, parallel, and cache layout configuration). -
(primary_kv_view¶memoryview) –Memoryview over the CPU primary tier; the NIXL agent registers this region for RDMA transfers.
-
(tier_type¶str, default:'p2p') –Tier identifier (defaults to
"p2p"). -
(host¶str | None, default:None) –Address the ZMQ control socket binds to, used verbatim as both the bind address and the identity peers dial back (mirrors the NIXL connector's
VLLM_NIXL_SIDE_CHANNEL_HOST; no auto-detection). Defaults toVLLM_P2P_SIDE_CHANNEL_HOST(localhost) when not set; must be set to the node's routable IP for cross-host P2P so remote peers can reach the socket. -
(port¶int | None, default:None) –Base port for the ZMQ control socket. Must be reachable from peers. Defaults to
VLLM_P2P_SIDE_CHANNEL_PORT(5710) when not set. The bound port isbase + data_parallel_indexso each DP replica gets a distinct port (one socket per replica, like NIXL); for DP=1 the offset is 0. -
(backends¶list[str] | None, default:None) –NIXL transport backends (e.g.
["UCX"],["MOONCAKE"],["LIBFABRIC"]). Defaults to["UCX"]. When any non-UCX backend is requested, the NIXL agent is initialized withbackends=...; otherwise it falls back to a UCX-only agent withnum_threadsthreads. -
(num_threads¶int, default:4) –NIXL agent worker threads for the UCX-only branch. Ignored when
backendscontains a non-UCX entry. -
(**kwargs¶Any, default:{}) –Reserved for future tier-specific options.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
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 | |
_drain_inflight_for_shutdown() ¶
Best-effort drain of inflight transfers before closing _data.
Mirrors session._drain_abort but as a single bounded loop. Collects inflight transfer_ids from each session, repeatedly calls _data.cancel(..., mode="wait") and _data.poll() so handles can surface as done/failed, and falls back to mode="immediate" once _SHUTDOWN_DRAIN_TIMEOUT_S elapses so a wedged peer can't hang us.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_get_or_create_session(peer_id) ¶
Return the existing session for peer_id, or open one outbound.
Consumer-side helper for on_new_request: when remote_prefiller (PD) or remote_kv_source (symmetric P2P) is set, the consumer must reach the producer at peer_id. If we already have a session toward that peer (from a prior load or a peer-initiated inbound), reuse it; otherwise open an outbound ControlConnection and build a connected session.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_poll_once() ¶
One sweep of the polling work.
Drains the control transport, polls every session, accumulates their results into _finished_jobs, and reaps any dead sessions. Runs on the scheduler thread.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_reap_unbound_stores() ¶
Time out submit_store batches that no peer has ever fetched.
Walks _unbound_stores for entries whose oldest batch is older than _UNBOUND_STORE_TIMEOUT_S. Drops the kv_request_id, surfaces every batched job as failed, and adds the id to _failed_req_ids so a late inbound FetchMsg short-circuits to a clean rejection.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
drain_jobs() ¶
Block until every submitted load/store job has completed or failed.
Loops calling _poll_once() until no session has outstanding inbound loads or in-flight outbound stores. Mid-flight transfers are NOT cancelled — the caller (TieringOffloadingManager.reset_cache) needs the primary memoryview to be quiescent, not aborted. Results accumulate in _finished_jobs and are surfaced by the next get_finished_jobs() call.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
on_new_request(req_context) ¶
Parse kv_transfer_params once and open the outbound session.
Parses the P2P routing state onto req_context (cached for the later lookup/submit/finish calls). On the consumer side (remote_prefiller for PD or remote_kv_source for symmetric P2P), open a session toward the producer at remote_host:remote_port so submit_load can issue FetchMsg as soon as it fires. On the prefiller side, sessions are created when the consumer's inbound connection arrives in _accept_new_peers — submit_store no longer pre-creates anything.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
on_request_finished(req_context) ¶
Cancels pending loads and prunes session-scoped state.
Consumer side (remote_prefiller for PD or remote_kv_source for symmetric-P2P): looks up the session by peer_id because the producer's address is what addresses the client-role load to cancel; also drops any pending symmetric-P2P lookup state via session.finish_request. Prefiller side (remote_decoder set): looks up via kv_request_id because peer_id is no longer carried on store-time kv_transfer_params; if a session has bound the id, finish it. If no session has bound the id yet, this is a no-op: parked batches in _unbound_stores are left in place and cleaned up only by _reap_unbound_stores after _UNBOUND_STORE_TIMEOUT_S.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
serve_external_requests(parent) ¶
Serve inbound peer lookups against the tiering manager.
Called once per scheduler step (before this tier's on_schedule_end) with a parent handle valid only for the duration of the call — the sole window in which the P2P server role may query the tiering manager. First release bookkeeping for the failed serves left by a reaped session, then let every live session resolve its enqueued inbound LookupMsgs.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
P2PSourceInfo dataclass ¶
Consumer side: this request fetches from a remote (prefiller or peer).
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_UnboundStoreBatch dataclass ¶
A submit_store batch parked at the manager before any peer has fetched.
Indexed by kv_request_id only — the prefiller no longer learns the peer identity at store time. When a FetchMsg(kv_request_id) arrives on some session, the manager binds the kv_request_id to that session and replays every parked batch into ServerRole via session.add_stored_blocks.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_annotate_req_context(req_context) ¶
Parse kv_transfer_params once and cache the P2P routing state.
Called from on_new_request; later calls for the same request read the cached P2PSourceInfo/P2PDestInfo via get_state instead of re-parsing.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_parse_dest(kv_params) ¶
Parse the producer remote_decoder sub-dict into a P2PDestInfo, or None if the block is absent (not a remote-decode request).
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_parse_source(kv_params) ¶
Parse the consumer sub-dict (PD remote_prefiller or symmetric remote_kv_source) into a P2PSourceInfo, or None if absent/incomplete.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_peer_id_from_params(role_params) ¶
Build host:port peer_id from a role-scoped sub-dict, or None.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_remote_decoder_params(kv_params) ¶
Return the remote_decoder sub-dict, or None if absent.
Set on prefiller requests to name the remote decoder they serve; carries kv_request_id.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_remote_kv_source_params(kv_params) ¶
Return the remote_kv_source sub-dict, or None if absent.
Set on symmetric-P2P consumer requests to name the remote source they pull from; carries kv_request_id, remote_host, remote_port.
Source code in vllm/v1/kv_offload/tiering/p2p/manager.py
_remote_prefiller_params(kv_params) ¶
Return the remote_prefiller sub-dict, or None if absent.
Set on decoder requests to name the remote prefiller they pull from; carries kv_request_id, remote_host, remote_port.