Repository navigation
Support Multi-Objective Optimization GPSampler - #6069
Conversation
GPSampler
|
@kAIto47802 @HideakiImamura Could you review this PR? |
HideakiImamura
left a comment
There was a problem hiding this comment.
Thank you for the PR. I have several comments. Could you take a look?
| size = min(self._n_local_search // 2, n_pareto_sols) | ||
| chosen_indices = self._rng.rng.choice( | ||
| np.arange(n_pareto_sols), size=size, replace=False | ||
| ) |
There was a problem hiding this comment.
If the solution on the Pareto-front is large enough, you randomly select n_local_search // 2 solutions from it as best_params. Is there any reference for this selection?
There was a problem hiding this comment.
No, this is a heuristic inspired from the single-objective optimization by GPSampler.
We can also follow the BoTorch convention if necessary.
There was a problem hiding this comment.
I see. This raises a performance concern. In multi-objective optimization, unlike single-objective optimization, there are multiple Pareto-optimal solutions to reach (and in many cases, there are infinitely many). Therefore, we should ideally start from multiple points for each of these infinitely many Pareto solutions. Of course, that is not feasible, but at the very least, shouldn’t we be optimizing the acquisition function toward Pareto solutions using a larger number of initial points compared to single-objective optimization? I suspect that this might be the reason for the performance difference compared to BoTorch. How does BoTorch handle this?
There was a problem hiding this comment.
Could you check this comment?
There was a problem hiding this comment.
Although BoTorch itself does not have a fixed parameter for the number of local searches, BoTorchSampler does have it.
- Number of local search: 20 (BoTorchSampler) vs 10 (GPSampler)
I would like you to refer to this comment for more details:
|
I documented the differences between
Note The default configuration of the logEHVI in BoTorch is available here. I personally believe that the performance degradation may happen due to the difference in the kernel hyperparameter prior. Note that the fatplus things are discussed in this paper. More specifically, this requires some changes here: Lines 53 to 60 in 5efa634 # log_smooth_relu and smooth_minimum must be implemented.
# cf. https://github.com/pytorch/botorch/blob/v0.13.0/botorch/utils/safe_math.py
# cf. https://github.com/pytorch/botorch/blob/v0.13.0/botorch/acquisition/multi_objective/logei.py
# smooth_minimum could be torch.minimum as well.
log_diff = smooth_minimum(
log_smooth_relu(Y_post[..., torch.newaxis, :] - non_dominated_box_lower_bounds),
(non_dominated_box_upper_bounds - non_dominated_box_lower_bounds).log()
)
return torch.special.logsumexp(log_diff.sum(dim=-1), dim=(-2, -1)) - log_n_qmc_sampleslog_smooth_relufrom torch.nn.functional import softplus
def log_smooth_relu(x: torch.Tensor) -> torch.Tensor:
# tau = 1e-6 is the default value in BoTorch.
# https://github.com/pytorch/botorch/blob/v0.13.0/botorch/acquisition/multi_objective/logei.py#L301
tau = 1e-6
# alpha = 1e-1 is the default value in BoTorch.
# https://github.com/pytorch/botorch/blob/v0.14.0/botorch/utils/safe_math.py#L297
alpha = 1e-1
z = x / tau
return tau * (alpha / (1.0 + z**2) + softplus(z))fat minimum/maximumimport torch
def fatmax(x: torch.Tensor, dim: int, tau: float) -> torch.Tensor:
max_val = x.amax(dim=dim, keepdim=True)
diff = x - max_val
diff = diff.masked_fill(diff.isnan(), 0.0)
z = -diff / tau
return max_val.squeeze(dim) + tau * (1.0 / (1.0 + z + 0.5 * z**2)).sum(dim=dim).log()
def fatmin(x: torch.Tensor, dim: int, tau: float) -> torch.Tensor:
min_val = x.amin(dim=dim, keepdim=True)
diff = min_val - x
diff = diff.masked_fill(diff.isnan(), 0.0)
z = -diff / tau
return min_val.squeeze(dim) - tau * (1.0 / (1.0 + z + 0.5 * z**2)).sum(dim=dim).log()
def fatmaximum(a: torch.Tensor, b: torch.Tensor, tau: float) -> torch.Tensor:
return fatmax(torch.stack(torch.broadcast_tensors(a, b), dim=-1), dim=-1, tau=tau)
def fatminimum(a: torch.Tensor, b: torch.Tensor, tau: float) -> torch.Tensor:
return fatmin(torch.stack(torch.broadcast_tensors(a, b), dim=-1), dim=-1, tau=tau) |
HideakiImamura
left a comment
There was a problem hiding this comment.
Thanks for the update. Basically, LGTM. I have some additional comments. PTAL.
| size = min(self._n_local_search // 2, n_pareto_sols) | ||
| chosen_indices = self._rng.rng.choice( | ||
| np.arange(n_pareto_sols), size=size, replace=False | ||
| ) |
There was a problem hiding this comment.
Could you check this comment?
Co-authored-by: kAIto47802 <[email protected]>
Co-authored-by: kAIto47802 <[email protected]>
Co-authored-by: kAIto47802 <[email protected]>
|
I responded to your comment: For now, I left a comment here: We can surely discuss what parameters to use in another PR! |
Co-authored-by: kAIto47802 <[email protected]>
| qmc_seed=self._rng.rng.randint(1 << 30), | ||
| ) | ||
| pareto_params = normalized_params[ | ||
| _is_pareto_front(-standardized_score_vals, assume_unique_lexsorted=False) |
There was a problem hiding this comment.
Since the sign has changed in 81e7e8e and the choice has changed from the worst one to the best one, the benchmarking results might become different.
There was a problem hiding this comment.
Yeap, you are right. I will work on it at another time!
Co-authored-by: kAIto47802 <[email protected]>
|
Other than these, The prior for the kernel hyperparameters is different from BoTorch, whose prior follows this paper. |
|
Note Memo for future development. Talking about this concern, we can discuss it by checking how much acquisition function value we get at each Pareto solution. |
Motivation
This PR adds the multi-objective GPSampler as a followup of these PRs:
AcquisitionFuncParamsfor LogEHVI #6052Description of the changes