Skip to content

Commit

Permalink
set num_processes=1 in MAB test (facebookresearch#602)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebookresearch#602

Attempt to fix the test timing out on CircleCI

Differential Revision: D33900623

fbshipit-source-id: ef9bb3a44ea726df9ba3e82a94fa8467704abe0a
  • Loading branch information
alexnikulkov authored and facebook-github-bot committed Jan 31, 2022
1 parent 09e36a9 commit 3739292
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
24 changes: 17 additions & 7 deletions reagent/mab/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,25 @@ def multiple_evaluations_bandit_algo(
)
for _ in range(n_bandits)
)
with Pool(num_processes) as pool:
pseudo_regrets = pool.starmap(
partial(
single_evaluation_bandit_algo,
if num_processes == 1:
pseudo_regrets = [
single_evaluation_bandit_algo(
*a,
update_every=update_every,
freeze_scores_btw_updates=freeze_scores_btw_updates,
),
arguments,
)
)
for a in arguments
]
else:
with Pool(num_processes) as pool:
pseudo_regrets = pool.starmap(
partial(
single_evaluation_bandit_algo,
update_every=update_every,
freeze_scores_btw_updates=freeze_scores_btw_updates,
),
arguments,
)
return np.stack(pseudo_regrets).mean(0)


Expand Down
1 change: 1 addition & 0 deletions reagent/test/mab/test_mab.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def test_multiple_evaluations_bandit_algo(self):
max_steps=max_steps,
algo_kwargs={"n_arms": 2},
bandit_kwargs={"probs": torch.Tensor([0.3, 0.5])},
num_processes=1,
)

self.assertIsInstance(regret_trajectory, np.ndarray)
Expand Down

0 comments on commit 3739292

Please sign in to comment.