@@ -1752,6 +1752,20 @@ def get_kv_cache_capacity(aphrodite_config: AphroditeConfig, kv_cache_config: KV
17521752 return int (max_concurrency * max_model_len ), max_concurrency
17531753
17541754
1755+ def update_kv_cache_capacity (aphrodite_config : AphroditeConfig , kv_cache_config : KVCacheConfig ) -> None :
1756+ """Store and log the resolved KV cache capacity."""
1757+ num_tokens , max_concurrency = get_kv_cache_capacity (aphrodite_config , kv_cache_config )
1758+ aphrodite_config .cache_config .kv_cache_size_tokens = num_tokens
1759+ aphrodite_config .cache_config .kv_cache_max_concurrency = max_concurrency
1760+ max_model_len = aphrodite_config .model_config .max_model_len
1761+ logger .info_once (
1762+ "GPU KV cache size: %s tokens, Maximum concurrency for %s tokens per request: %.2fx" ,
1763+ f"{ num_tokens :,} " ,
1764+ f"{ max_model_len :,} " ,
1765+ max_concurrency ,
1766+ )
1767+
1768+
17551769def _max_memory_usage_bytes_from_groups (
17561770 aphrodite_config : AphroditeConfig ,
17571771 kv_cache_groups : list [KVCacheGroupSpec ],
@@ -2055,21 +2069,6 @@ def get_kv_cache_configs(
20552069 assert tensor .size % num_blocks_old == 0
20562070 tensor .size = tensor .size // num_blocks_old * min_num_blocks
20572071
2058- if len (kv_cache_config .kv_cache_groups ) > 0 :
2059- max_model_len = aphrodite_config .model_config .max_model_len
2060- # GPU KV cache size in tokens = max_concurrency * max_model_len:
2061- # the total tokens of context the pool can hold at peak
2062- # utilization. Sourcing this from the concurrency calculation
2063- # handles hybrid layouts correctly.
2064- num_tokens , max_concurrency = get_kv_cache_capacity (aphrodite_config , kv_cache_config )
2065-
2066- logger .info_once ("GPU KV cache size: %s tokens" , f"{ num_tokens :,} " )
2067- logger .info_once (
2068- "Maximum concurrency for %s tokens per request: %.2fx" ,
2069- f"{ max_model_len :,} " ,
2070- max_concurrency ,
2071- )
2072-
20732072 return kv_cache_configs
20742073
20752074
0 commit comments