Skip to content

Commit c592798

Browse files
authored
fix: limit process pool size when prefetching (NVIDIA#5088)
Signed-off-by: Zheng Duan <[email protected]>
1 parent ee44fa0 commit c592798

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tensorrt_llm/_torch/pyexecutor/model_engine.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ def prefetch_files(file_names: List[str]):
155155
# Find out the files to prefetch for the current rank.
156156
# Each rank loads files with indices local_rank, local_rank + local_mpi_size, local_rank + 2*local_mpi_size, etc.
157157
local_file_names = file_names[local_mpi_rank()::local_mpi_size()]
158+
if len(local_file_names) == 0:
159+
return
158160

159-
max_processes = min(multiprocessing.cpu_count() * 2, 16)
161+
max_processes = min(multiprocessing.cpu_count() * 2, 16,
162+
len(local_file_names))
160163
with multiprocessing.Pool(processes=max_processes) as pool:
161164
pool.map(_prefetch_one_file, local_file_names)
162165

0 commit comments

Comments
 (0)