Skip to content

Commit

Permalink
also cap pool sizes with max_workers
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz committed Feb 26, 2025
1 parent 98a7454 commit e5efe41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion garak/generators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ def generate(
)
multi_generator_bar.set_description(self.fullname[:55])

pool_size = min(generations_this_call, _config.system.parallel_requests)
pool_size = min(
generations_this_call,
_config.system.parallel_requests,
_config.system.max_workers,
)

try:
with Pool(pool_size) as pool:
Expand Down
6 changes: 5 additions & 1 deletion garak/probes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ def _execute_all(self, attempts) -> Iterable[garak.attempt.Attempt]:
attempt_bar = tqdm.tqdm(total=len(attempts), leave=False)
attempt_bar.set_description(self.probename.replace("garak.", ""))

pool_size = min(_config.system.parallel_attempts, len(attempts))
pool_size = min(
len(attempts),
_config.system.parallel_attempts,
_config.system.max_workers,
)

try:
with Pool(pool_size) as attempt_pool:
Expand Down

0 comments on commit e5efe41

Please sign in to comment.