add try catch for quant config hf download (#10340)
This commit is contained in:
@@ -420,11 +420,20 @@ class ModelConfig:
|
|||||||
is_local = os.path.exists(self.model_path)
|
is_local = os.path.exists(self.model_path)
|
||||||
modelopt_quant_config = {"quant_method": "modelopt"}
|
modelopt_quant_config = {"quant_method": "modelopt"}
|
||||||
if not is_local:
|
if not is_local:
|
||||||
|
import huggingface_hub
|
||||||
|
|
||||||
|
try:
|
||||||
from huggingface_hub import HfApi
|
from huggingface_hub import HfApi
|
||||||
|
|
||||||
hf_api = HfApi()
|
hf_api = HfApi()
|
||||||
if hf_api.file_exists(self.model_path, "hf_quant_config.json"):
|
if hf_api.file_exists(self.model_path, "hf_quant_config.json"):
|
||||||
quant_cfg = modelopt_quant_config
|
quant_cfg = modelopt_quant_config
|
||||||
|
except huggingface_hub.errors.OfflineModeIsEnabled:
|
||||||
|
logger.warning(
|
||||||
|
"Offline mode is enabled, skipping hf_quant_config.json check"
|
||||||
|
)
|
||||||
|
pass
|
||||||
|
|
||||||
elif os.path.exists(os.path.join(self.model_path, "hf_quant_config.json")):
|
elif os.path.exists(os.path.join(self.model_path, "hf_quant_config.json")):
|
||||||
quant_config_file = os.path.join(
|
quant_config_file = os.path.join(
|
||||||
self.model_path, "hf_quant_config.json"
|
self.model_path, "hf_quant_config.json"
|
||||||
|
|||||||
Reference in New Issue
Block a user