Skip to content

Add _trial_type_to_metric_names to base Experiment (#5004)#5004

Open
mpolson64 wants to merge 2 commits intofacebook:mainfrom
mpolson64:export-D94970662
Open

Add _trial_type_to_metric_names to base Experiment (#5004)#5004
mpolson64 wants to merge 2 commits intofacebook:mainfrom
mpolson64:export-D94970662

Conversation

@mpolson64
Copy link
Contributor

@mpolson64 mpolson64 commented Mar 9, 2026

Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds _trial_type_to_metric_names: dict[str, set[str]] to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
_trial_type_to_runner dict. Along with it, adds the following
properties and methods to Experiment:

  • trial_type_to_metric_names: read-only property (shallow copy)
  • metric_to_trial_type: computed inverse mapping, with optimization
    config metrics pinned to default_trial_type
  • metrics_for_trial_type(trial_type): returns Metric objects for a
    given trial type
  • default_trials: returns trial indices matching the default type

MultiTypeExperiment is updated to populate _trial_type_to_metric_names
alongside _metric_to_trial_type in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for metric_to_trial_type,
metrics_for_trial_type, default_trials, and default_trial_type
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild _trial_type_to_metric_names
from _metric_to_trial_type during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662

@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Mar 9, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 9, 2026

@mpolson64 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94970662.

mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 11, 2026
Summary:
Pull Request resolved: facebook#5004

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Differential Revision: D94970662
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 13, 2026
Summary:
Pull Request resolved: facebook#5004

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Differential Revision: D94970662
@meta-codesync meta-codesync bot changed the title Add _trial_type_to_metric_names to base Experiment Add _trial_type_to_metric_names to base Experiment (#5004) Mar 13, 2026
@mpolson64 mpolson64 force-pushed the export-D94970662 branch 2 times, most recently from 71304a9 to 473ad24 Compare March 16, 2026 14:11
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 16, 2026
Summary:
Pull Request resolved: facebook#5004

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
…pter

Summary: D93520819 removed Metric instances from the OptimizationConfig which made it more verbose to get any individual Metric's signature, which we use for bookkeeping throughout the adapter stack. This diff ...

Differential Revision: D96855090
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 17, 2026
Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 17, 2026
Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 17, 2026
Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 17, 2026
Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 17, 2026
Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
Summary:
Pull Request resolved: facebook#5004

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
mpolson64 added a commit to mpolson64/Ax that referenced this pull request Mar 17, 2026
Summary:

This is Phase 1 of moving MultiTypeExperiment features into the base
Experiment class, enabling eventual deprecation of MultiTypeExperiment.

Adds `_trial_type_to_metric_names: dict[str, set[str]]` to Experiment —
a mapping from trial type to the set of metric names relevant to that
type. This is the natural complement to the existing
`_trial_type_to_runner` dict. Along with it, adds the following
properties and methods to Experiment:

- `trial_type_to_metric_names`: read-only property (shallow copy)
- `metric_to_trial_type`: computed inverse mapping, with optimization
  config metrics pinned to `default_trial_type`
- `metrics_for_trial_type(trial_type)`: returns Metric objects for a
  given trial type
- `default_trials`: returns trial indices matching the default type

MultiTypeExperiment is updated to populate `_trial_type_to_metric_names`
alongside `_metric_to_trial_type` in all mutation paths (init,
optimization_config setter, add/update/remove tracking metric). The
redundant MTE overrides for `metric_to_trial_type`,
`metrics_for_trial_type`, `default_trials`, and `default_trial_type`
are removed — they are now inherited from the base class.

The JSON decoder is updated to rebuild `_trial_type_to_metric_names`
from `_metric_to_trial_type` during deserialization for backward
compatibility.

Reviewed By: lena-kashtelyan

Differential Revision: D94970662
@mpolson64 mpolson64 force-pushed the export-D94970662 branch 2 times, most recently from e7b4c20 to b4386fa Compare March 17, 2026 14:59
@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 95.29412% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.75%. Comparing base (d016302) to head (b4386fa).
⚠️ Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
ax/adapter/torch.py 50.00% 2 Missing ⚠️
ax/core/experiment.py 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5004      +/-   ##
==========================================
- Coverage   96.75%   96.75%   -0.01%     
==========================================
  Files         606      606              
  Lines       66152    66179      +27     
==========================================
+ Hits        64007    64032      +25     
- Misses       2145     2147       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants