[Fix] has_hf_quant_config crashes on local dirs without the config (#34774)

Co-authored-by: harmya <harmya@modal.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
gilfordting
2026-08-14 07:17:42 +00:00
committed by GitHub
co-authored by harmya Claude Fable 5
parent 65d62109dd
commit 2622e013eb
+4 -3
View File
@@ -3304,9 +3304,10 @@ def has_hf_quant_config(model_path: str) -> bool:
Returns:
True if hf_quant_config.json exists, False otherwise.
"""
# Check if the model_path is a local path
if os.path.exists(os.path.join(model_path, "hf_quant_config.json")):
return True
# Local paths are decided on the filesystem; the hub helpers below
# reject them as invalid repo ids.
if os.path.isdir(model_path):
return os.path.isfile(os.path.join(model_path, "hf_quant_config.json"))
from huggingface_hub import try_to_load_from_cache