[Bugfix] Exclude kv_cache_memory_bytes from CacheConfig.compute_hash (#47356)
Signed-off-by: Nils Matteson <nils@thaw.sh> Signed-off-by: Nils Matteson <nilsmatteson@icloud.com> Co-authored-by: Nils Matteson <nils@thaw.sh>
Nils Matteson committed
Jul 7, 2026 at 11:46 UTC
d6875196ad2ed91c11cb39c877e63884c4180e01
2 files changed
+14
tests/config/test_config_utils.py
+13
@@ -6,6 +6,7 @@ from enum import Enum
6
7
import pytest
8
9
+from vllm.config.cache import CacheConfig
10
from vllm.config.utils import get_hash_factors, hash_factors, normalize_value
11
12
# Helpers
@@ -201,3 +202,15 @@ print(hash_factors(envs.compile_factors()))
202
"compile_factors hash differs between fresh initializations - "
203
"dynamic env vars may not be properly ignored"
204
)
205
+
206
+
207
+def test_cache_config_hash_ignores_kv_cache_sizing_knobs():
208
+ """kv_cache_memory_bytes only sizes the KV cache allocation (like
209
+ gpu_memory_utilization, which is already ignored); it does not affect
210
+ the compiled computation graph. If it leaks into the hash, setting the
211
+ documented fast-boot knob silently invalidates the torch.compile cache
212
+ and forces a full recompile.
213
+ """
214
+ base_hash = CacheConfig().compute_hash()
215
+ assert CacheConfig(kv_cache_memory_bytes=1 << 30).compute_hash() == base_hash
216
+ assert CacheConfig(gpu_memory_utilization=0.5).compute_hash() == base_hash
vllm/config/cache.py
+1
@@ -205,6 +205,7 @@ class CacheConfig:
205
ignored_factors = {
206
# Runtime/derived knobs that don't affect compiled graph shape
207
"gpu_memory_utilization",
208
+ "kv_cache_memory_bytes",
209
"is_attention_free",
210
"num_gpu_blocks_override",
211
"enable_prefix_caching",