Skip to content

Commit 669fc3f

Browse files
committed
Merge remote-tracking branch 'Isotr0py/local-lookup' into upstream_merge_25_02_17
2 parents ce342c7 + 7cc05dd commit 669fc3f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

vllm/transformers_utils/config.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,14 @@ def list_repo_files(
116116
token: Union[str, bool, None] = None,
117117
) -> list[str]:
118118

119-
def lookup_files():
119+
def lookup_files() -> list[str]:
120+
# directly list files if model is local
121+
if (local_path := Path(repo_id)).exists():
122+
return [
123+
str(file.relative_to(local_path))
124+
for file in local_path.rglob('*') if file.is_file()
125+
]
126+
# if model is remote, use hf_hub api to list files
120127
try:
121128
if VLLM_USE_MODELSCOPE:
122129
from vllm.transformers_utils.utils import (
@@ -156,8 +163,8 @@ def file_exists(
156163
# In offline mode the result can be a false negative
157164
def file_or_path_exists(model: Union[str, Path], config_name: str,
158165
revision: Optional[str]) -> bool:
159-
if Path(model).exists():
160-
return (Path(model) / config_name).is_file()
166+
if (local_path := Path(model)).exists():
167+
return (local_path / config_name).is_file()
161168

162169
# Offline mode support: Check if config file is cached already
163170
cached_filepath = try_to_load_from_cache(repo_id=model,

0 commit comments

Comments
 (0)