Skip to content

Commit

Permalink
Remove correlation between the step size and the step direction (#2156)…
Browse files Browse the repository at this point in the history
… (#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
  • Loading branch information
zankin authored and facebook-github-bot committed May 10, 2024
1 parent faf8d8d commit 5c8b8ae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion botorch/utils/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ def sample_polytope(
# pre-sample samples from hypersphere
d = x0.size(0)
# uniform samples from unit ball in d dims
# increment seed by +1 to avoid correlation with step size, see #2156 for details
Rs = sample_hypersphere(
d=d, n=n_tot, dtype=A.dtype, device=A.device, seed=seed
d=d, n=n_tot, dtype=A.dtype, device=A.device, seed=seed + 1
).unsqueeze(-1)

# compute matprods in batch
Expand Down

0 comments on commit 5c8b8ae

Please sign in to comment.