Skip to content

Commit 92017b0

Browse files
stzoozzgemini-code-assist[bot]HDCharles
authored
Fix: Support custom HF_ENDPOINT for model recipe downloads (#1982)
SUMMARY: Replace hardcoded `HUGGINGFACE_CO_URL_HOME` with `HfApi().`endpoint to enable custom HuggingFace endpoint configuration via `HF_ENDPOINT` environment variable. (Fixed #1967) TEST PLAN: Tested with custom endpoint (`HF_ENDPOINT=https://hf-mirror.com`): Uses mirror site. Any feedback or suggestions for improvement are welcome! --------- Signed-off-by: Shuting Zhao <shuting.zhao@outlook.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: HDCharles <39544797+HDCharles@users.noreply.github.com>
1 parent 0e4d3a0 commit 92017b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/llmcompressor/transformers/utils/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import requests
1111
from huggingface_hub import (
1212
_CACHED_NO_EXIST,
13-
HUGGINGFACE_CO_URL_HOME,
13+
HfApi,
1414
hf_hub_download,
1515
try_to_load_from_cache,
1616
)
@@ -149,7 +149,9 @@ def recipe_from_huggingface_model_id(
149149
logger.debug("HF_HUB_OFFLINE is set, skipping recipe download from HuggingFace")
150150
return None
151151

152-
model_id_url = os.path.join(HUGGINGFACE_CO_URL_HOME, hf_stub)
152+
# Use custom HF_ENDPOINT
153+
hf_api = HfApi()
154+
model_id_url = f"{hf_api.endpoint.rstrip('/')}/{hf_stub}"
153155
request = requests.head(model_id_url)
154156

155157
if request.status_code != 200:

0 commit comments

Comments
 (0)