Skip to content

Commit 1712543

Browse files
[CI/Build] Fix multimodal tests (#22491)
Signed-off-by: DarkLight1337 <[email protected]>
1 parent 808a7b6 commit 1712543

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

vllm/engine/llm_engine.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ def has_unfinished_requests_for_virtual_engine(
845845

846846
def reset_mm_cache(self) -> bool:
847847
"""Reset the multi-modal cache."""
848-
return self.input_preprocessor.mm_registry.reset_processor_cache()
848+
return self.input_preprocessor.mm_registry.reset_processor_cache(
849+
self.model_config)
849850

850851
def reset_prefix_cache(self, device: Optional[Device] = None) -> bool:
851852
"""Reset prefix cache for all devices."""

vllm/multimodal/registry.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33
from collections.abc import Mapping
44
from dataclasses import dataclass
5+
from functools import lru_cache
56
from typing import TYPE_CHECKING, Generic, Optional, Protocol, TypeVar
67

78
import torch.nn as nn
@@ -86,6 +87,13 @@ def build_processor(
8687
return self.processor(info, dummy_inputs_builder, cache=cache)
8788

8889

90+
# Make sure a different cache is used for each model config
91+
# NOTE: ModelConfig is not hashable so it cannot be passed directly
92+
@lru_cache(maxsize=1)
93+
def _get_processor_cache(model_id: str, capacity_gb: int):
94+
return ProcessingCache(capacity_gb) if capacity_gb > 0 else None
95+
96+
8997
class MultiModalRegistry:
9098
"""
9199
A registry that dispatches data processing according to the model.
@@ -95,22 +103,15 @@ def __init__(self) -> None:
95103
self._processor_factories = ClassRegistry[nn.Module,
96104
_ProcessorFactories]()
97105

98-
self._processor_cache: Optional[ProcessingCache] = None
99-
100106
def _get_processor_cache(self, model_config: "ModelConfig"):
107+
model_id = model_config.model
101108
capacity_gb = model_config.mm_processor_cache_gb
102-
if capacity_gb is None:
103-
return None # Overrides `disable_cache` argument
104-
105-
if self._processor_cache is None:
106-
self._processor_cache = ProcessingCache(capacity_gb)
107-
108-
return self._processor_cache
109+
return _get_processor_cache(model_id, capacity_gb)
109110

110-
def reset_processor_cache(self) -> bool:
111+
def reset_processor_cache(self, model_config: "ModelConfig") -> bool:
111112
"""Reset the multi-modal processing cache."""
112-
if self._processor_cache:
113-
self._processor_cache.reset()
113+
if processor_cache := self._get_processor_cache(model_config):
114+
processor_cache.reset()
114115

115116
return True # Success
116117

vllm/v1/engine/async_llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ async def stop_profile(self) -> None:
566566
await self.engine_core.profile_async(False)
567567

568568
async def reset_mm_cache(self) -> None:
569-
self.processor.mm_registry.reset_processor_cache()
569+
self.processor.mm_registry.reset_processor_cache(self.model_config)
570570
self.processor.mm_input_cache_client.reset()
571571
await self.engine_core.reset_mm_cache_async()
572572

vllm/v1/engine/llm_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def stop_profile(self):
271271
self.engine_core.profile(False)
272272

273273
def reset_mm_cache(self):
274-
self.processor.mm_registry.reset_processor_cache()
274+
self.processor.mm_registry.reset_processor_cache(self.model_config)
275275
self.processor.mm_input_cache_client.reset()
276276
self.engine_core.reset_mm_cache()
277277

0 commit comments

Comments
 (0)