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

Changes to Adapter constructors, require experiment #3415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saitcakmak
Copy link
Contributor

Summary:
The motivation for this change is to bring us closer to relying on the experiment as the source of truth about the experiment state & attributes within the modeling layer. We currently support many inputs that are extracted from the experiment, just to be passed in alongside it. By making experiment a required input, we open the possibility of removing these extra inputs and extracting them directly from experiment where they're needed.

Makes the following changes to Adapter constructors:

  • Requires keyword-only arguments. Positional inputs are no-longer supported.
  • Makes experiment required and search_space optional.
  • Re-orders inputs for consistency across sub-classes.

In addition:

  • Removes model input to Adapter._fit. This is a private method that is only called through fit_if_implemented (with self.model). Accepting multiple inputs for the same argument only makes the code harder to reason about.
  • Removes class level attributes, some of which weren't initialized in __init__, leading to pyre complaints. All attributes are now initialized in __init__. This also eliminates misleading "optional" type hints with None default for model, which is never None in practice.
  • Removes Adapter.update, which has been deprecated for quite some time.
  • Initializing a Generator from registry with only search_space is being deprecated. It is temporarily supported using a dummy experiment for random & discrete adapters, which previously did not require an experiment.

Differential Revision: D70103442

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

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

@facebook-github-bot
Copy link
Contributor

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

saitcakmak added a commit to saitcakmak/Ax that referenced this pull request Feb 25, 2025
Summary:
Pull Request resolved: facebook#3415

The motivation for this change is to bring us closer to relying on the `experiment` as the source of truth about the experiment state & attributes within the modeling layer. We currently support many inputs that are extracted from the `experiment`, just to be passed in alongside it. By making `experiment` a required input, we open the possibility of removing these extra inputs and extracting them directly from `experiment` where they're needed.

Makes the following changes to Adapter constructors:
- Requires keyword-only arguments. Positional inputs are no-longer supported.
- Makes `experiment` required and `search_space` optional.
- Re-orders inputs for consistency across sub-classes.

In addition:
- Removes `model` input to `Adapter._fit`. This is a private method that is only called through `fit_if_implemented` (with `self.model`). Accepting multiple inputs for the same argument only makes the code harder to reason about.
- Removes class level attributes, some of which weren't initialized in `__init__`, leading to pyre complaints. All attributes are now initialized in `__init__`. This also eliminates misleading "optional" type hints with `None` default for `model`, which is never `None` in practice.
- Removes `Adapter.update`, which has been deprecated for quite some time.
- Initializing a Generator from registry with only `search_space` is being deprecated. It is temporarily supported using a dummy experiment for random & discrete adapters, which previously did not require an `experiment`.

Differential Revision: D70103442
saitcakmak added a commit to saitcakmak/Ax that referenced this pull request Feb 25, 2025
Summary:

The motivation for this change is to bring us closer to relying on the `experiment` as the source of truth about the experiment state & attributes within the modeling layer. We currently support many inputs that are extracted from the `experiment`, just to be passed in alongside it. By making `experiment` a required input, we open the possibility of removing these extra inputs and extracting them directly from `experiment` where they're needed.

Makes the following changes to Adapter constructors:
- Requires keyword-only arguments. Positional inputs are no-longer supported.
- Makes `experiment` required and `search_space` optional.
- Re-orders inputs for consistency across sub-classes.

In addition:
- Removes `model` input to `Adapter._fit`. This is a private method that is only called through `fit_if_implemented` (with `self.model`). Accepting multiple inputs for the same argument only makes the code harder to reason about.
- Removes class level attributes, some of which weren't initialized in `__init__`, leading to pyre complaints. All attributes are now initialized in `__init__`. This also eliminates misleading "optional" type hints with `None` default for `model`, which is never `None` in practice.
- Removes `Adapter.update`, which has been deprecated for quite some time.
- Initializing a Generator from registry with only `search_space` is being deprecated. It is temporarily supported using a dummy experiment for random & discrete adapters, which previously did not require an `experiment`.

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

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

Summary:

The motivation for this change is to bring us closer to relying on the `experiment` as the source of truth about the experiment state & attributes within the modeling layer. We currently support many inputs that are extracted from the `experiment`, just to be passed in alongside it. By making `experiment` a required input, we open the possibility of removing these extra inputs and extracting them directly from `experiment` where they're needed.

Makes the following changes to Adapter constructors:
- Requires keyword-only arguments. Positional inputs are no-longer supported.
- Makes `experiment` required and `search_space` optional.
- Re-orders inputs for consistency across sub-classes.

In addition:
- Removes `model` input to `Adapter._fit`. This is a private method that is only called through `fit_if_implemented` (with `self.model`). Accepting multiple inputs for the same argument only makes the code harder to reason about.
- Removes class level attributes, some of which weren't initialized in `__init__`, leading to pyre complaints. All attributes are now initialized in `__init__`. This also eliminates misleading "optional" type hints with `None` default for `model`, which is never `None` in practice.
- Removes `Adapter.update`, which has been deprecated for quite some time.
- Initializing a Generator from registry with only `search_space` is being deprecated. It is temporarily supported using a dummy experiment for random & discrete adapters, which previously did not require an `experiment`.

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

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

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 98.34437% with 5 lines in your changes missing coverage. Please review.

Project coverage is 95.99%. Comparing base (625f8f6) to head (6445681).

Files with missing lines Patch % Lines
ax/modelbridge/tests/test_factory.py 71.42% 2 Missing ⚠️
ax/modelbridge/base.py 91.66% 1 Missing ⚠️
ax/modelbridge/registry.py 90.00% 1 Missing ⚠️
ax/plot/tests/test_feature_importances.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3415      +/-   ##
==========================================
- Coverage   95.99%   95.99%   -0.01%     
==========================================
  Files         539      539              
  Lines       52794    52800       +6     
==========================================
+ Hits        50679    50683       +4     
- Misses       2115     2117       +2     

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

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants