[Bugfix] Skip MM processor cache inserts larger than capacity (#53016)

Signed-off-by: Prudhvivuda <prudhvi12042001@gmail.com>
This commit is contained in:
Prudhvi Vuda
2026-08-20 13:42:50 +00:00
committed by GitHub
parent 4b7cb949a9
commit de216b6e64
6 changed files with 108 additions and 5 deletions
+15
View File
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import pytest
from vllm.utils.cache import CacheInfo, LRUCache
@@ -123,3 +125,16 @@ def test_lru_cache():
assert 2 in cache
assert 4 in cache
assert 6 in cache
def test_lru_cache_put_if_fits():
cache = LRUCache(10, getsizeof=lambda x: x)
assert cache.put_if_fits("ok", 4) is True
assert cache["ok"] == 4
assert cache.put_if_fits("big", 11) is False
assert "big" not in cache
with pytest.raises(ValueError, match="value too large"):
cache.put("big", 11)