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 7, 05:15 UTC
[Bugfix] Fix RunAI streamer crash with S3-hosted model paths (#35976)
Signed-off-by: AjAnubolu <anuboluajay@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Ajay Anubolu committed
Mar 5, 2026 at 04:14 UTC
ed81d5edd16b0d933d0e1115003c258dcecd991c
1 file changed
+33
-22
vllm/transformers_utils/repo_utils.py
+33
-22
@@ -220,6 +220,37 @@ def get_model_path(model: str | Path, revision: str | None = None):
220
return snapshot_download(repo_id=model, **common_kwargs)
221
222
223
+def _try_download_from_hf_hub(
224
+ model: str | Path, file_name: str, revision: str | None
225
+) -> Path | None:
226
+ """Try to download a file from HuggingFace Hub.
227
+
228
+ Returns the local path on success, None on failure.
229
+ Skips download if model is a local directory.
230
+ """
231
+ if Path(model).is_dir():
232
+ return None
233
+ try:
234
+ return Path(hf_hub_download(model, file_name, revision=revision))
235
+ except huggingface_hub.errors.OfflineModeIsEnabled:
236
+ return None
237
+ except (
238
+ RepositoryNotFoundError,
239
+ RevisionNotFoundError,
240
+ EntryNotFoundError,
241
+ LocalEntryNotFoundError,
242
+ ) as e:
243
+ logger.debug("File or repository not found in hf_hub_download:", exc_info=e)
244
+ return None
245
+ except HfHubHTTPError as e:
246
+ logger.warning(
247
+ "Cannot connect to Hugging Face Hub. Skipping file download for '%s':",
248
+ file_name,
249
+ exc_info=e,
250
+ )
251
+ return None
252
+
253
+
254
def get_hf_file_bytes(
255
file_name: str, model: str | Path, revision: str | None = "main"
256
) -> bytes | None:
@@ -227,8 +258,7 @@ def get_hf_file_bytes(
258
file_path = try_get_local_file(model=model, file_name=file_name, revision=revision)
259
260
if file_path is None:
230
- hf_hub_file = hf_hub_download(model, file_name, revision=revision)
231
- file_path = Path(hf_hub_file)
261
+ file_path = _try_download_from_hf_hub(model, file_name, revision)
262
263
if file_path is not None and file_path.is_file():
264
with open(file_path, "rb") as file:
@@ -275,26 +305,7 @@ def get_hf_file_to_dict(
305
file_path = try_get_local_file(model=model, file_name=file_name, revision=revision)
306
307
if file_path is None:
278
- try:
279
- hf_hub_file = hf_hub_download(model, file_name, revision=revision)
280
- except huggingface_hub.errors.OfflineModeIsEnabled:
281
- return None
282
- except (
283
- RepositoryNotFoundError,
284
- RevisionNotFoundError,
285
- EntryNotFoundError,
286
- LocalEntryNotFoundError,
287
- ) as e:
288
- logger.debug("File or repository not found in hf_hub_download:", exc_info=e)
289
- return None
290
- except HfHubHTTPError as e:
291
- logger.warning(
292
- "Cannot connect to Hugging Face Hub. Skipping file download for '%s':",
293
- file_name,
294
- exc_info=e,
295
- )
296
- return None
297
- file_path = Path(hf_hub_file)
308
+ file_path = _try_download_from_hf_hub(model, file_name, revision)
309
310
if file_path is not None and file_path.is_file():
311
with open(file_path) as file: