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

Use regular inheritance instead of dispatcher to special-case PairwiseGP logic #2176

Closed
wants to merge 1 commit into from

Conversation

esantorella
Copy link
Member

Summary:

  • Replace dispatcher with inheritance: Model.construct_inputs calls a dispatcher, parse_training_data, that dispatches to one function if the Model is a PairwiseGP and the dataset is a RankingDataset and another for the general case of a Model and SupervisedDataset. This can be achieved with inheritance, putting the general case in Model and special case for PairwiseGP in PairwiseGP.construct_inputs. This allows the parse_training_data dispatcher to be removed.
  • Error for using an input that is not a RankingDataset to PairwiseGP.construct_inputs: Previously, if PairwiseGP.construct_inputs was called with a dataset that was not a RankingDataset, it would fall back to the general behavior for Model.construct_inputs, producing inputs that are not valid for PairwiseGP. This now produces an error.

Reviewed By: saitcakmak

Differential Revision: D53011931

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 23, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53011931

esantorella added a commit to esantorella/botorch that referenced this pull request Jan 23, 2024
…eGP logic (pytorch#2176)

Summary:

* Replace dispatcher with inheritance: `Model.construct_inputs` calls a dispatcher, `parse_training_data`, that dispatches to one function if the Model is a PairwiseGP and the dataset is a RankingDataset and another for the general case of a Model and SupervisedDataset. This can be achieved with inheritance, putting the general case in Model and special case for PairwiseGP in PairwiseGP.construct_inputs. This allows the `parse_training_data` dispatcher to be removed.
* Error for using an input that is not a `RankingDataset` to `PairwiseGP.construct_inputs`: Previously, if `PairwiseGP.construct_inputs` was called with a dataset that was not a `RankingDataset`, it would fall back to the general behavior for `Model.construct_inputs`, producing inputs that are not valid for `PairwiseGP`. This now produces an error.

Reviewed By: saitcakmak

Differential Revision: D53011931
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53011931

…eGP logic (pytorch#2176)

Summary:

* Replace dispatcher with inheritance: `Model.construct_inputs` calls a dispatcher, `parse_training_data`, that dispatches to one function if the Model is a PairwiseGP and the dataset is a RankingDataset and another for the general case of a Model and SupervisedDataset. This can be achieved with inheritance, putting the general case in Model and special case for PairwiseGP in PairwiseGP.construct_inputs. This allows the `parse_training_data` dispatcher to be removed.
* Error for using an input that is not a `RankingDataset` to `PairwiseGP.construct_inputs`: Previously, if `PairwiseGP.construct_inputs` was called with a dataset that was not a `RankingDataset`, it would fall back to the general behavior for `Model.construct_inputs`, producing inputs that are not valid for `PairwiseGP`. This now produces an error.

Reviewed By: saitcakmak

Differential Revision: D53011931
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53011931

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6a66c79.

stefanpricopie pushed a commit to stefanpricopie/botorch that referenced this pull request Feb 27, 2024
…eGP logic (pytorch#2176)

Summary:
Pull Request resolved: pytorch#2176

* Replace dispatcher with inheritance: `Model.construct_inputs` calls a dispatcher, `parse_training_data`, that dispatches to one function if the Model is a PairwiseGP and the dataset is a RankingDataset and another for the general case of a Model and SupervisedDataset. This can be achieved with inheritance, putting the general case in Model and special case for PairwiseGP in PairwiseGP.construct_inputs. This allows the `parse_training_data` dispatcher to be removed.
* Error for using an input that is not a `RankingDataset` to `PairwiseGP.construct_inputs`: Previously, if `PairwiseGP.construct_inputs` was called with a dataset that was not a `RankingDataset`, it would fall back to the general behavior for `Model.construct_inputs`, producing inputs that are not valid for `PairwiseGP`. This now produces an error.

Reviewed By: saitcakmak

Differential Revision: D53011931

fbshipit-source-id: d697df3fffeaa5c9213a52a1dd39afd3b7a0ee25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants