Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add evaluate_oracle method to BenchmarkRunner #2705

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ax/benchmark/runners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ def get_Y_true(self, arm: Arm) -> Tensor:
"""
...

def evaluate_oracle(self, arm: Arm) -> Tensor:
"""
Evaluate oracle metric values at a parameterization. In the base class,
oracle=ground truth.
This method can be customized for more complex setups based on different
notions of what the "oracle" value should be. For example, in a
multi-task or multi-fidelity problem, it might be appropriate to
evaluate at the target task or fidelity. In a simple single-task
single-fidelity problem, this could the ground truth if available or the
"Y" value if the ground truth is not available. With a
preference-learned objective, the values might be true metrics evaluated
at the true utility function (which would be unobserved in reality).
"""
return self.get_Y_true(arm=arm)

@abstractmethod
def get_noise_stds(self) -> Union[None, float, dict[str, float]]:
"""
Expand Down
2 changes: 2 additions & 0 deletions ax/benchmark/tests/runners/test_botorch_test_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def test_synthetic_runner(self) -> None:
torch.Size([2]), X.pow(2).sum().item(), dtype=torch.double
)
self.assertTrue(torch.allclose(Y, expected_Y))
oracle = runner.evaluate_oracle(arm=arm)
self.assertTrue(torch.equal(Y, oracle))

with self.subTest(f"test `run()`, {test_description}"):
trial = Mock(spec=Trial)
Expand Down