-
Notifications
You must be signed in to change notification settings - Fork 52
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
Prepare for future batching #385
Prepare for future batching #385
Conversation
In the future certain utility functions will be "batched" utility functions which quantify the utility of querying a *batch* of points rather than a single point. These utility functions may in turn be optimised differently. Therefore, I propose we have a `SinglePointUtilityFunction` type for non-batched utility functions, which has type annotation `[N D] -> [N 1]`, and in the future we may add `BatchUtilityFunction` which has type annotation `[N B D] -> [N 1]`. Distinguishing between these makes it easy for users to see which utility functions support batching. Also refactored UtilityDrivenDecisionMaker to enable for Thompson sampling to be used in a batched context, and updated unit tests to reflect this. Finally, added a new notebook to serve as an introduction to the `decision_making` module.
Note that in general `SinglePointUtilityFunction`s are only capable of | ||
generating one point to be queried at each iteration of the decision making loop | ||
(i.e. `self.batch_size` must be 1). However, Thompson sampling can be used in a | ||
batched setting by drawing a batch of different samples from the GP posterior. | ||
This is done by calling `build_utility_function` with different keys | ||
sequentilly, and optimising each of these individual samples in sequence in | ||
order to obtain `self.batch_size` points to query next. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nice and clear
maximizers = jnp.concatenate(maximizers) | ||
return maximizers | ||
else: | ||
raise NotImplementedError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this keeps it tidy for now
maximizers = [] | ||
if isinstance(self.utility_function_builder, ThompsonSampling) or ( | ||
(not isinstance(self.utility_function_builder, ThompsonSampling)) | ||
and (self.batch_size == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this still not work with batch_size=1? This logic is a little tricky to understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's restricting batch size to be 1 for non-TS acquisition functions if someone happens to implement one for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. Maybe you can make the logic clearer so people like me dont get confused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
b225ecf
into
JaxGaussianProcesses:tchristie/bo
Type of changes
Checklist
poetry run pre-commit run --all-files --show-diff-on-failure
before committing.Description
In the future certain utility functions will be "batched" utility functions which quantify the utility of querying a batch of points rather than a single point. These utility functions may in turn be optimised differently.
Therefore, I propose we have a
SinglePointUtilityFunction
type for non-batched utility functions, which has type annotation[N D] -> [N 1]
, and in the future we may addBatchUtilityFunction
which has type annotation[N B D] -> [N 1]
. Distinguishing between these makes it easy for users to see which utility functions support batching.Also refactored UtilityDrivenDecisionMaker to enable for Thompson sampling to be used in a batched context, and updated unit tests to reflect this. Finally, added a new notebook to serve as an introduction to the
decision_making
module.Issue Number: N/A