Skip to content

Commit 7d04765

Browse files
committed
Don't spawn more workers than max_concurrency
1 parent 7bfc8a2 commit 7d04765

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/guidellm/scheduler/worker_group.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,6 @@ async def create_processes(self):
120120
:raises RuntimeError: If process initialization or startup fails.
121121
"""
122122
# Processes limits and params
123-
num_processes = int(
124-
min(
125-
self.strategy.processes_limit or math.inf,
126-
self.backend.processes_limit or math.inf,
127-
settings.max_worker_processes,
128-
)
129-
)
130-
if num_processes <= 0:
131-
raise RuntimeError("num_processes resolved to 0; increase limits/config")
132123

133124
max_conc = int(
134125
min(
@@ -140,6 +131,18 @@ async def create_processes(self):
140131
if max_conc <= 0:
141132
raise RuntimeError("max_concurrency resolved to 0; increase limits/config")
142133

134+
num_processes = int(
135+
min(
136+
self.strategy.processes_limit or math.inf,
137+
self.backend.processes_limit or math.inf,
138+
settings.max_worker_processes,
139+
# Only spawn as many processes as we need for max_concurrency
140+
max_conc,
141+
)
142+
)
143+
if num_processes <= 0:
144+
raise RuntimeError("num_processes resolved to 0; increase limits/config")
145+
143146
per_proc_max_conc = math.ceil(max_conc / num_processes)
144147
per_proc_max_queue = min(2, per_proc_max_conc)
145148
max_queued_requests = ( # Add queue buffer for each process

0 commit comments

Comments
 (0)