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 an option to pass model_cv_kwargs to ModelSpec.cross_validate #2566

Closed
wants to merge 4 commits into from

Conversation

saitcakmak
Copy link
Contributor

Summary:
This allows us to customize the kwargs passed to cross_validate during call time (in addition to ModelSpec.model_cv_kwargs, which is specified at initialization). This can be used in SingleDiagnosticBestModelSelector to customize how the CV diagnostics are computed.

To ensure we don't return cached results that were computed using different kwargs, we also store the last cv_kwargs used and re-compute CV if they changed.

Differential Revision: D59406177

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

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

saitcakmak added a commit to saitcakmak/Ax that referenced this pull request Jul 5, 2024
…cebook#2566)

Summary:
Pull Request resolved: facebook#2566

This allows us to customize the kwargs passed to `cross_validate` during call time (in addition to `ModelSpec.model_cv_kwargs`, which is specified at initialization). This can be used in `SingleDiagnosticBestModelSelector` to customize how the CV diagnostics are computed.

To ensure we don't return cached results that were computed using different kwargs, we also store the last `cv_kwargs` used and re-compute CV if they changed.

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

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

saitcakmak added a commit to saitcakmak/Ax that referenced this pull request Jul 5, 2024
…cebook#2566)

Summary:
Pull Request resolved: facebook#2566

This allows us to customize the kwargs passed to `cross_validate` during call time (in addition to `ModelSpec.model_cv_kwargs`, which is specified at initialization). This can be used in `SingleDiagnosticBestModelSelector` to customize how the CV diagnostics are computed.

To ensure we don't return cached results that were computed using different kwargs, we also store the last `cv_kwargs` used and re-compute CV if they changed.

Differential Revision: D59406177
@codecov-commenter
Copy link

codecov-commenter commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.22%. Comparing base (f6bf1c6) to head (8e86ddc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2566   +/-   ##
=======================================
  Coverage   95.21%   95.22%           
=======================================
  Files         487      489    +2     
  Lines       47582    47630   +48     
=======================================
+ Hits        45307    45356   +49     
+ Misses       2275     2274    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

saitcakmak and others added 4 commits July 9, 2024 11:15
Summary:
Pull Request resolved: facebook#2557

`BestModelSelector` was previously limited to selecting the best out of a given dictionary of CV diagnostics that were computed in `ModelSpec.cross_validate`. This setup limited extensibility, since any change would require updating `ModelSpec` code to the diagnostics that are computed.

This diff refactors `BestModelSelector` to directly operate on the `ModelSpecs`. This new modular design will let each `BestModelSelector` class compute the necessary diagnostics internally, without locking us up to any pre-specified list.

Other minor changes:
- Removed `CallableEnum` and subclasses and replaced these with a single `ReductionCriterion` enum.
- Split off `BestModelSelector` into a separate file to avoid circular imports.

Differential Revision: D59249657
Summary:
Pull Request resolved: facebook#2561

Context: BestModelSelector is used to pick the model to gen from in GNode with multiple ModelSpecs.

This diff adds storage support for the BestModelSelector, making it possible to serialize & deserialize GenerationNodes with multiple ModelSpecs & a BestModelSelector.

Differential Revision: D59355084

Reviewed By: Balandat
Summary:
Pull Request resolved: facebook#2565

These were typed as `Optional[Dict[str, Any]]` but immediately made into `Dict[str, Any]` in `__post_init__`. The internal usage also included a bunch of `self.*_kwargs or {}`, presumably to make Pyre happy with the optional field.

This diff updates the type-hints to `Dict[str, Any]` and keeps these arguments as optional during initialization using `field(default_factory=dict)` as the default (which will assign an empty dict as the default). The change is also extended to `GenerationStep`.

I kept the `__post_init__` method in place to keep backwards compatibility with any previous usage of `None`.

Differential Revision: D59403745

Reviewed By: Balandat
…cebook#2566)

Summary:
Pull Request resolved: facebook#2566

This allows us to customize the kwargs passed to `cross_validate` during call time (in addition to `ModelSpec.model_cv_kwargs`, which is specified at initialization). This can be used in `SingleDiagnosticBestModelSelector` to customize how the CV diagnostics are computed.

To ensure we don't return cached results that were computed using different kwargs, we also store the last `cv_kwargs` used and re-compute CV if they changed.

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

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

saitcakmak added a commit to saitcakmak/Ax that referenced this pull request Jul 9, 2024
…cebook#2566)

Summary:
Pull Request resolved: facebook#2566

This allows us to customize the kwargs passed to `cross_validate` during call time (in addition to `ModelSpec.model_cv_kwargs`, which is specified at initialization). This can be used in `SingleDiagnosticBestModelSelector` to customize how the CV diagnostics are computed.

To ensure we don't return cached results that were computed using different kwargs, we also store the last `cv_kwargs` used and re-compute CV if they changed.

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

This pull request has been merged in faf25c4.

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.

3 participants