Skip to content

Commit 340ac8a

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Minor tweak to MARS.set_baseline_Y to reduce memory overhead (#1346)
Summary: Pull Request resolved: #1346 Unsqueeze before evaluating `model.posterior` in `MARS.set_baseline_Y` to avoid creating large matrices. This helps reduce the memory overhead with large models and helps avoid OOMs. Reviewed By: Balandat Differential Revision: D38648419 fbshipit-source-id: c4bd5646e53625f640f545b9a33979d8458c885a
1 parent 7370224 commit 340ac8a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

botorch/acquisition/multi_objective/multi_output_risk_measures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def forward(self, samples: Tensor, X: Optional[Tensor] = None) -> Tensor:
505505
if self.expectation:
506506
padded_mvar_list.append(mvar_.mean(dim=0))
507507
else:
508-
# Repeat the last entry to make `mvar_set` `n_w x m`.
508+
# Repeat the last entry to make `mvar_set` `pad_size x m`.
509509
repeats_needed = pad_size - mvar_.shape[0]
510510
padded_mvar_list.append(
511511
torch.cat([mvar_, mvar_[-1].expand(repeats_needed, m)], dim=0)
@@ -578,7 +578,7 @@ def set_baseline_Y(self, model: Model, X_baseline: Tensor) -> None:
578578
X_baseline: An `n x d`-dim tensor of previously evaluated points.
579579
"""
580580
with torch.no_grad():
581-
Y = model.posterior(X_baseline).mean
581+
Y = model.posterior(X_baseline.unsqueeze(-2)).mean.squeeze(-2)
582582
Y = self.preprocessing_function(Y)
583583
Y = self.mvar(Y).view(-1, Y.shape[-1])
584584
Y = Y[is_non_dominated(Y)]

0 commit comments

Comments
 (0)