Skip to content

Add fit_tracking_metrics option to configure_generation_strategy (#5238)#5238

Closed
saitcakmak wants to merge 1 commit into
facebook:mainfrom
saitcakmak:fit-tracking-metrics-dispatch
Closed

Add fit_tracking_metrics option to configure_generation_strategy (#5238)#5238
saitcakmak wants to merge 1 commit into
facebook:mainfrom
saitcakmak:fit-tracking-metrics-dispatch

Conversation

@saitcakmak

@saitcakmak saitcakmak commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary:
Implements the feature requested in #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.

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 #4688

Reviewed By: mpolson64

Differential Revision: D109735998

Pulled By: saitcakmak

@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jun 25, 2026
@meta-codesync

meta-codesync Bot commented Jun 25, 2026

Copy link
Copy Markdown

@saitcakmak has imported this pull request. If you are a Meta employee, you can view this in D109735998.

@codecov-commenter

codecov-commenter commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.57%. Comparing base (025d7e5) to head (d445a74).

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.
📢 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.
…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
@meta-codesync meta-codesync Bot changed the title Add fit_tracking_metrics option to configure_generation_strategy Jun 26, 2026
@saitcakmak saitcakmak force-pushed the fit-tracking-metrics-dispatch branch from b857fff to d445a74 Compare June 26, 2026 19:24
@meta-codesync

meta-codesync Bot commented Jun 26, 2026

Copy link
Copy Markdown

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

@meta-codesync

meta-codesync Bot commented Jun 26, 2026

Copy link
Copy Markdown

@saitcakmak merged this pull request in 5fd8dbf.

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

2 participants