From 7a8987dac5f0ed0c798a73e8b4ec8f5e640bc63a Mon Sep 17 00:00:00 2001 From: Roger Wang <136131678+ywang96@users.noreply.github.com> Date: Fri, 31 Jan 2025 00:19:35 -0800 Subject: [PATCH] [Bugfix] Gracefully handle huggingface hub http error (#12571) --- vllm/transformers_utils/config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vllm/transformers_utils/config.py b/vllm/transformers_utils/config.py index c97acffa1a719..5805f4ad0b7f7 100644 --- a/vllm/transformers_utils/config.py +++ b/vllm/transformers_utils/config.py @@ -7,7 +7,8 @@ from typing import Any, Dict, Optional, Type, Union import huggingface_hub from huggingface_hub import (file_exists, hf_hub_download, try_to_load_from_cache) -from huggingface_hub.utils import (EntryNotFoundError, LocalEntryNotFoundError, +from huggingface_hub.utils import (EntryNotFoundError, HfHubHTTPError, + LocalEntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError) from torch import nn @@ -294,6 +295,13 @@ def get_hf_file_to_dict(file_name: str, logger.debug("File or repository not found in hf_hub_download", e) return None + except HfHubHTTPError as e: + logger.warning( + "Cannot connect to Hugging Face Hub. Skipping file " + "download for '%s':", + file_name, + exc_info=e) + return None file_path = Path(hf_hub_file) with open(file_path) as file: