Skip to content

Commit 76436bc

Browse files
sufubaoClaude Code
authored andcommitted
fix
1 parent 605ac34 commit 76436bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lightllm/common/basemodel/layer_weights/hf_load_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def load_hf_weights(data_type, weight_dir, pre_post_layer=None, transformer_laye
5151
candidate_files = list(filter(lambda x: x.endswith(".bin"), files))
5252
assert len(candidate_files) != 0, "can only support pytorch tensor and safetensors format for weights."
5353
from functools import partial
54+
from multiprocessing import cpu_count
5455
from multiprocessing.pool import ThreadPool as Pool
5556

5657
partial_func = partial(
@@ -60,7 +61,7 @@ def load_hf_weights(data_type, weight_dir, pre_post_layer=None, transformer_laye
6061
transformer_layer_list=transformer_layer_list,
6162
weight_dir=weight_dir,
6263
) # noqa
63-
worker = int(os.environ.get("LOADWORKER", 1))
64+
worker = min(24, cpu_count())
6465
with Pool(worker) as p:
6566
iterator = p.imap_unordered(partial_func, candidate_files, chunksize=1)
6667
desc_str = f"pid {os.getpid()} Loading model weights with {worker} workers"

0 commit comments

Comments
 (0)