Skip to content

Commit 5c8b8ae

Browse files
zankinfacebook-github-bot
authored andcommitted
Remove correlation between the step size and the step direction (#2156) (#2290)
Summary: <!-- Thank you for sending the PR! We appreciate you spending the time to make BoTorch better. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to BoTorch here: https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md --> ## Motivation This is a quick fix of #2156. In the ```botorch.utils.sampling.sample_polytope()```, both the step size ```rands``` and direction ```Rs``` are currently sampled using the same seed value. This can lead to strong correlation and induce sampling bias, particularly with a small number of steps (e.g., ```n=1```), as illustrated in #2156. Adding ```+1``` to the seed value for ```Rs``` helps to avoid such behaviour. ### Have you read the [Contributing Guidelines on pull requests](https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md#pull-requests)? Yes. Pull Request resolved: #2290 Test Plan: Not sure if any unit tests needed for that change. Reviewed By: esantorella Differential Revision: D57208858 Pulled By: Balandat fbshipit-source-id: 0653e751f4351a8f9ad2cf2625c93a3a5de7de63
1 parent faf8d8d commit 5c8b8ae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

botorch/utils/sampling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ def sample_polytope(
249249
# pre-sample samples from hypersphere
250250
d = x0.size(0)
251251
# uniform samples from unit ball in d dims
252+
# increment seed by +1 to avoid correlation with step size, see #2156 for details
252253
Rs = sample_hypersphere(
253-
d=d, n=n_tot, dtype=A.dtype, device=A.device, seed=seed
254+
d=d, n=n_tot, dtype=A.dtype, device=A.device, seed=seed + 1
254255
).unsqueeze(-1)
255256

256257
# compute matprods in batch

0 commit comments

Comments
 (0)