[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
+29
View File
@@ -17,6 +17,7 @@ from vllm.multimodal.cache import (
MultiModalProcessorCacheInItem,
MultiModalProcessorCacheItem,
MultiModalProcessorCacheItemMetadata,
MultiModalProcessorOnlyCache,
MultiModalProcessorSenderCache,
MultiModalReceiverCache,
ShmObjectStoreReceiverCache,
@@ -247,6 +248,34 @@ class _StubModelConfig:
return self._mm_config
@pytest.mark.skip_global_cleanup
def test_oversized_item_is_served_uncached():
"""Items larger than the processor cache must not crash insert.
cachetools.LRUCache raises ValueError("value too large") when a single
item exceeds maxsize. Engine profiling uses a max-size dummy item, so this
used to abort EngineCore startup (vllm-project/vllm#52835). Skip the
insert and serve the item uncached instead.
"""
# 1 KiB cache; a 4 KiB item cannot fit even if the cache is empty.
model_config = _StubModelConfig(mm_processor_cache_gb=1024 / GiB_bytes)
item = MultiModalKwargsItem.dummy(nbytes=4096)
small = MultiModalKwargsItem.dummy(nbytes=64)
p0_only = MultiModalProcessorOnlyCache(model_config) # type: ignore[arg-type]
assert p0_only.get_and_update_item((item, []), "big")[0] is item
assert not p0_only.is_cached_item("big")
assert p0_only.get_and_update_item((small, []), "small")[0] is small
assert p0_only.is_cached_item("small")
p0 = MultiModalProcessorSenderCache(model_config) # type: ignore[arg-type]
p1 = MultiModalReceiverCache(model_config) # type: ignore[arg-type]
assert p0.get_and_update_item((item, []), "big")[0] is item
assert not p0.is_cached_item("big")
assert p1.get_and_update_item(item, "big") is item
assert "big" not in p1._cache
def test_mm_cache_miss_raises_and_recovers():
"""A P0/P1 multimodal cache drift must be recoverable, not a hard crash.
+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)