vllm.distributed.kv_transfer.kv_connector.v1.offloading.events
¶
Self-describing KV cache events for the offloading connector.
The OffloadingManager identifies an offloaded chunk only by its OffloadKey,
so its raw events carry no token ids, parent hash, or block size.
:class:OffloadingEventsTracker snapshots each chunk's full BlockStored
payload while the Request is alive and publishes stores as block-granular
payloads: a chunk event may carry multiple constituent per-block hashes, and
evictions fan out to the same hashes. Chunks overlapping a non-chunk-aligned
shared prefix re-announce the shared hashes once per chunk; consumers are
expected to deduplicate (reference-count) repeated store/remove announcements
of the same hash. Opt-in via
kv_connector_extra_config["self_describing_kv_events"]; inert unless
KV cache events are enabled. See the PR description for the full design.
Recurrent (Mamba / linear-attention) state groups announce state checkpoints,
not token ranges: an offloaded chunk holds the recurrent state at the chunk's
last hash only. Their BlockStored therefore carries that single hash, its
parent, an empty token_ids and kv_cache_spec_kind "mamba". A
consumer aligns it by hash with the attention group's blocks, and a hybrid
prefix is reusable only up to a boundary where every group has a residency.
Windowed attention groups keep the legacy placeholder payload.
Classes:
-
OffloadingEventsTracker–Tracks offloaded chunks' KV event payloads from store to eviction.
Functions:
-
describes_group–Whether the tracker builds self-describing payloads for this group.
OffloadingEventsTracker
¶
Tracks offloaded chunks' KV event payloads from store to eviction.
The scheduler calls :meth:record_store from _build_store_jobs and
:meth:record_lookup for allocated primary-tier hits while the Request is
available. Unallocated and missing lookups add no state. Entries remain until
the final observed residency removal or :meth:reset.
Methods:
-
record_lookup–Snapshot metadata for a ready or write-pending primary-tier hit.
-
record_partial_lookup–Backfill metadata for a partial recurrent tail lookup hit.
-
record_partial_store–Snapshot metadata for a newly stored partial recurrent tail.
-
record_store–Snapshot the KV cache event payload for one offloaded chunk.
-
reset–Drop all tracked state; pending payloads are stale after a
-
take_events–Translate raw OffloadingEvents into self-describing KV events.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
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 | |
_build_event_metadata(req, group_config, chunk_idx)
¶
Build the payload snapshot for one offloaded chunk: its
constituent per-block hashes, the whole chunk's tokens, and the
per-block block_size. A recurrent group's chunk is reduced to
its state checkpoint (see :func:_as_state_checkpoint).
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
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 | |
_record_partial_tail(req, group_config, boundary_tokens, offload_key)
¶
Build metadata for the valid prefix of one physical cache block.
A partial recurrent tail ends on a hash boundary but before its physical cache block is full. The event describes only the valid hashes and tokens, not the unused remainder of that physical block.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
record_lookup(req, group_config, chunk_idx, offload_key)
¶
Snapshot metadata for a ready or write-pending primary-tier hit.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
record_partial_lookup(req, group_config, boundary_tokens, offload_key)
¶
Backfill metadata for a partial recurrent tail lookup hit.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
record_partial_store(req, group_config, boundary_tokens, offload_key)
¶
Snapshot metadata for a newly stored partial recurrent tail.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
record_store(req, group_config, chunk_idx, offload_key)
¶
Snapshot the KV cache event payload for one offloaded chunk.
No-op when self-describing event capture is disabled or for windowed attention groups, which keep the legacy placeholder payload.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
reset()
¶
Drop all tracked state; pending payloads are stale after a manager cache reset.
take_events(events)
¶
Translate raw OffloadingEvents into self-describing KV events.
Complete metadata is available for full-attention and recurrent state groups when the tracker is enabled. Windowed attention groups retain the legacy placeholder payload so consumers can ignore them.
Yields:
-
Iterable[KVCacheEvent]–BlockStoredorBlockRemovedevents corresponding to -
Iterable[KVCacheEvent]–the underlying :class:
OffloadingEventstream.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
_OffloadEventMetadata
¶
Bases: Struct
BlockStored payload snapshot for one OffloadKey, captured while the
Request is available and kept until the final matching removal event.
medium and ownership are forwarded from the OffloadingEvent.
One is kept per offloaded chunk, so it is untracked by the cyclic GC: keep
fields free of tracked containers (active_residencies is a bitmask).
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
_as_state_checkpoint(meta)
¶
Reduce a chunk payload to the recurrent state checkpoint it holds.
A recurrent group's offloaded chunk is one state, valid at the chunk's last hash. Announcing the whole hash range would let a consumer treat every hash in it as a resumable position, so the payload keeps only the last hash (the OffloadKey), chained to the hash before it, and no tokens: the consumer aligns it with the attention group's blocks by hash.
Source code in vllm/distributed/kv_transfer/kv_connector/v1/offloading/events.py
describes_group(group_config)
¶
Whether the tracker builds self-describing payloads for this group.
Full-attention groups and recurrent state groups (MambaSpec) do;
windowed attention groups (sliding window, chunked local) keep the legacy
placeholder because a window's hashes do not identify a reusable prefix.