Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Don't use cache during multi-modal profiling #14336

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion vllm/inputs/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ def dummy_data_for_profiling(

if mm_registry.has_processor(model_config):
tokenizer = cached_tokenizer_from_config(model_config)
processor = mm_registry.create_processor(model_config, tokenizer)
processor = mm_registry.create_processor(model_config,
tokenizer,
disable_cache=True)
profiler = MultiModalProfiler(processor)
dummy_data = profiler.get_dummy_data(
seq_len, is_encoder_data=is_encoder_data)
Expand Down
16 changes: 12 additions & 4 deletions vllm/multimodal/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def get_max_tokens_per_item_by_modality(
"""
if self.has_processor(model_config):
tokenizer = cached_tokenizer_from_config(model_config)
processor = self.create_processor(model_config, tokenizer)
processor = self.create_processor(model_config,
tokenizer,
disable_cache=True)
seq_len = model_config.max_model_len
mm_limits = self.get_mm_limits_per_prompt(model_config)
return processor.info.get_mm_max_tokens_per_item(
Expand Down Expand Up @@ -372,7 +374,9 @@ def get_mm_limits_per_prompt(
"""
if self.has_processor(model_config):
tokenizer = cached_tokenizer_from_config(model_config)
processor = self.create_processor(model_config, tokenizer)
processor = self.create_processor(model_config,
tokenizer,
disable_cache=True)
profiler = MultiModalProfiler(processor)
return profiler.get_mm_limits()

Expand Down Expand Up @@ -433,18 +437,22 @@ def create_processor(
self,
model_config: "ModelConfig",
tokenizer: AnyTokenizer,
*,
disable_cache: Optional[bool] = None,
) -> BaseMultiModalProcessor[BaseProcessingInfo]:
"""
Create a multi-modal processor for a specific model and tokenizer.
See also:
:ref:`mm-processing`
"""
if disable_cache is None:
disable_cache = model_config.disable_mm_preprocessor_cache

model_cls = self._get_model_cls(model_config)
factories = self._processor_factories[model_cls]

ctx = InputProcessingContext(model_config, tokenizer)
cache = (None if model_config.disable_mm_preprocessor_cache else
self._processing_cache)
cache = None if disable_cache else self._processing_cache

return factories.build_processor(ctx, cache=cache)