Skip to content

Commit

Permalink
Log time consumption on weight downloading
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Duan <[email protected]>
  • Loading branch information
waltforme committed Feb 8, 2025
1 parent 45cbc49 commit ea49c5d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vllm/model_executor/model_loader/weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import os
import tempfile
import time
from collections import defaultdict
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union

Expand All @@ -14,7 +15,7 @@
import huggingface_hub.constants
import numpy as np
import torch
from huggingface_hub import HfFileSystem, hf_hub_download, snapshot_download
from huggingface_hub import HfFileSystem, hf_hub_download, scan_cache_dir, snapshot_download

Check failure on line 18 in vllm/model_executor/model_loader/weight_utils.py

View workflow job for this annotation

GitHub Actions / pre-commit

Ruff (E501)

vllm/model_executor/model_loader/weight_utils.py:18:81: E501 Line too long (92 > 80)
from safetensors.torch import load_file, safe_open, save_file
from tqdm.auto import tqdm

Expand Down Expand Up @@ -253,6 +254,8 @@ def download_weights_from_hf(
# Use file lock to prevent multiple processes from
# downloading the same model weights at the same time.
with get_lock(model_name_or_path, cache_dir):
start_size = scan_cache_dir().size_on_disk
start_time = time.time()
hf_folder = snapshot_download(
model_name_or_path,
allow_patterns=allow_patterns,
Expand All @@ -262,6 +265,10 @@ def download_weights_from_hf(
revision=revision,
local_files_only=huggingface_hub.constants.HF_HUB_OFFLINE,
)
end_time = time.time()
end_size = scan_cache_dir().size_on_disk
if end_size != start_size:
logger.info("Time took to download weights for %s: %.6f seconds", model_name_or_path, end_time - start_time)
return hf_folder


Expand Down

0 comments on commit ea49c5d

Please sign in to comment.