Add vLLM-Omni library info to Hugging Face Hub requests (#5381)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-09-08 10:08:38 -06:00
1 parent 7a80b79698
commit fdaf4e31bd
57 files changed
+259 -220

No files matched your search

@@ -1,3 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
from __future__ import annotations
import hashlib
@@ -20,9 +23,9 @@ from vllm.logger import init_logger
logger = init_logger(__name__)
try:
from huggingface_hub import snapshot_download
from vllm_omni.transformers_utils.repo_utils import hf_api
except Exception: # pragma: no cover
snapshot_download = None
hf_api = None
class DetokTarget(IntEnum):
@@ -397,13 +400,13 @@ def _find_dynin_config_under_root(root: Path) -> Path | None:
@lru_cache(maxsize=16)
def _resolve_dynin_config_from_hf_repo(repo_id: str) -> str | None:
if not _looks_like_hf_repo_id(repo_id) or snapshot_download is None:
if not _looks_like_hf_repo_id(repo_id) or hf_api is None:
return None
try:
snapshot_dir = (
Path(
snapshot_download(
hf_api().snapshot_download(
repo_id=repo_id,
repo_type="model",
allow_patterns=list(_DYNIN_CONFIG_CANDIDATE_RELPATHS),
@@ -719,7 +722,7 @@ def _resolve_remote_snapshot_dir(
if source_path.is_dir():
return str(source_path.resolve())
if snapshot_download is None:
if hf_api is None:
raise RuntimeError("huggingface_hub is required to load remote code.")
kwargs: dict[str, Any] = {
@@ -732,10 +735,10 @@ def _resolve_remote_snapshot_dir(
kwargs["revision"] = revision
try:
return str(snapshot_download(**kwargs))
return str(hf_api().snapshot_download(**kwargs))
except TypeError:
kwargs.pop("local_files_only", None)
return str(snapshot_download(**kwargs))
return str(hf_api().snapshot_download(**kwargs))
def _ensure_remote_package(snapshot_dir: str) -> str:
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
from __future__ import annotations
import os
@@ -80,7 +83,7 @@ def _ensure_remote_s2u_vendor_root(
return str(existing_path)
try:
from huggingface_hub import snapshot_download
from vllm_omni.transformers_utils.repo_utils import hf_api
except Exception as e:
logger.warning("huggingface_hub unavailable; cannot fetch s2u_vendor from %s: %s", repo_id, e)
return None
@@ -91,7 +94,7 @@ def _ensure_remote_s2u_vendor_root(
for revision in revisions:
try:
snapshot_dir = snapshot_download(
snapshot_dir = hf_api().snapshot_download(
repo_id=repo_id,
revision=revision,
allow_patterns=["s2u_vendor/**"],
@@ -99,7 +102,7 @@ def _ensure_remote_s2u_vendor_root(
)
except TypeError:
try:
snapshot_dir = snapshot_download(
snapshot_dir = hf_api().snapshot_download(
repo_id=repo_id,
revision=revision,
allow_patterns=["s2u_vendor/**"],