Skip to content

Commit df65dec

Browse files
sufubaohiworldwzj
andauthored
[Misc] Add a progress bar when loading the model (#1008)
<img width="937" height="18" alt="image" src="https://github.com/user-attachments/assets/5bc4e103-bf3f-44b1-9618-4367d0acccaf" /> --------- Co-authored-by: hiworldwzj <30762946+hiworldwzj@users.noreply.github.com>
1 parent 81b9ecb commit df65dec

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lightllm/common/basemodel/layer_weights/hf_load_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import gc
44
from safetensors import safe_open
5+
from tqdm import tqdm
56
import lightllm.utils.petrel_helper as utils
67
from lightllm.utils.dist_utils import get_current_device_id
78

@@ -61,6 +62,11 @@ def load_hf_weights(data_type, weight_dir, pre_post_layer=None, transformer_laye
6162
) # noqa
6263
worker = int(os.environ.get("LOADWORKER", 1))
6364
with Pool(worker) as p:
64-
_ = p.map(partial_func, candidate_files)
65+
iterator = p.imap_unordered(partial_func, candidate_files, chunksize=1)
66+
desc_str = f"pid {os.getpid()} Loading model weights with {worker} workers"
67+
iterator = tqdm(iterator, total=len(candidate_files), desc=desc_str)
68+
69+
for _ in iterator:
70+
pass
6571

6672
return

0 commit comments

Comments
 (0)