diff --git a/tests/renderers/test_process_multi_modal_uuids.py b/tests/renderers/test_process_multi_modal_uuids.py index 76b394897e..8987782d71 100644 --- a/tests/renderers/test_process_multi_modal_uuids.py +++ b/tests/renderers/test_process_multi_modal_uuids.py @@ -176,9 +176,32 @@ def test_multi_modal_uuids_accepts_empty( assert processed_mm_uuids == mm_uuids -def test_multi_modal_uuids_ignored_when_caching_disabled(): - # When both processor cache is 0 and prefix caching disabled, the - # processor builds overrides from request id instead of using user UUIDs. +@pytest.mark.parametrize( + "mm_uuids, expected", + [ + ( + {"image": ["hash_cherry", "hash_stop"], "video": ["hash_video"]}, + {"image": ["hash_cherry", "hash_stop"], "video": ["hash_video"]}, + ), + ( + {"image": [None, "hash_stop"], "video": None}, + {"image": ["req-42-image-0", "hash_stop"], "video": ["req-42-video-0"]}, + ), + ( + {"image": ["", None]}, + {"image": ["", "req-42-image-1"], "video": ["req-42-video-0"]}, + ), + ( + {}, + { + "image": ["req-42-image-0", "req-42-image-1"], + "video": ["req-42-video-0"], + }, + ), + ], +) +def test_multi_modal_uuids_preserved_when_caching_disabled(mm_uuids, expected): + """Only missing UUIDs get request-local IDs when both caches are disabled.""" renderer = _build_renderer(mm_cache_gb=0.0, enable_prefix_caching=False) request_id = "req-42" @@ -186,7 +209,6 @@ def test_multi_modal_uuids_ignored_when_caching_disabled(): "image": [cherry_pil_image, stop_pil_image], "video": baby_reading_np_ndarrays, } - mm_uuids = {"image": ["hash_cherry", "hash_stop"], "video": ["hash_video"]} mm_processor = renderer.get_mm_processor() mm_data_items = mm_processor.info.parse_mm_data(mm_data) @@ -196,16 +218,4 @@ def test_multi_modal_uuids_ignored_when_caching_disabled(): mm_data, mm_data_items, mm_uuid_items, request_id ) - # Expect request-id-based overrides are passed through - assert set(mm_uuids.keys()) == {"image", "video"} - assert len(mm_uuids["image"]) == 2 - assert len(mm_uuids["video"]) == 1 - assert processed_mm_uuids["image"][0].startswith( - f"{request_id}-image-" - ) and processed_mm_uuids["image"][0].endswith("-0") - assert processed_mm_uuids["image"][1].startswith( - f"{request_id}-image-" - ) and processed_mm_uuids["image"][1].endswith("-1") - assert processed_mm_uuids["video"][0].startswith( - f"{request_id}-video-" - ) and processed_mm_uuids["video"][0].endswith("-0") + assert processed_mm_uuids == expected diff --git a/vllm/renderers/base.py b/vllm/renderers/base.py index 0fd1b7610b..4aca17fa43 100644 --- a/vllm/renderers/base.py +++ b/vllm/renderers/base.py @@ -824,20 +824,22 @@ class BaseRenderer(ABC, Generic[_T]): ) -> MultiModalUUIDItems: model_config = self.model_config - # NOTE: When users explicitly turn off BOTH prefix caching and input - # processing caching, no multimodal features or embeddings will be - # reused across requests, therefore identifying multimodal data items - # by their content is no longer necessary, and we create uuids with - # `--`, overriding even user-provided ones. + # Skip content hashing when both caches are disabled, but preserve + # explicit UUIDs used to identify embeddings across EC instances. if ( model_config.multimodal_config and model_config.multimodal_config.mm_processor_cache_gb == 0 and not self.config.cache_config.enable_prefix_caching ): - mm_uuid_items = { - modality: [f"{mm_req_id}-{modality}-{i}" for i in range(data_count)] - for modality, data_count in mm_data_items.get_all_counts().items() - } + mm_uuid_items = dict(mm_uuid_items) + for modality, data_count in mm_data_items.get_all_counts().items(): + uuids = mm_uuid_items.get(modality) + if uuids is None: + uuids = [None] * data_count + mm_uuid_items[modality] = [ + uuid if uuid is not None else f"{mm_req_id}-{modality}-{i}" + for i, uuid in enumerate(uuids) + ] self._validate_mm_uuids(mm_data, mm_data_items, mm_uuid_items)