From 03b7bfb79b1edf54511fd1b12acc9a875cee5656 Mon Sep 17 00:00:00 2001 From: Zifei Tong Date: Wed, 21 Aug 2024 08:16:43 +0900 Subject: [PATCH] fix --- vllm/config.py | 2 +- vllm/inputs/registry.py | 7 +------ vllm/model_executor/models/phi3v.py | 4 ++-- vllm/transformers_utils/config.py | 21 +-------------------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/vllm/config.py b/vllm/config.py index 1f37705d002b8..e02c8ba380c0c 100644 --- a/vllm/config.py +++ b/vllm/config.py @@ -169,7 +169,7 @@ def __init__( code_revision, rope_scaling, rope_theta) self.hf_text_config = get_hf_text_config(self.hf_config) self.hf_image_processor_config = get_hf_image_processor_config( - self.model, trust_remote_code, revision) + self.model, revision) self.dtype = _get_and_verify_dtype(self.hf_text_config, dtype) # Choose a default enforce_eager value if the user did not specify diff --git a/vllm/inputs/registry.py b/vllm/inputs/registry.py index c3954d7a485e6..7b64941ff1624 100644 --- a/vllm/inputs/registry.py +++ b/vllm/inputs/registry.py @@ -57,12 +57,7 @@ def get_hf_config(self, hf_config_type: Type[C] = PretrainedConfig) -> C: def get_hf_image_processor_config(self) -> Dict: """ - Get the HuggingFace configuration - (:class:`transformers.PretrainedConfig`) of the model, - additionally checking its type. - - Raises: - TypeError: If the model is not of the specified type. + Get the HuggingFace image processor configuration of the model. """ return self.model_config.hf_image_processor_config diff --git a/vllm/model_executor/models/phi3v.py b/vllm/model_executor/models/phi3v.py index 589c5a14501d2..56408c8190e99 100644 --- a/vllm/model_executor/models/phi3v.py +++ b/vllm/model_executor/models/phi3v.py @@ -15,7 +15,7 @@ # limitations under the License. import re from functools import lru_cache -from typing import (Iterable, List, Literal, Mapping, Optional, Tuple, +from typing import (Dict, Iterable, List, Literal, Mapping, Optional, Tuple, TypedDict, Union) import numpy as np @@ -324,7 +324,7 @@ def _calc_hd_transform_size(*, width: int, height: int, hd_num: int = 16): # Based on https://huggingface.co/microsoft/Phi-3-vision-128k-instruct/blob/main/image_processing_phi3_v.py#L181 def get_phi3v_image_feature_size( - hf_config: PretrainedConfig, + hf_config: Dict, *, input_height: int, input_width: int, diff --git a/vllm/transformers_utils/config.py b/vllm/transformers_utils/config.py index 34c50cdcfc235..9b7ae5a332b73 100644 --- a/vllm/transformers_utils/config.py +++ b/vllm/transformers_utils/config.py @@ -101,29 +101,10 @@ def get_config( def get_hf_image_processor_config( model: Union[str, Path], - trust_remote_code: bool, revision: Optional[str] = None, **kwargs, ) -> Dict: - try: - config = get_image_processor_config( - model, - trust_remote_code=trust_remote_code, - revision=revision, - **kwargs) - except ValueError as e: - if (not trust_remote_code and - "requires you to execute the configuration file" in str(e)): - err_msg = ( - "Failed to load the model config. If the model is a custom " - "model not yet available in the HuggingFace transformers " - "library, consider setting `trust_remote_code=True` in LLM " - "or using the `--trust-remote-code` flag in the CLI.") - raise RuntimeError(err_msg) from e - else: - raise e - - return config + return get_image_processor_config(model, revision=revision, **kwargs) def get_hf_text_config(config: PretrainedConfig):