vllm.v1.kv_cache_interface
¶
Classes:
-
AttentionSpec– -
ChunkedLocalAttentionSpec– -
CircularBufferSpec–One block per request holding the raw keys of the token group that
-
CrossAttentionSpec–KV cache spec for cross-attention layers in encoder-decoder models.
-
FullAttentionSpec–When hybrid allocator is disabled and the model contains both full
-
HiSparseHotSpec–Ephemeral per-request HiSparse hot-cache allocation.
-
HiSparseResidentSpec–Reclaimable GPU-resident pages for host-backed HiSparse KV.
-
HiddenStateCacheSpec–Marker for hidden-state cache layers used by extract_hidden_states.
-
KVCacheConfig–The KV cache configuration of a model.
-
KVCacheGroupSpec–Represents a group of model layers that share the same KV cache block table.
-
KVCacheSpec–A base class for specifying the KV cache format of one layer.
-
KVCacheTensor–A class for specifying how the workers should initialize the KV cache.
-
KVQuantMode–KV cache quantization mode.
-
KpoolTailSpec–One-block circular scratch cache for a kpool indexer's raw tail.
-
MLAAttentionSpec– -
RSWASpec–KV cache spec for Reference Sliding Window Attention (R-SWA).
-
SinkFullAttentionSpec– -
SlidingWindowMLASpec–Sliding window attention with MLA cache format.
-
SlidingWindowSpec– -
UniformTypeKVCacheSpecs–A KV cache spec for multiple layers with the same type of attention. Here,
Functions:
-
compute_layer_kv_cache_shape_bytes–Return the 4D logical shape
(B, H, N, C)where C is in bytes. -
compute_layout_strides–Byte strides in logical
[L, B, H, N, C]axis order. -
create_kv_cache_views–View a flat int8 buffer as one 4D
[B, H, N, C]view per layer. -
get_kv_quant_mode–Map a
kv_cache_dtypestring to a :class:KVQuantMode. -
get_mamba_prefill_checkpoint_position–Return the reusable Mamba checkpoint boundary for a prefill.
-
group_kernel_blocks–View a kernel-block-granular layer cache with manager blocks as dim 0.
-
is_full_attention_spec–Whether a KV cache group spec is (or wraps) full attention.
-
is_mamba_prefill_checkpoint_valid–Whether a backend can export the checkpoint in this query.
-
iter_layer_specs–The per-layer specs a KV cache group spec covers.
-
kv_cache_uses_per_token_head_scales–Return True if kv_cache_dtype needs per-token-head scales.
-
replace_as–dataclasses.replace, but rebuilding spec as target_cls
AttentionSpec
dataclass
¶
Bases: KVCacheSpec
Attributes:
-
max_tp_shards(int | None) –Distinct shards this cache splits into across TP; TP ranks beyond this
-
num_head_slots(int | None) –H of the logical
[B, H, N, C]page when packing diverges from one -
real_page_size_bytes(int) –Alias of
unpadded_page_size_bytes -
state_content_bytes(int | None) –C in bytes when packed; None means dense K/V content.
-
state_content_size_bytes(int) –Bytes per (head slot, stored state) cell of the page.
-
tokens_per_state(int | Fraction) –Tokens covered by one stored state. Ints > 1 compress multiple tokens
Source code in vllm/v1/kv_cache_interface.py
max_tp_shards = None
class-attribute
instance-attribute
¶
Distinct shards this cache splits into across TP; TP ranks beyond this hold replicas. None: unknown, treated as not replicated.
num_head_slots = None
class-attribute
instance-attribute
¶
H of the logical [B, H, N, C] page when packing diverges from one
slot per KV head. None means one slot per KV head. Published by the backend.
real_page_size_bytes
property
¶
Alias of unpadded_page_size_bytes
TODO(lucas): follow up with TPU backend to see if we can remove this property.
state_content_bytes = None
class-attribute
instance-attribute
¶
C in bytes when packed; None means dense K/V content.
state_content_size_bytes
property
¶
Bytes per (head slot, stored state) cell of the page.
tokens_per_state = 1
class-attribute
instance-attribute
¶
Tokens covered by one stored state. Ints > 1 compress multiple tokens
into one state (DSv4 sparse MLA); fractions < 1 store multiple states per
token (Whisper block pooling: Fraction(1, block_pool_size)).
ChunkedLocalAttentionSpec
dataclass
¶
Bases: AttentionSpec
Methods:
-
max_admission_blocks_per_request–Per-request admission cap, in blocks.
Source code in vllm/v1/kv_cache_interface.py
max_admission_blocks_per_request(max_in_flight_tokens, max_model_len)
¶
Per-request admission cap, in blocks.
Single source of truth for both startup pool sizing
(max_memory_usage_bytes) and the runtime admission gate, so requests
admitted by startup can also be admitted at runtime.
max_in_flight_tokens is the max tokens scheduled but not yet settled
(one batch per concurrent step); see VllmConfig.max_in_flight_tokens.
Source code in vllm/v1/kv_cache_interface.py
CircularBufferSpec
dataclass
¶
Bases: AttentionSpec
One block per request holding the raw keys of the token group that is still being compressed.
block_size is the ring capacity. It must exceed the compression ratio
by the speculative lookahead: a speculative step stores all of its rows,
drafts included, before acceptance is known, while the next step still
reads the open group's committed keys from the ring.
Source code in vllm/v1/kv_cache_interface.py
CrossAttentionSpec
dataclass
¶
Bases: AttentionSpec
KV cache spec for cross-attention layers in encoder-decoder models.
Source code in vllm/v1/kv_cache_interface.py
FullAttentionSpec
dataclass
¶
Bases: AttentionSpec
When hybrid allocator is disabled and the model contains both full attention layers and sliding window attention layers, sliding window attention are regarded as full attention in KV cache manager (blocks are allocated for all tokens), while computed as sliding window attention in model runner. In this case, we use FullAttentionSpec and record the sliding window size.
Methods:
-
merge–Merge a list of FullAttentionSpec objects into a single
Attributes:
-
non_causal(bool) –Whether the layer attends non-causally (e.g. Prefix LM). Carried on the
-
sliding_window(int | None) –Default to None for not using sliding window attention.
Source code in vllm/v1/kv_cache_interface.py
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 | |
non_causal = False
class-attribute
instance-attribute
¶
Whether the layer attends non-causally (e.g. Prefix LM). Carried on the spec so the engine core, which collects specs from all workers before the scheduler is built, can adjust scheduling policy (chunked prefill / prefix caching) regardless of tensor-parallel layout. It does not affect the KV cache layout itself.
sliding_window = None
class-attribute
instance-attribute
¶
Default to None for not using sliding window attention.
merge(specs)
classmethod
¶
Merge a list of FullAttentionSpec objects into a single FullAttentionSpec object.
Source code in vllm/v1/kv_cache_interface.py
HiSparseHotSpec
dataclass
¶
Bases: KVCacheSpec
Ephemeral per-request HiSparse hot-cache allocation.
Source code in vllm/v1/kv_cache_interface.py
HiSparseResidentSpec
dataclass
¶
Bases: KVCacheSpec
Reclaimable GPU-resident pages for host-backed HiSparse KV.
Source code in vllm/v1/kv_cache_interface.py
HiddenStateCacheSpec
dataclass
¶
Bases: MLAAttentionSpec
Marker for hidden-state cache layers used by extract_hidden_states.
Source code in vllm/v1/kv_cache_interface.py
KVCacheConfig
dataclass
¶
The KV cache configuration of a model.
Methods:
-
num_blocks_of–Number of blocks addressable by the pool backing
tensor. -
select_transfer_block_ids–Select block IDs for externally transferable cache groups.
Attributes:
-
has_mixed_precision_kv_cache(bool) –Whether device attention caches use more than one precision.
-
hisparse_host_block_stride(int | None) –Physical bytes between consecutive HiSparse host blocks.
-
hisparse_host_num_blocks(int | None) –Capacity of the dedicated HiSparse host-block manager, when enabled.
-
hisparse_shared_host_pool(bool) –Whether local TP ranks share one physical HiSparse host pool.
-
kv_cache_groups(list[KVCacheGroupSpec]) –The kv cache groups of the model.
-
kv_cache_layout(str | None) –The KV cache layout resolved by the engine core, adopted by all workers.
-
kv_cache_tensors(list[KVCacheTensor]) –How should model runner initialize the KV cache tensors for each layer
-
kv_tp_replicas(int) –Consecutive TP ranks holding identical KV for every layer (1: none).
-
needs_kv_cache_zeroing(bool) –Whether newly allocated KV cache blocks must be zeroed before use.
-
num_blocks(int) –The number of KV cache blocks
-
prefix_cache_retention_interval(int | None) –Resolved retention policy for local prefix-cache checkpoints.
-
prefix_cacheable_group_ids(tuple[int, ...]) –IDs of transferable groups eligible for hash-addressed stores.
-
prefix_cacheable_groups(tuple[KVCacheGroupSpec, ...]) –Transferable groups eligible for hash-addressed stores.
-
transfer_group_ids(tuple[int, ...]) –IDs of cache groups that participate in external KV transfer.
-
transfer_group_index_by_layer(dict[str, int]) –Transfer-group tuple index for each participating layer.
-
transfer_groups(tuple[KVCacheGroupSpec, ...]) –Cache groups that participate in external KV transfer.
Source code in vllm/v1/kv_cache_interface.py
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 | |
has_mixed_precision_kv_cache
property
¶
Whether device attention caches use more than one precision.
hisparse_host_block_stride = None
class-attribute
instance-attribute
¶
Physical bytes between consecutive HiSparse host blocks.
hisparse_host_num_blocks = None
class-attribute
instance-attribute
¶
Capacity of the dedicated HiSparse host-block manager, when enabled.
hisparse_shared_host_pool = False
class-attribute
instance-attribute
¶
Whether local TP ranks share one physical HiSparse host pool.
kv_cache_groups
instance-attribute
¶
The kv cache groups of the model.
For models with only one type of attention, there is only one group that
contains all layers.
For models with multiple types of attention, there will be multiple groups,
see _get_kv_cache_config_uniform_page_size for more details.
kv_cache_layout = None
class-attribute
instance-attribute
¶
The KV cache layout resolved by the engine core, adopted by all workers.
kv_cache_tensors
instance-attribute
¶
How should model runner initialize the KV cache tensors for each layer
kv_tp_replicas = 1
class-attribute
instance-attribute
¶
Consecutive TP ranks holding identical KV for every layer (1: none).
needs_kv_cache_zeroing
property
¶
Whether newly allocated KV cache blocks must be zeroed before use.
Required for Mamba layers, whose state is read before it is fully written (#35219), and for mixed-precision caches, where a block reused across groups can be reinterpreted under a different precision and decode stale bytes to NaN/Inf. Uniform-precision caches skip zeroing.
num_blocks
instance-attribute
¶
The number of KV cache blocks
prefix_cache_retention_interval = None
class-attribute
instance-attribute
¶
Resolved retention policy for local prefix-cache checkpoints.
prefix_cacheable_group_ids
cached
property
¶
IDs of transferable groups eligible for hash-addressed stores.
prefix_cacheable_groups
cached
property
¶
Transferable groups eligible for hash-addressed stores.
transfer_group_ids
cached
property
¶
IDs of cache groups that participate in external KV transfer.
transfer_group_index_by_layer
cached
property
¶
Transfer-group tuple index for each participating layer.
transfer_groups
cached
property
¶
Cache groups that participate in external KV transfer.
num_blocks_of(tensor)
¶
Number of blocks addressable by the pool backing tensor.
Source code in vllm/v1/kv_cache_interface.py
select_transfer_block_ids(block_ids)
¶
Select block IDs for externally transferable cache groups.
Source code in vllm/v1/kv_cache_interface.py
KVCacheGroupSpec
dataclass
¶
Represents a group of model layers that share the same KV cache block table. These layers are regarded as one layer in the KV cache manager.
Source code in vllm/v1/kv_cache_interface.py
KVCacheSpec
dataclass
¶
A base class for specifying the KV cache format of one layer.
Methods:
-
copy_with_new_block_size–Create a new KVCacheSpec from self but replacing the block size.
-
is_uniform_with_collection–Whether this KVCacheSpec is uniform with all specs of all layers.
-
max_memory_usage_bytes–The maximum possible memory usage of this KV cache in bytes.
-
max_num_blocks_per_req–The number of block table entries needed per request, i.e. the row
-
merge–Merge a list of KVCacheSpec objects into a single KVCacheSpec object.
Attributes:
-
block_stride_alignment(int | None) –Required byte alignment between physical blocks, including packed layers.
-
dcp_sharded(bool) –Whether DCP shards this cache's token positions across ranks.
-
has_layer_views(bool) –Whether generic allocation creates per-layer cache views.
-
page_size_bytes(int) –The size of a page with
block_sizetokens in bytes. -
prefix_cacheable(bool) –Whether this spec's group participates in prefix caching.
-
prefix_replay_tokens(int) –DeepSeek-V4.1 only: bounded replay. Currently only for DSV41 SWA.
-
uses_slot_mapping(bool) –Whether the worker computes a per-token slot mapping for this spec.
Source code in vllm/v1/kv_cache_interface.py
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 | |
block_stride_alignment = field(default=None, kw_only=True)
class-attribute
instance-attribute
¶
Required byte alignment between physical blocks, including packed layers.
dcp_sharded = field(default=False, kw_only=True)
class-attribute
instance-attribute
¶
Whether DCP shards this cache's token positions across ranks.
has_layer_views
property
¶
Whether generic allocation creates per-layer cache views.
Specs without a per-layer shape keep the raw backing tensor and lay it out themselves. They also have no attention module of their own, so they take no part in attention-backend or kernel-block selection.
page_size_bytes
property
¶
prefix_cacheable
property
¶
Whether this spec's group participates in prefix caching.
prefix_replay_tokens
property
¶
DeepSeek-V4.1 only: bounded replay. Currently only for DSV41 SWA.
uses_slot_mapping
property
¶
Whether the worker computes a per-token slot mapping for this spec.
Specs that address their pages themselves (raw storage, ring buffers) take no slot mapping row.
copy_with_new_block_size(block_size)
¶
is_uniform_with_collection(kv_cache_specs)
¶
Whether this KVCacheSpec is uniform with all specs of all layers.
Source code in vllm/v1/kv_cache_interface.py
max_memory_usage_bytes(vllm_config)
¶
The maximum possible memory usage of this KV cache in bytes.
Returns:
-
int–The KV cache size in bytes
max_num_blocks_per_req(vllm_config, max_len)
¶
The number of block table entries needed per request, i.e. the row length of the worker-side block table for this cache group.
Parameters:
-
(vllm_config¶VllmConfig) –The vllm config.
-
(max_len¶int) –The maximum sequence length to size for, including the encoder length for encoder-decoder models.
Source code in vllm/v1/kv_cache_interface.py
merge(specs)
classmethod
¶
Merge a list of KVCacheSpec objects into a single KVCacheSpec object.
Source code in vllm/v1/kv_cache_interface.py
KVCacheTensor
dataclass
¶
A class for specifying how the workers should initialize the KV cache.
Placement of a set of same-shaped layers in the KV cache allocation.
Layer layers[l]'s page for block b starts at
offset + l * layer_stride + b * block_stride bytes into the backing
allocation of size bytes. Layer-outermost layouts give each layer a
contiguous region (layer_stride = page * num_blocks,
block_stride = page); block-outermost layouts make each block a
block of all layers' pages (layer_stride = page, block_stride =
the packed block). Tensors whose address ranges overlap
alias the same bytes: cache groups overlay each other, which is sound
because a block ID is owned by one group at a time.
Source code in vllm/v1/kv_cache_interface.py
KVQuantMode
¶
Bases: IntEnum
KV cache quantization mode.
Used by attention backends and kernels to dispatch quantization logic
without string matching on kv_cache_dtype.
Attributes:
-
is_nvfp4(bool) –True for NVFP4 packed quantization mode.
-
is_per_token_head(bool) –True for any per-token-head quantization mode.
-
is_turboquant(bool) –True for any turboquant quantization mode.
Source code in vllm/v1/kv_cache_interface.py
KpoolTailSpec
dataclass
¶
Bases: SlidingWindowSpec
One-block circular scratch cache for a kpool indexer's raw tail.
Source code in vllm/v1/kv_cache_interface.py
MLAAttentionSpec
dataclass
¶
Bases: FullAttentionSpec
Attributes:
-
storage_block_size(int | None) –Token width used to view storage when it differs from the kernel block.
Source code in vllm/v1/kv_cache_interface.py
storage_block_size = None
class-attribute
instance-attribute
¶
Token width used to view storage when it differs from the kernel block.
RSWASpec
dataclass
¶
Bases: FullAttentionSpec
KV cache spec for Reference Sliding Window Attention (R-SWA).
Prefill (image + text prompt) tokens are always globally visible.
Only the last rswa_window generated tokens are kept in the KV cache;
gap blocks (between the prefill tail and the current decode window) are
evicted during each decode step to bound memory at
O(prefix_blocks + window_blocks).
Source code in vllm/v1/kv_cache_interface.py
SinkFullAttentionSpec
dataclass
¶
Bases: FullAttentionSpec
Methods:
-
merge–Merge a list of FullAttentionSpec objects into a single
Source code in vllm/v1/kv_cache_interface.py
merge(specs)
classmethod
¶
Merge a list of FullAttentionSpec objects into a single FullAttentionSpec object.
Source code in vllm/v1/kv_cache_interface.py
SlidingWindowMLASpec
dataclass
¶
Bases: SlidingWindowSpec
Sliding window attention with MLA cache format.
Source code in vllm/v1/kv_cache_interface.py
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | |
SlidingWindowSpec
dataclass
¶
Bases: AttentionSpec
Methods:
-
max_admission_blocks_per_request–Per-request admission cap, in blocks.
Source code in vllm/v1/kv_cache_interface.py
max_admission_blocks_per_request(max_in_flight_tokens, max_model_len)
¶
Per-request admission cap, in blocks.
Single source of truth for both startup pool sizing
(max_memory_usage_bytes) and the runtime admission gate. Per-request
real-held blocks plateau at this bound because
SlidingWindowManager.remove_skipped_blocks runs from allocate_slots
before each chunk's get_num_blocks_to_allocate.
max_in_flight_tokens is the max tokens scheduled but not yet settled
(one batch per concurrent step); see VllmConfig.max_in_flight_tokens.
Source code in vllm/v1/kv_cache_interface.py
UniformTypeKVCacheSpecs
dataclass
¶
Bases: KVCacheSpec
A KV cache spec for multiple layers with the same type of attention. Here, same types means always need the same number of token slots. For example, sliding window attentions with different window sizes are not the same type and should not be merged into one UniformTypeKVCacheSpecs.
Methods:
-
from_specs–Return a SameTypeKVCacheSpecs object if all layers have the same type
-
get_max_layers_per_page_size–Max number of layers sharing a page size. For a balanced bucket
-
is_uniform_type–Whether all layers have the same type of KV cache spec.
Attributes:
-
first_spec(KVCacheSpec) –Return the first spec in the group.
Source code in vllm/v1/kv_cache_interface.py
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 | |
first_spec
property
¶
Return the first spec in the group.
from_specs(kv_cache_specs)
classmethod
¶
Return a SameTypeKVCacheSpecs object if all layers have the same type of KV cache spec. Return None if not.
Source code in vllm/v1/kv_cache_interface.py
get_max_layers_per_page_size()
¶
Max number of layers sharing a page size. For a balanced bucket this equals the number of repetitions of the layer pattern.
Source code in vllm/v1/kv_cache_interface.py
is_uniform_type(kv_cache_specs)
classmethod
¶
Whether all layers have the same type of KV cache spec.
Uses the registry to determine grouping base classes, so custom specs that inherit from FullAttentionSpec are treated as full attention.
Source code in vllm/v1/kv_cache_interface.py
compute_layer_kv_cache_shape_bytes(spec, num_blocks, kernel_block_size=None)
¶
Return the 4D logical shape (B, H, N, C) where C is in bytes.
Source code in vllm/v1/kv_cache_interface.py
compute_layout_strides(spec, num_blocks, num_layers, layout, kernel_block_size=None, fixed_strides=(None,) * 5)
¶
Byte strides in logical [L, B, H, N, C] axis order.
Source code in vllm/v1/kv_cache_interface.py
create_kv_cache_views(raw, spec, num_blocks, layout, kv_cache_tensor, kernel_block_size=None)
¶
View a flat int8 buffer as one 4D [B, H, N, C] view per layer.
Block b of layer l starts at the tensor offset plus its layer and
block stride contributions.
Source code in vllm/v1/kv_cache_interface.py
get_kv_quant_mode(kv_cache_dtype)
¶
Map a kv_cache_dtype string to a :class:KVQuantMode.
Source code in vllm/v1/kv_cache_interface.py
get_mamba_prefill_checkpoint_position(num_tokens, hash_block_size, drop_eagle_block)
¶
Return the reusable Mamba checkpoint boundary for a prefill.
Source code in vllm/v1/kv_cache_interface.py
group_kernel_blocks(cache, num_blocks)
¶
View a kernel-block-granular layer cache with manager blocks as dim 0.
Kernel block splitting subdivides each manager block into uniformly strided
kernel blocks, so grouping is a pure view: (num_blocks * ratio, ...)
Source code in vllm/v1/kv_cache_interface.py
is_full_attention_spec(kv_cache_spec)
¶
Whether a KV cache group spec is (or wraps) full attention.
UniformTypeKVCacheSpecs is not itself a FullAttentionSpec, so a bare
isinstance check misses groups that carry the wrapper -- DeepSeek-V4's MLA
layers, or any model taking the UniformTypeKVCacheSpecs.from_specs path.
Every layer must be full attention: a group holding a recycling (sliding-window) layer has no stable slot layout, so callers that key data by slot cannot use it.
Source code in vllm/v1/kv_cache_interface.py
is_mamba_prefill_checkpoint_valid(query_start, query_end, checkpoint_position, hash_block_size, mamba_block_size, checkpoint_alignment)
¶
Whether a backend can export the checkpoint in this query.
Source code in vllm/v1/kv_cache_interface.py
iter_layer_specs(kv_cache_spec)
¶
The per-layer specs a KV cache group spec covers.
UniformTypeKVCacheSpecs groups keep one spec per layer; every other
spec describes its group on its own. Returns the layer specs either way so
callers do not have to special-case the wrapper.
Source code in vllm/v1/kv_cache_interface.py
kv_cache_uses_per_token_head_scales(kv_cache_dtype)
¶
Return True if kv_cache_dtype needs per-token-head scales.
replace_as(spec, target_cls, *, drop=(), **changes)
¶
dataclasses.replace, but rebuilding spec as target_cls
e.g. SlidingWindowSpec -> FullAttentionSpec
Every field of spec must exist on target_cls unless named in drop; fields only target_cls has keep their default values.