Add fit_tracking_metrics option to configure_generation_strategy (#5238)#5238
Closed
saitcakmak wants to merge 1 commit into
Closed
Add fit_tracking_metrics option to configure_generation_strategy (#5238)#5238saitcakmak wants to merge 1 commit into
saitcakmak wants to merge 1 commit into
Conversation
|
@saitcakmak has imported this pull request. If you are a Meta employee, you can view this in D109735998. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5238 +/- ##
=======================================
Coverage 96.56% 96.57%
=======================================
Files 619 619
Lines 70273 70296 +23
=======================================
+ Hits 67861 67889 +28
+ Misses 2412 2407 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ebook#5238) Summary: Implements the feature requested in facebook#4688: a `fit_tracking_metrics` option on the high-level `Client.configure_generation_strategy` API, so users can disable modeling of tracking metrics without manually editing the generation strategy. ```python client.configure_generation_strategy(fit_tracking_metrics=False) ``` When `False`, only metrics in the optimization config (objectives and outcome constraints) are modeled. Tracking metrics are still recorded but not modeled by the BoTorch model — useful when many tracking metrics are kept only for book-keeping. ## Changes - **`ax/api/client.py`** — added `fit_tracking_metrics: bool = True` to `configure_generation_strategy` and `_choose_generation_strategy`, threading it into the dispatch struct. Docstrings flag that **when `False`, model-dependent analyses (cross-validation, sensitivity analysis, etc.) will not be produced for tracking metrics**, that it requires an optimization config, and that it has no effect for `random_search`. - **`ax/api/utils/structs.py`** — added the `fit_tracking_metrics` field to `GenerationStrategyDispatchStruct`. - **`ax/api/utils/generation_strategy_dispatch.py`** — `_get_mbm_node` injects `fit_tracking_metrics` into the MBM node's `generator_kwargs`; only the MBM node receives it (Sobol/random-search nodes don't model outcomes). - **Tests** — added `test_gs_fit_tracking_metrics` (dispatch) and `test_configure_generation_strategy_with_fit_tracking_metrics` (client); updated existing tests that assert the full MBM `generator_kwargs` dict. ## Implementation note `fit_tracking_metrics` is a `TorchAdapter.__init__` kwarg. The registry's kwarg-splitter (`ax/adapter/registry.py`) automatically routes any key matching an adapter constructor param into the adapter, so adding it to the node's `generator_kwargs` is sufficient — no changes to `registry.py`, `torch.py`, or `base.py`. Test Plan: - Dispatch tests: 13 passed. Client tests pass. flake8 + ufmt clean. - End-to-end verified with a genuine tracking metric `m2`: `fit_tracking_metrics=True` → modeled outcomes `['m1', 'm2']`; `False` → `['m1']` (tracking metric excluded from modeling). Closes facebook#4688 Reviewed By: mpolson64 Differential Revision: D109735998 Pulled By: saitcakmak
b857fff to
d445a74
Compare
|
@saitcakmak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109735998. |
|
@saitcakmak merged this pull request in 5fd8dbf. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Implements the feature requested in #4688: a
fit_tracking_metricsoption on the high-levelClient.configure_generation_strategyAPI, so users can disable modeling of tracking metrics without manually editing the generation strategy.When
False, only metrics in the optimization config (objectives and outcome constraints) are modeled. Tracking metrics are still recorded but not modeled by the BoTorch model — useful when many tracking metrics are kept only for book-keeping.Changes
ax/api/client.py— addedfit_tracking_metrics: bool = Truetoconfigure_generation_strategyand_choose_generation_strategy, threading it into the dispatch struct. Docstrings flag that whenFalse, model-dependent analyses (cross-validation, sensitivity analysis, etc.) will not be produced for tracking metrics, that it requires an optimization config, and that it has no effect forrandom_search.ax/api/utils/structs.py— added thefit_tracking_metricsfield toGenerationStrategyDispatchStruct.ax/api/utils/generation_strategy_dispatch.py—_get_mbm_nodeinjectsfit_tracking_metricsinto the MBM node'sgenerator_kwargs; only the MBM node receives it (Sobol/random-search nodes don't model outcomes).test_gs_fit_tracking_metrics(dispatch) andtest_configure_generation_strategy_with_fit_tracking_metrics(client); updated existing tests that assert the full MBMgenerator_kwargsdict.Implementation note
fit_tracking_metricsis aTorchAdapter.__init__kwarg. The registry's kwarg-splitter (ax/adapter/registry.py) automatically routes any key matching an adapter constructor param into the adapter, so adding it to the node'sgenerator_kwargsis sufficient — no changes toregistry.py,torch.py, orbase.py.Test Plan:
m2:fit_tracking_metrics=True→ modeled outcomes['m1', 'm2'];False→['m1'](tracking metric excluded from modeling).Closes #4688
Reviewed By: mpolson64
Differential Revision: D109735998
Pulled By: saitcakmak