-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #2632 Adding AuxiliaryExperiment to allow for experiments and models to use other experiments as auxiliary information during optimization Meta: Design doc https://docs.google.com/document/d/1MYq4WHPDLoWp-RUyk7jXiqswKARtyoSeM68PRayPGUk/edit?usp=sharing Reviewed By: saitcakmak, mgarrard, lena-kashtelyan Differential Revision: D60192602
- Loading branch information
1 parent
15bb8a0
commit 9975af5
Showing
8 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Optional, TYPE_CHECKING | ||
|
||
from ax.core.data import Data | ||
from ax.utils.common.base import SortableBase | ||
|
||
|
||
if TYPE_CHECKING: | ||
# import as module to make sphinx-autodoc-typehints happy | ||
from ax import core # noqa F401 | ||
|
||
|
||
class AuxiliaryExperiment(SortableBase): | ||
"""Class for defining an auxiliary experiment.""" | ||
|
||
def __init__( | ||
self, | ||
experiment: core.experiment.Experiment, | ||
data: Optional[Data] = None, | ||
) -> None: | ||
""" | ||
Lightweight container of an experiment, and its data, | ||
that will be used as auxiliary information for another experiment. | ||
""" | ||
self.experiment = experiment | ||
self.data: Data = data or experiment.lookup_data() | ||
|
||
def _unique_id(self) -> str: | ||
# While there can be multiple `AuxiliarySource`-s made from the same | ||
# experiment (and thus sharing the experiment name), the uniqueness | ||
# here is only needed w.r.t. parent object ("main experiment", for which | ||
# this will be an auxiliary source for). | ||
return self.experiment.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
from ax.core.auxiliary import AuxiliaryExperiment | ||
from ax.utils.common.testutils import TestCase | ||
from ax.utils.testing.core_stubs import get_experiment, get_experiment_with_data | ||
|
||
|
||
class AuxiliaryExperimentTest(TestCase): | ||
def test_AuxiliaryExperiment(self) -> None: | ||
for get_exp_func in [get_experiment, get_experiment_with_data]: | ||
exp = get_exp_func() | ||
data = exp.lookup_data() | ||
|
||
# Test init | ||
aux_exp = AuxiliaryExperiment(experiment=exp) | ||
self.assertEqual(aux_exp.experiment, exp) | ||
self.assertEqual(aux_exp.data, data) | ||
|
||
aux_exp = AuxiliaryExperiment(experiment=exp, data=exp.lookup_data()) | ||
self.assertEqual(aux_exp.experiment, exp) | ||
self.assertEqual(aux_exp.data, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters