vllm.v1.core.kv_cache_planning
¶
KV cache planning: grouping, sizing, and memory-fit logic.
Classes:
-
DefaultKVCacheConfigBuilder–Default grouping and placement, backed by the module-level functions here.
Functions:
-
check_enough_kv_cache_memory–Checks whether
available_memoryis enough for the KV cache to hold at -
create_kv_cache_group_specs–Create KVCacheGroupSpec object for each kv cache group layer.
-
estimate_max_model_len–Estimates the maximum model length that can fit in the available memory
-
get_kv_cache_config_from_groups–Generate the KV cache configuration from the KV cache groups and spec
-
get_kv_cache_configs–Generates the KV cache configurations for a model.
-
get_kv_cache_groups–Split the layers in the model into groups with the same KV cache spec.
-
get_kv_cache_groups_from_builder–Group the layers with the builder and check the result.
-
get_uniform_page_size–Get the page size of the KV cache.
-
is_kv_cache_spec_uniform–Whether all layers in the given KVCacheSpec have the same KV cache spec.
-
kv_cache_groups_tp_replicas–Consecutive TP ranks holding identical KV for every layer.
-
max_memory_usage_bytes–Get the maximum memory usage in bytes for the given KV cache specs.
-
may_override_num_blocks–Override the number of kv cache blocks if
num_gpu_blocks_overrideis set. -
unify_hybrid_kv_cache_specs–This function tries to convert the KV cache specs to one type if the model
-
unify_kv_cache_spec_page_size–Unify the page size of the given KVCacheSpec. If the page size of all layers
-
validate_kv_cache_layout–Validate that the resolved layout can express this model's packing.
DefaultKVCacheConfigBuilder
¶
Bases: KVCacheConfigBuilder
Default grouping and placement, backed by the module-level functions here.
.. note::
This class is part of the experimental KVCacheConfigBuilder
interface and is subject to change.
Subclasses override only the hooks they need. The planning flow and its
invariants (num_gpu_blocks_override, null-block reservation, auto-fit,
admission checks, cross-rank convergence) stay in the Core-owned
:func:get_kv_cache_configs.
Methods:
-
get_kv_cache_config_from_groups–See
KVCacheConfigBuilder.get_kv_cache_config_from_groups. -
get_kv_cache_groups–See
KVCacheConfigBuilder.get_kv_cache_groups.
Source code in vllm/v1/core/kv_cache_planning.py
get_kv_cache_config_from_groups(vllm_config, kv_cache_groups, num_blocks)
¶
See KVCacheConfigBuilder.get_kv_cache_config_from_groups.
Source code in vllm/v1/core/kv_cache_planning.py
get_kv_cache_groups(vllm_config, kv_cache_spec)
¶
See KVCacheConfigBuilder.get_kv_cache_groups.
A model implementing SupportsKVCacheGrouping owns the grouping
decision; otherwise the default grouping is used.
Source code in vllm/v1/core/kv_cache_planning.py
_approximate_gcd(values, *, lower_bound=None)
¶
Pick a chunk size that minimizes total upward padding.
Each x is rounded up to a multiple of d:
x -> ceil(x / d) * d
Total padding is:
pad(d) = sum_i (ceil(x_i / d) * d - x_i)
We brute-force d in [lower_bound, max(values)] (fine for small lists / small maxima) and return the d with minimum padding. Ties prefer larger d.
Source code in vllm/v1/core/kv_cache_planning.py
_auto_fit_max_model_len(builder, vllm_config, projected_groups_per_worker, available_memory)
¶
When max_model_len is set to -1, this function estimates the largest context length that can be supported with the available GPU memory. It uses binary search to find the maximum length that fits across all workers.
Parameters:
-
(builder¶KVCacheConfigBuilder) –The builder whose hooks drive block accounting.
-
(vllm_config¶VllmConfig) –The global VllmConfig (will be modified in-place)
-
(projected_groups_per_worker¶list[list[KVCacheGroupSpec]]) –KV cache groups projected to each worker.
-
(available_memory¶list[int]) –Memory available for KV cache in bytes for each worker.
Source code in vllm/v1/core/kv_cache_planning.py
1456 1457 1458 1459 1460 1461 1462 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 | |
_check_exact_partition(groups, kv_cache_spec)
¶
Ensure the groups partition every input layer exactly once.
Source code in vllm/v1/core/kv_cache_planning.py
_ensure_min_page_size(groups, common_page, hidden_specs)
¶
Scale up group block sizes so the common page is at least as large as the biggest hidden-state per-token cost.
This protects the hidden state extraction feature, where we store hidden states in the KV cache, and return them to clients using a custom hidden state connector.
Returns the (possibly scaled) groups and updated common page size.
Source code in vllm/v1/core/kv_cache_planning.py
_estimate_max_model_len_from_groups(builder, vllm_config, kv_cache_groups, available_memory)
¶
Binary search for the maximum model length that fits in available memory. Returns 0 if even 1 token doesn't fit.
Source code in vllm/v1/core/kv_cache_planning.py
_get_kv_cache_bytes_per_block(kv_cache_groups, layout)
¶
Return the largest cache group's bytes per block.
Source code in vllm/v1/core/kv_cache_planning.py
_get_kv_cache_groups_uniform_page_size(kv_cache_spec)
¶
Generates the KV cache groups for hybrid models with multiple attention types but still with a uniform page size (physical memory per block per layer) for all layers.
Detailed explanation about kv cache management of hybrid models:
The layers in the models are repeated with some patterns, e.g., a model
with 10 full attention layers and 20 sliding window attention layers can be
regarded as repeating the pattern (1 * full, 2 * sw) 10 times.
The KVCacheManager allocates different block tables for each of the 3 layers
in the pattern, and repeats each of them 10 times to generate the
block_table for the 30 layers in the model.
Therefore, we can group the layers in the model into 3 kv_cache_groups, each
of which contains 10 layers in the model.
The KVCacheManager allocates the block_table for each group based on its
kv_cache spec, and the model runner applies the block table to each layer
in the group.
For example:
1. A model only uses full attention. The pattern is
(num_hidden_layers * full), so there is only one group and the block table
is shared by all layers. It is already handled by
_get_kv_cache_config_uniform_type.
2. A model with 10 full attention layers and 20 sliding window
attention layers. There are 3 layers in the pattern (1 * full, 2 * sw), so
there are 3 kv_cache_groups, each of which represents 10 layers.
To simplify the implementation, we make the following assumptions:
1. Physical memory per block: Must be the same across all KV cache groups.
Breaking this assumption is non-trivial due to memory fragmentation concerns
when allocating blocks of different sizes.
2. Tokens per block (block_size): Currently, we directly use
CacheConfig.block_size for all layers. It can be extended to vary by KV
cache group, but within each KV cache group, all layers must share the same
block size.
3. Physical memory per token per layer: This property is decided by model
config. Currently we only support models that have the same physical memory
per token per layer for all layers. Can be relaxed with a simple extension,
but still need to keep physical memory per block the same for all groups.
4. Number of layers per group: Currently assumed the same for all layers.
Can be relaxed with a simple extension, but still need to keep physical
memory per block the same for all groups.
5. Attention type within groups: All layers in a group must share the same
attention type. One exception is that, when
--disable-hybrid-kv-cache-manager is true, the single group for full
attention layers may also include attention layers using sliding window or
LLaMA 4 local attention. See unify_hybrid_kv_cache_specs for more details.
6. Support for multiple attention types: The design for most components is
general to an arbitrary number of attention types. But
find_longest_cache_hit only supports one attention type or two
types of full-attention plus exactly one another type. The general
implementation of this function is feasible but we don't know how to
implement it cleanly yet.
As we assume tokens per block, physical memory per token per layer, and number of layers per group are the same now, we can ensure that physical memory per block is the same for all groups.
Parameters:
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The KVCacheSpec of each attention layer in the model
Returns: The generated KVCacheGroupSpecs
Source code in vllm/v1/core/kv_cache_planning.py
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 | |
_get_kv_cache_groups_uniform_spec(kv_cache_specs)
¶
Generates the KV cache configuration for a model with the same KV cache spec for all layers.
Parameters:
-
(kv_cache_specs¶dict[str, KVCacheSpec]) –The kv cache spec of each attention layer in the model
Returns:
-
list[KVCacheGroupSpec]–The generated KVCacheGroupSpecs
Source code in vllm/v1/core/kv_cache_planning.py
_get_kv_cache_groups_uniform_type(spec)
¶
Generates the KV cache configuration for a model with one type of KV cache but different hidden sizes. All layers are merged into one group.
Parameters:
-
(spec¶UniformTypeKVCacheSpecs) –The UniformTypeKVCacheSpecs of the model
Returns:
-
list[KVCacheGroupSpec]–The generated KVCacheGroupSpecs
Source code in vllm/v1/core/kv_cache_planning.py
_get_layer_block_stride(spec)
¶
A layer-outer block stride: the page padded to its alignment.
_get_packed_kv_cache_groups(vllm_config, kv_cache_spec)
¶
Group mixed-page-size layers for contiguous block-outermost packing.
Greedily buckets layers into uniform-type specs. Buckets with equal layer
counts per page size are treated as a repeating layer pattern (one layer
per page size) and split into groups covering the same number of pattern
repeats (picked by _approximate_gcd to minimize padding), so all
groups pack into the same per-block layout. Mamba buckets are additionally
split to fit the block the attention buckets already need.
Returns None when the layout is not block-outermost or all layers already
share one page size.
Source code in vllm/v1/core/kv_cache_planning.py
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | |
_get_windowed_dspark_groups(kv_cache_spec)
¶
One group for the target, one per window for sliding-window DSpark drafts.
The non-windowed target layers must form one uniform-type group (e.g. a
sparse MLA target with its indexer caches). See
_get_windowed_dspark_kv_cache_tensors for the allocation.
Source code in vllm/v1/core/kv_cache_planning.py
_max_memory_usage_bytes_from_groups(builder, vllm_config, kv_cache_groups)
¶
Calculate maximum memory usage in bytes from KV cache groups.
This correctly accounts for padding in hybrid models. For example, if a model has 8 full attention layers and 9 sliding window layers, they will be padded to 9 full + 9 sliding window for uniform group sizes.
Each group independently claims blocks from the shared pool, so a request consumes
the sum of the per-group block counts, i.e. bytes_per_block * total_blocks.
Source code in vllm/v1/core/kv_cache_planning.py
_pool_bytes_per_block(vllm_config, kv_cache_groups)
¶
Bytes consumed by one block in the worker's shared KV cache pool, mirroring
the divisor used by get_kv_cache_config_from_groups to convert
available_memory into num_blocks. Used to compute the effective KV cache
capacity once num_gpu_blocks_override is applied.
Source code in vllm/v1/core/kv_cache_planning.py
_pool_bytes_per_block_from_builder(builder, vllm_config, kv_cache_groups)
¶
Bytes consumed by one block in the worker's device KV cache pool.
Core places one block with the builder and reads the size of its single
device backing. A placement with several device allocations declares the
value through KVCacheConfigBuilder._get_pool_bytes_per_block. HiSparse
keeps the pure computation, since probing its placement would check the host
pool against max_model_len before auto-fit shortens it.
num_gpu_blocks_override is suppressed so it cannot inflate the probe.
Source code in vllm/v1/core/kv_cache_planning.py
_project_kv_cache_groups_to_worker(global_kv_cache_groups, worker_spec)
¶
Projects global KV cache groups onto a single worker's assigned layers.
In pipeline parallelism, each worker only owns a subset of layers. This function filters the global groups to include only layers present on the given worker, adjusting UniformTypeKVCacheSpecs accordingly.
Parameters:
-
(global_kv_cache_groups¶list[KVCacheGroupSpec]) –The global KV cache groups for the whole model.
-
(worker_spec¶dict[str, KVCacheSpec]) –The KV cache spec of each layer on this worker.
Returns:
-
list[KVCacheGroupSpec]–The projected KV cache groups containing only this worker's layers.
Source code in vllm/v1/core/kv_cache_planning.py
_promote_local_kv_cache_specs(kv_cache_spec)
¶
Use full-attention allocation for local-attention cache specs.
The returned specs affect KV cache management only. Attention modules keep their original sliding-window or chunked-local compute behavior.
Source code in vllm/v1/core/kv_cache_planning.py
_try_get_full_allocation_fallback_groups(kv_cache_spec)
¶
Try a supported full-allocation fallback for local-attention layers.
Source code in vllm/v1/core/kv_cache_planning.py
_warn_if_unannotated_eagle_mamba(spec_config, kv_cache_groups)
¶
Warn when no KV cache group could be identified as the draft model's.
Parameters:
-
(spec_config¶SpeculativeConfig) –Config supplying the speculative method.
-
(kv_cache_groups¶list[KVCacheGroupSpec]) –Groups as they will be handed to consumers.
Source code in vllm/v1/core/kv_cache_planning.py
_windowed_dspark_allocations(kv_cache_groups)
¶
Give every target layer a contiguous cache; draft layers alias one with the same page size, else get their own.
Draft and target groups have separate block tables over one block pool, so their live pages never overlap. Contiguous per-layer caches keep the sparse MLA indexer's flat row view valid.
Source code in vllm/v1/core/kv_cache_planning.py
check_enough_kv_cache_memory(vllm_config, kv_cache_spec, available_memory)
¶
Checks whether available_memory is enough for the KV cache to hold at
least one request with the model's max_model_len.
Parameters:
-
(vllm_config¶VllmConfig) –The global VllmConfig
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The kv cache spec of each attention layer in the model
-
(available_memory¶int) –Memory available for KV cache in bytes.
Raises:
-
ValueError–If there is not enough memory available for the KV cache.
Source code in vllm/v1/core/kv_cache_planning.py
create_kv_cache_group_specs(kv_cache_spec, grouped_layer_names)
¶
Create KVCacheGroupSpec object for each kv cache group layer. The layers in the same group should share the same KVCacheSpec.
Parameters:
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –A mapping from each layer name to its corresponding KVCacheSpec.
-
(grouped_layer_names¶list[list[str]]) –A list of kv cache groups, where each element is a list of layer names that belong to the same group and should share the same KVCacheSpec.
Returns:
-
list[KVCacheGroupSpec]–A list of KVCacheGroupSpec objects, one for each group.
Source code in vllm/v1/core/kv_cache_planning.py
estimate_max_model_len(vllm_config, kv_cache_spec, available_memory)
¶
Estimates the maximum model length that can fit in the available memory using binary search.
This function temporarily modifies max_model_len during estimation but restores the original value before returning, ensuring no side effects.
Parameters:
-
(vllm_config¶VllmConfig) –The global VllmConfig
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The kv cache spec of each attention layer in the model
-
(available_memory¶int) –Memory available for KV cache in bytes.
Returns:
-
int–The estimated maximum model length that can fit in the available memory.
Source code in vllm/v1/core/kv_cache_planning.py
get_kv_cache_config_from_groups(vllm_config, kv_cache_groups, available_memory)
¶
Generate the KV cache configuration from the KV cache groups and spec of each layer.
Parameters:
-
(vllm_config¶VllmConfig) –The global VllmConfig
-
(kv_cache_groups¶list[KVCacheGroupSpec]) –The KV cache groups
-
(available_memory¶int) –Memory available for KV cache in bytes
Returns: The generated KVCacheConfig
Source code in vllm/v1/core/kv_cache_planning.py
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 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | |
get_kv_cache_configs(vllm_config, kv_cache_specs, available_memory)
¶
Generates the KV cache configurations for a model.
Since we use a shared centralized controller for all workers, we need the
kv_cache_config to be consistent across all workers to make sure
the KV cache allocation can be applied to all workers. However, different
workers may have different memory available, and different type of layers
(when pipeline parallel is enabled). To handle the difference between
workers, the current implementation is:
1. Merge the KV cache specs of all workers to get the KVCacheSpecs for
the whole model.
2. Generate the KV cache groups based on the layer ratio of the whole model.
This also handles spec unification for hybrid models.
3. Handle auto-fit max_model_len and memory checks using per-worker
projected groups to account for PP sharding.
4. Generate the KV cache configs for each worker based on the KV cache
grouping strategy. (This is reasonable because the layer ratio of
different PP stages are similar.)
5. Change the num_blocks of each worker to the smallest among all workers
and shrink tensor sizes proportionally to avoid allocating unused memory.
Parameters:
-
(vllm_config¶VllmConfig) –The global VllmConfig
-
(kv_cache_specs¶list[dict[str, KVCacheSpec]]) –List of dict[layer_name, KVCacheSpec] for each worker.
-
(available_memory¶list[int]) –Memory available for KV cache in bytes for each worker.
Returns:
-
list[KVCacheConfig]–The generated KVCacheConfigs for each worker.
Source code in vllm/v1/core/kv_cache_planning.py
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 | |
get_kv_cache_groups(vllm_config, kv_cache_spec)
¶
Split the layers in the model into groups with the same KV cache spec.
Parameters:
-
(vllm_config¶VllmConfig) –The global VllmConfig
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The kv cache spec of each attention layer in the model
Returns:
-
list[KVCacheGroupSpec]–The generated KVCacheGroups
Source code in vllm/v1/core/kv_cache_planning.py
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 | |
get_kv_cache_groups_from_builder(builder, vllm_config, kv_cache_spec)
¶
Group the layers with the builder and check the result.
Core checks every grouping, whether it comes from the default grouping, a
model's SupportsKVCacheGrouping or a platform builder.
Source code in vllm/v1/core/kv_cache_planning.py
get_uniform_page_size(kv_cache_specs)
¶
Get the page size of the KV cache.
is_kv_cache_spec_uniform(kv_cache_spec)
¶
Whether all layers in the given KVCacheSpec have the same KV cache spec. Note that we regard FullAttentionSpec with and without sliding window as the same type.
Parameters:
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The kv cache spec of each attention layer in the model
Returns:
-
bool–True if all layers have the same type, False otherwise.
Source code in vllm/v1/core/kv_cache_planning.py
kv_cache_groups_tp_replicas(groups, tp_size, dcp_size=1)
¶
Consecutive TP ranks holding identical KV for every layer.
Source code in vllm/v1/core/kv_cache_planning.py
max_memory_usage_bytes(vllm_config, kv_cache_specs)
¶
Get the maximum memory usage in bytes for the given KV cache specs.
Source code in vllm/v1/core/kv_cache_planning.py
may_override_num_blocks(vllm_config, num_blocks)
¶
Override the number of kv cache blocks if num_gpu_blocks_override is set.
The override is logged once, at the call site in get_kv_cache_configs.
Source code in vllm/v1/core/kv_cache_planning.py
unify_hybrid_kv_cache_specs(kv_cache_spec)
¶
This function tries to convert the KV cache specs to one type if the model is a hybrid model with multiple type of KV cache. It will convert all SlidingWindowSpec to FullAttentionSpec if both types are present.
Parameters:
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The kv cache spec of each attention layer in the model
Source code in vllm/v1/core/kv_cache_planning.py
unify_kv_cache_spec_page_size(kv_cache_spec)
¶
Unify the page size of the given KVCacheSpec. If the page size of all layers
are the same, return the original KVCacheSpec. If not same, unify the page
size by increasing the block size of layers with smaller page size. Two
cases cannot be unified by block size alone and pad their physical page to
the maximum instead: Mamba layers, whose page size comes from state shapes
and is independent of block size; and non-MLA attention layers whose page
does not evenly divide the maximum (the padded page is read through a
strided view). MLA is excluded because sparse MLA indexes the cache in
whole token rows (see flat_kv_row_view), so its block stride can only
be padded by its own row-aligned alignment, not to an arbitrary page
size. Raise NotImplementedError if failed to unify the page size;
get_kv_cache_groups catches it to try the full-allocation fallback
(e.g. MLA next to an incompatible sliding-window draft).
Parameters:
-
(kv_cache_spec¶dict[str, KVCacheSpec]) –The KVCacheSpec of each attention layer in the model
Returns:
-
dict[str, KVCacheSpec]–The updated KVCacheSpec with the same page_size_bytes.
Source code in vllm/v1/core/kv_cache_planning.py
validate_kv_cache_layout(layout, kv_cache_groups)
¶
Validate that the resolved layout can express this model's packing.
The layout was chosen once in the engine core from the backends' supported sets; a backend whose model packs pages side by side (e.g. the DeepSeek-V4 indexer) declares block-outermost layouts there, so an inexpressible layout reaching this point is an error.