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,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Cosmos3 sound tokenizer integration.
The tokenizer decodes model-generated sound latents for video+audio output. It
@@ -338,9 +338,9 @@ class Cosmos3SoundTokenizer:
model_root = str(model_path) if model_path and os.path.isdir(model_path) else None
if model_root is None and model_path and not explicit_avae_path:
from huggingface_hub import snapshot_download
from vllm_omni.transformers_utils.repo_utils import hf_api
model_root = snapshot_download(
model_root = hf_api().snapshot_download(
repo_id=str(model_path),
revision=getattr(od_config, "revision", None),
allow_patterns=[
@@ -21,7 +21,6 @@ from contextlib import contextmanager
import numpy as np
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer, UMT5Config, UMT5EncoderModel
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
@@ -67,6 +66,7 @@ from vllm_omni.experimental.world_models.session_state import (
resolve_session_state_config,
)
from vllm_omni.inputs.data import OmniDiffusionSamplingParams
from vllm_omni.transformers_utils.repo_utils import hf_api
logger = logging.getLogger(__name__)
MAX_DREAMZERO_SESSIONS = 64
@@ -581,7 +581,7 @@ class DreamZeroPipeline(nn.Module, CFGParallelMixin):
return json.load(f)
try:
json_path = hf_hub_download(model_path, relative_path)
json_path = hf_api().hf_hub_download(model_path, relative_path)
with open(json_path) as f:
return json.load(f)
except Exception:
@@ -76,9 +76,9 @@ def load_json_config(model_path: str, subfolder: str, filename: str, local_files
return json.load(f)
else:
try:
from huggingface_hub import hf_hub_download
from vllm_omni.transformers_utils.repo_utils import hf_api
config_path = hf_hub_download(
config_path = hf_api().hf_hub_download(
repo_id=model_path,
filename=f"{subfolder}/{filename}",
)
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
from __future__ import annotations
@@ -376,9 +376,9 @@ def _ensure_local_dir(model: str | os.PathLike[str], allow_patterns: list[str] |
model_path = Path(model)
if model_path.exists():
return model_path
from huggingface_hub import snapshot_download
from vllm_omni.transformers_utils.repo_utils import hf_api
return Path(snapshot_download(str(model), allow_patterns=allow_patterns))
return Path(hf_api().snapshot_download(str(model), allow_patterns=allow_patterns))
def _ensure_avatar_model_index(model_dir: Path, use_int8: bool) -> None:
@@ -20,7 +20,6 @@ from diffusers.pipelines.ltx2 import LTX2TextConnectors
from diffusers.pipelines.ltx2.latent_upsampler import LTX2LatentUpsamplerModel
from diffusers.pipelines.ltx2.vocoder import LTX2Vocoder
from diffusers.video_processor import VideoProcessor
from huggingface_hub import hf_hub_download
from safetensors import safe_open
from safetensors.torch import load_file
from transformers import AutoModelForImageTextToText, AutoTokenizer, Gemma3ForConditionalGeneration
@@ -32,6 +31,7 @@ from vllm_omni.diffusion.distributed.utils import get_local_device
from vllm_omni.diffusion.model_loader.diffusers_loader import DiffusersPipelineLoader
from vllm_omni.diffusion.model_loader.hub_prefetch import from_pretrained_with_prefetch, prefetch_subfolders
from vllm_omni.diffusion.offloader.module_collector import ModuleDiscovery
from vllm_omni.transformers_utils.repo_utils import hf_api
if TYPE_CHECKING:
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
@@ -279,7 +279,7 @@ def resolve_ltx_artifact(
# independently pinned artifact revision.
revision = model_revision if model == repo_id else artifact_revision
try:
return hf_hub_download(
return hf_api().hf_hub_download(
repo_id=repo_id,
filename=filename,
revision=revision,
@@ -351,7 +351,7 @@ def _load_ltx_metadata_json(model: str, filename: str, revision: str | None = No
return {}
else:
try:
path = hf_hub_download(repo_id=model, filename=filename, revision=revision)
path = hf_api().hf_hub_download(repo_id=model, filename=filename, revision=revision)
except Exception:
return {}
try:
@@ -529,7 +529,7 @@ def _detect_vocoder_output_sample_rate(model: str, revision: str | None = None)
vocoder_config_path = os.path.join(model, "vocoder", "config.json")
if not os.path.exists(vocoder_config_path):
try:
vocoder_config_path = hf_hub_download(model, "vocoder/config.json", revision=revision)
vocoder_config_path = hf_api().hf_hub_download(model, "vocoder/config.json", revision=revision)
except Exception:
return None
try:
@@ -839,7 +839,7 @@ def load_transformer_config(
if not os.path.exists(config_path):
raise FileNotFoundError(f"LTX transformer config not found: {config_path}")
else:
config_path = hf_hub_download(
config_path = hf_api().hf_hub_download(
repo_id=model_path,
filename=f"{subfolder}/config.json",
revision=revision,
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""
OmniVoice TTS Pipeline for vLLM-Omni diffusion engine.
@@ -141,9 +141,9 @@ class OmniVoicePipeline(nn.Module, SupportAudioOutput):
# Resolve model path (HF hub ID → local cache)
if not os.path.isdir(self.model_path):
from huggingface_hub import snapshot_download
from vllm_omni.transformers_utils.repo_utils import hf_api
self.model_path = snapshot_download(self.model_path)
self.model_path = hf_api().snapshot_download(self.model_path)
# Load OmniVoice config
config_path = os.path.join(self.model_path, "config.json")
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""π0 (Pi-Zero) VLA pipeline for vllm-omni.
Entry point for ``DiffusionEngine.step() → pipeline.forward(req)``. Mirrors the
@@ -94,9 +94,9 @@ class Pi0Pipeline(nn.Module):
return None
if os.path.isdir(model):
return model
from huggingface_hub import snapshot_download
from vllm_omni.transformers_utils.repo_utils import hf_api
return snapshot_download(
return hf_api().snapshot_download(
repo_id=model,
allow_patterns=["*.json", "*.safetensors", "*.model", "tokenizer*"],
)
@@ -27,7 +27,6 @@ import numpy as np
import torch
import torch.nn as nn
import torchvision.transforms as T
from huggingface_hub import snapshot_download
from PIL import Image
from transformers import AutoTokenizer
from vllm.logger import init_logger
@@ -109,7 +108,9 @@ def _resolve_model_path(model_path: str) -> str:
"""Resolve a HuggingFace model ID or local path to a local directory."""
if os.path.isdir(model_path):
return model_path
return snapshot_download(model_path)
from vllm_omni.transformers_utils.repo_utils import hf_api
return hf_api().snapshot_download(model_path)
def _round_by_factor(number: float, factor: int) -> int:
+2 -2
View File
@@ -168,8 +168,8 @@ def _load_json(model_path: str, filename: str, local_files_only: bool = True) ->
with open(path) as f:
return json.load(f)
else:
from huggingface_hub import hf_hub_download
from vllm_omni.transformers_utils.repo_utils import hf_api
cached = hf_hub_download(repo_id=model_path, filename=filename)
cached = hf_api().hf_hub_download(repo_id=model_path, filename=filename)
with open(cached) as f:
return json.load(f)
@@ -156,9 +156,9 @@ def load_transformer_config(model_path: str, subfolder: str = "transformer", loc
else:
# Try to download config from HF Hub
try:
from huggingface_hub import hf_hub_download
from vllm_omni.transformers_utils.repo_utils import hf_api
config_path = hf_hub_download(
config_path = hf_api().hf_hub_download(
repo_id=model_path,
filename=f"{subfolder}/config.json",
)
@@ -364,9 +364,9 @@ class Wan22Pipeline(
else:
# For remote models, download and read model_index.json
try:
from huggingface_hub import hf_hub_download
from vllm_omni.transformers_utils.repo_utils import hf_api
model_index_path = hf_hub_download(repo_id=model, filename="model_index.json")
model_index_path = hf_api().hf_hub_download(repo_id=model, filename="model_index.json")
with open(model_index_path) as f:
model_index = json.load(f)
self.expand_timesteps = model_index.get("expand_timesteps", False)