Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import torch
import torch.nn as nn
import torch.nn.functional as F
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api
from PIL import Image
from transformers import (
AutoConfig,
Expand Down Expand Up @@ -1496,7 +1496,7 @@ def num_gpus_available():
def dummy_opt_path():
json_path = os.path.join(_dummy_opt_path, "config.json")
if not os.path.exists(_dummy_opt_path):
snapshot_download(
hf_api().snapshot_download(
repo_id="facebook/opt-125m",
local_dir=_dummy_opt_path,
ignore_patterns=["*.bin", "*.bin.index.json", "*.pt", "*.h5", "*.msgpack"],
Expand All @@ -1514,7 +1514,7 @@ def dummy_opt_path():
def dummy_llava_path():
json_path = os.path.join(_dummy_llava_path, "config.json")
if not os.path.exists(_dummy_llava_path):
snapshot_download(
hf_api().snapshot_download(
repo_id="llava-hf/llava-1.5-7b-hf",
local_dir=_dummy_llava_path,
ignore_patterns=[
Expand All @@ -1539,7 +1539,7 @@ def dummy_llava_path():
def dummy_gemma2_embedding_path():
json_path = os.path.join(_dummy_gemma2_embedding_path, "config.json")
if not os.path.exists(_dummy_gemma2_embedding_path):
snapshot_download(
hf_api().snapshot_download(
repo_id="BAAI/bge-multilingual-gemma2",
local_dir=_dummy_gemma2_embedding_path,
ignore_patterns=[
Expand Down
6 changes: 3 additions & 3 deletions tests/distributed/test_rocm_quick_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import pytest
import torch
import torch.distributed as dist
from huggingface_hub import snapshot_download

import vllm.envs as envs
from vllm import LLM, SamplingParams
from vllm.distributed import cleanup_dist_env_and_memory
from vllm.platforms import current_platform
from vllm.transformers_utils.repo_utils import hf_api
from vllm.utils.network_utils import get_open_port

pytestmark = pytest.mark.skipif(
Expand Down Expand Up @@ -210,11 +210,11 @@ def _log_prompt_summaries() -> None:
@lru_cache(maxsize=1)
def _get_model_path() -> str:
try:
path = snapshot_download(repo_id=MODEL_NAME, local_files_only=True)
path = hf_api().snapshot_download(repo_id=MODEL_NAME, local_files_only=True)
_log(f"using cached model snapshot: {path}")
return path
except Exception:
path = snapshot_download(repo_id=MODEL_NAME)
path = hf_api().snapshot_download(repo_id=MODEL_NAME)
_log(f"downloaded model snapshot: {path}")
return path

Expand Down
18 changes: 10 additions & 8 deletions tests/entrypoints/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,32 @@ def sample_sql_statements():
@pytest.fixture(scope="session")
def qwen3_lora_files():
"""Download Qwen3 LoRA files once per test session."""
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api

return snapshot_download(repo_id="charent/self_cognition_Alice")
return hf_api().snapshot_download(repo_id="charent/self_cognition_Alice")


@pytest.fixture(scope="session")
def qwen3_meowing_lora_files():
"""Download Qwen3 LoRA files once per test session."""
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api

return snapshot_download(repo_id="Jackmin108/Qwen3-0.6B-Meow-LoRA")
return hf_api().snapshot_download(repo_id="Jackmin108/Qwen3-0.6B-Meow-LoRA")


@pytest.fixture(scope="session")
def qwen3_woofing_lora_files():
"""Download Qwen3 LoRA files once per test session."""
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api

return snapshot_download(repo_id="Jackmin108/Qwen3-0.6B-Woof-LoRA")
return hf_api().snapshot_download(repo_id="Jackmin108/Qwen3-0.6B-Woof-LoRA")


@pytest.fixture(scope="session")
def opt125_lora_files() -> str:
"""Download opt-125m LoRA files once per test session."""
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api

return snapshot_download(repo_id="peft-internal-testing/opt-125m-dummy-lora")
return hf_api().snapshot_download(
repo_id="peft-internal-testing/opt-125m-dummy-lora"
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import safetensors
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoConfig, AutoTokenizer

from tests.utils import RemoteOpenAIServer
from vllm.transformers_utils.repo_utils import hf_api
from vllm.utils.serial_utils import tensor2base64
from vllm.utils.torch_utils import is_torch_equal_or_newer

Expand Down Expand Up @@ -126,11 +126,13 @@ def qwen2audio_aligned_content_and_embeds_b64() -> tuple[str, str]:
content = "Describe this audio."
tokenizer = AutoTokenizer.from_pretrained(QWEN2AUDIO_MODEL, trust_remote_code=True)

index_path = hf_hub_download(QWEN2AUDIO_MODEL, "model.safetensors.index.json")
index_path = hf_api().hf_hub_download(
QWEN2AUDIO_MODEL, "model.safetensors.index.json"
)
with open(index_path) as f:
weight_map = json.load(f)["weight_map"]
embed_key = next(k for k in weight_map if k.endswith("embed_tokens.weight"))
shard_path = hf_hub_download(QWEN2AUDIO_MODEL, weight_map[embed_key])
shard_path = hf_api().hf_hub_download(QWEN2AUDIO_MODEL, weight_map[embed_key])
with safetensors.safe_open(shard_path, framework="pt", device="cpu") as f:
embed_weight = f.get_tensor(embed_key)
embed_layer = nn.Embedding.from_pretrained(embed_weight.to(QWEN2AUDIO_DTYPE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import safetensors
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer

from tests.utils import RemoteOpenAIServer
from vllm.assets.image import ImageAsset
from vllm.multimodal.utils import encode_image_url
from vllm.transformers_utils.repo_utils import hf_api
from vllm.utils.serial_utils import tensor2base64

MODEL_NAME = "Qwen/Qwen2-VL-2B-Instruct"
Expand Down Expand Up @@ -84,11 +84,11 @@ def aligned_content_and_embeds_b64() -> tuple[str, str]:
content = "Describe this image."
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)

index_path = hf_hub_download(MODEL_NAME, "model.safetensors.index.json")
index_path = hf_api().hf_hub_download(MODEL_NAME, "model.safetensors.index.json")
with open(index_path) as f:
weight_map = json.load(f)["weight_map"]
embed_key = next(k for k in weight_map if k.endswith("embed_tokens.weight"))
shard_path = hf_hub_download(MODEL_NAME, weight_map[embed_key])
shard_path = hf_api().hf_hub_download(MODEL_NAME, weight_map[embed_key])
with safetensors.safe_open(shard_path, framework="pt", device="cpu") as f:
embed_weight = f.get_tensor(embed_key)
embed_layer = nn.Embedding.from_pretrained(embed_weight.to(MODEL_DTYPE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
import openai # use the official client for correctness check
import pytest
import pytest_asyncio
from huggingface_hub import snapshot_download

from tests.conftest import AudioTestAssets
from tests.utils import RemoteOpenAIServer
from vllm.transformers_utils.repo_utils import hf_api

# NOTE - the tests in this module are currently analogous to test_chat, but are
# separated to avoid OOM killing due to module-scoped servers, since we
# need a multimodal model for these tests.

# Contains a modality specific lora alongside the base model
MULTIMODAL_MODEL_NAME = snapshot_download("microsoft/Phi-4-multimodal-instruct")
MULTIMODAL_MODEL_NAME = hf_api().snapshot_download(
"microsoft/Phi-4-multimodal-instruct"
)
AUDIO_LORA_PATH = os.path.join(MULTIMODAL_MODEL_NAME, "speech-lora")

ACTIVE_MM_LORA_RESPONSE = "Spoken text: The first words I spoke in the original chronograph, a little piece of practical poetry. Mary had a little lamb, it slept with quite a snow, and everywhere that Mary went, the lamb was sure to go." # noqa: E501
Expand Down
4 changes: 2 additions & 2 deletions tests/entrypoints/openai/chat_completion/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
@pytest.fixture(scope="module")
def zephyr_lora_files():
"""Download zephyr LoRA files once per test session."""
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api

return snapshot_download(repo_id="typeof/zephyr-7b-beta-lora")
return hf_api().snapshot_download(repo_id="typeof/zephyr-7b-beta-lora")


@pytest.fixture(scope="module")
Expand Down
4 changes: 2 additions & 2 deletions tests/entrypoints/pooling/scoring/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pybase64 as base64
import torch
import torch.nn.functional as F
from huggingface_hub import hf_hub_download
from PIL import Image
from safetensors.torch import load_file
from transformers import AutoModel, AutoTokenizer
Expand All @@ -18,6 +17,7 @@
)
from vllm.entrypoints.pooling.scoring.typing import ScoreMultiModalParam
from vllm.entrypoints.pooling.scoring.utils import compute_maxsim_score
from vllm.transformers_utils.repo_utils import hf_api


class ColBERTScoringHfRunner(torch.nn.Module):
Expand All @@ -38,7 +38,7 @@ def __init__(self, model_name, linear_weights_key):
).to(self.device)
self.model.eval()

path = hf_hub_download(model_name, filename="model.safetensors")
path = hf_api().hf_hub_download(model_name, filename="model.safetensors")
weights = load_file(path)

self.linear_weight = weights[linear_weights_key].to(self.device).float()
Expand Down
4 changes: 2 additions & 2 deletions tests/entrypoints/serve/sagemaker/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
@pytest.fixture(scope="session")
def smollm2_lora_files():
"""Download LoRA files once per test session."""
from huggingface_hub import snapshot_download
from vllm.transformers_utils.repo_utils import hf_api

return snapshot_download(repo_id=LORA_ADAPTER_NAME_SMOLLM)
return hf_api().snapshot_download(repo_id=LORA_ADAPTER_NAME_SMOLLM)


@pytest.fixture(scope="module")
Expand Down
4 changes: 2 additions & 2 deletions tests/entrypoints/tool_parsers/test_hermes_tool_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import openai
import pytest
import pytest_asyncio
from huggingface_hub import snapshot_download
from typing_extensions import TypedDict

from tests.utils import RemoteOpenAIServer
from vllm.tool_parsers.abstract_tool_parser import ToolParser
from vllm.tool_parsers.granite4_tool_parser import Granite4ToolParser
from vllm.tool_parsers.hermes_tool_parser import Hermes2ProToolParser
from vllm.transformers_utils.repo_utils import hf_api

LORA_MODEL = "minpeter/LoRA-Llama-3.2-1B-tool-vllm-ci"

Expand Down Expand Up @@ -91,7 +91,7 @@ def server_config(request):
config = CONFIGS[request.param]

# download model and tokenizer using transformers
snapshot_download(config["model"])
hf_api().snapshot_download(config["model"])
yield CONFIGS[request.param]


Expand Down
4 changes: 2 additions & 2 deletions tests/kernels/quantization/test_nvfp4_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import cast

import huggingface_hub
import pytest
import torch
from safetensors import safe_open
Expand Down Expand Up @@ -33,6 +32,7 @@
kNvfp4Static,
)
from vllm.platforms import current_platform
from vllm.transformers_utils.repo_utils import hf_api
from vllm.triton_utils import triton

if current_platform.is_rocm():
Expand All @@ -56,7 +56,7 @@ def on_gfx950() -> bool:
@pytest.fixture(scope="module")
def loaded_model_files():
return {
model_id: huggingface_hub.snapshot_download(
model_id: hf_api().snapshot_download(
repo_id=model_id, allow_patterns=config["shards"]
)
for model_id, config in MOE_MODEL_CONFIGS.items()
Expand Down
Loading
Loading