2323import numpy as np
2424import regex as re
2525import torch
26- from huggingface_hub import HfFileSystem , hf_hub_download , snapshot_download
2726from safetensors .torch import load , load_file , safe_open , save_file
2827from tqdm .auto import tqdm
2928from transformers .utils import SAFE_WEIGHTS_INDEX_NAME
4645)
4746from vllm .platforms import current_platform
4847from vllm .tracing import instrument
48+ from vllm .transformers_utils .repo_utils import hf_api , hf_fs
4949from vllm .utils .import_utils import PlaceholderModule
5050
5151try :
@@ -373,7 +373,7 @@ def get_quant_config(
373373 if not is_local :
374374 # Download the config files.
375375 with get_lock (model_config .model , load_config .download_dir ):
376- hf_folder = snapshot_download (
376+ hf_folder = hf_api (). snapshot_download (
377377 model_config .model ,
378378 revision = model_config .revision ,
379379 allow_patterns = "*.json" ,
@@ -431,7 +431,7 @@ def get_sparse_attention_config(
431431 if not is_local :
432432 # Download the config files.
433433 with get_lock (model_name_or_path , load_config .download_dir ):
434- hf_folder = snapshot_download (
434+ hf_folder = hf_api (). snapshot_download (
435435 model_name_or_path ,
436436 revision = model_config .revision ,
437437 allow_patterns = "*.json" ,
@@ -534,7 +534,7 @@ def download_weights_from_hf(
534534 # Attempt to reduce allow_patterns to a single pattern
535535 # so we only have to call snapshot_download once.
536536 try :
537- fs = HfFileSystem ()
537+ fs = hf_fs ()
538538 file_list = fs .ls (
539539 os .path .join (model_name_or_path , subfolder or "" ),
540540 detail = False ,
@@ -546,7 +546,7 @@ def download_weights_from_hf(
546546 # unnecessary files (e.g., from subdirectories like "original/").
547547 index_file = f"{ model_name_or_path } /{ SAFE_WEIGHTS_INDEX_NAME } "
548548 if "*.safetensors" in allow_patterns and index_file in file_list :
549- index_path = hf_hub_download (
549+ index_path = hf_api (). hf_hub_download (
550550 repo_id = model_name_or_path ,
551551 filename = SAFE_WEIGHTS_INDEX_NAME ,
552552 cache_dir = cache_dir ,
@@ -582,7 +582,7 @@ def download_weights_from_hf(
582582 with get_lock (model_name_or_path , cache_dir ):
583583 start_time = time .perf_counter ()
584584 for allow_pattern in allow_patterns :
585- hf_folder = snapshot_download (
585+ hf_folder = hf_api (). snapshot_download (
586586 model_name_or_path ,
587587 allow_patterns = allow_pattern ,
588588 ignore_patterns = ignore_patterns ,
@@ -631,7 +631,7 @@ def download_safetensors_index_file_from_hf(
631631 with get_lock (model_name_or_path , cache_dir ):
632632 try :
633633 # Download the safetensors index file.
634- hf_hub_download (
634+ hf_api (). hf_hub_download (
635635 repo_id = model_name_or_path ,
636636 filename = index_file ,
637637 cache_dir = cache_dir ,
0 commit comments