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. For complete
chunks, OffloadingEventsTracker builds BlockStored from the
originating request data carried by the raw event. A store may describe multiple
blocks, and removals still expand to those block hashes using captured
metadata. Partial tails also use captured metadata. 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–Builds complete stores from request context and expands removals.
Functions:
-
describes_group–Whether the tracker builds self-describing payloads for this group.
OffloadingEventsTracker
¶
Builds complete stores from request context and expands removals.
The store trigger handlers call record_store and the scheduler calls
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 reset.
Methods:
-
on_new_request–Retain only the request fields needed for complete-chunk stores.
-
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.
_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 _as_state_checkpoint).
_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.
on_new_request(req_context, request, group_configs)
¶
Retain only the request fields needed for complete-chunk stores.
record_lookup(req, group_config, chunk_idx, offload_key)
¶
Snapshot metadata for a ready or write-pending primary-tier hit.
record_partial_lookup(req, group_config, boundary_tokens, offload_key)
¶
Backfill metadata for a partial recurrent tail lookup hit.
record_partial_store(req, group_config, boundary_tokens, offload_key)
¶
Snapshot metadata for a newly stored partial recurrent tail.
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.
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
OffloadingEventstream.
_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).
_RequestEventContext
dataclass
¶
Request data used to describe complete offloaded chunks.
_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.
describes_group(group_config)
¶
Whether the tracker builds self-describing payloads for this group.
Full-attention groups and recurrent state groups (MambaManager) do;
windowed attention groups (sliding window, chunked local) keep the legacy
placeholder because a window's hashes do not identify a reusable prefix.