A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 22:15 UTC
[Misc] Avoid calling unnecessary `hf_list_repo_files` for local model path (#13348)
Signed-off-by: isotr0py <2037008807@qq.com>
Isotr0py committed
Feb 20, 2025 at 02:57 UTC
550d97eb58f03b21f0f4c9ef1935c2789186a5a0
1 file changed
+10
-3
vllm/transformers_utils/config.py
+10
-3
@@ -115,7 +115,14 @@ def list_repo_files(
115
token: Union[str, bool, None] = None,
116
) -> list[str]:
117
118
- def lookup_files():
118
+ def lookup_files() -> list[str]:
119
+ # directly list files if model is local
120
+ if (local_path := Path(repo_id)).exists():
121
+ return [
122
+ str(file.relative_to(local_path))
123
+ for file in local_path.rglob('*') if file.is_file()
124
+ ]
125
+ # if model is remote, use hf_hub api to list files
126
try:
127
if VLLM_USE_MODELSCOPE:
128
from vllm.transformers_utils.utils import (
@@ -154,8 +161,8 @@ def file_exists(
161
# In offline mode the result can be a false negative
162
def file_or_path_exists(model: Union[str, Path], config_name: str,
163
revision: Optional[str]) -> bool:
157
- if Path(model).exists():
158
- return (Path(model) / config_name).is_file()
164
+ if (local_path := Path(model)).exists():
165
+ return (local_path / config_name).is_file()
166
167
# Offline mode support: Check if config file is cached already
168
cached_filepath = try_to_load_from_cache(repo_id=model,