Skip to content

Migrate core_stubs.py from objective= to objectives=[]#5154

Open
saitcakmak wants to merge 4 commits intofacebook:mainfrom
saitcakmak:export-D99504973
Open

Migrate core_stubs.py from objective= to objectives=[]#5154
saitcakmak wants to merge 4 commits intofacebook:mainfrom
saitcakmak:export-D99504973

Conversation

@saitcakmak
Copy link
Copy Markdown
Contributor

Summary:
Mechanical migration of all base OptimizationConfig callers in
core_stubs.py from the deprecated objective= kwarg to objectives=[...].
MultiObjectiveOptimizationConfig callers are not changed.

This is part of a phased deprecation of the objective= parameter
from OptimizationConfig.init.

Differential Revision: D99506123

…zationConfig

Summary:
Implementation plan for Option 3 from the design doc:
https://docs.google.com/document/d/1EGQYmBjiNGtYapXu1RLHEBdA5Yz2c7q17acX3es0yV8/edit

This restricts Objective to represent a single (possibly scalarized) objective,
moves multi-objective representation to OptimizationConfig(objectives=list[Objective]),
adds threshold/relative_threshold fields to Objective, and deprecates
MultiObjectiveOptimizationConfig, MultiObjective, ScalarizedObjective, and
ObjectiveThreshold.

The plan is a 6-diff stack, each backward-compatible:
1. Add objectives: list[Objective] to OptimizationConfig
2. Update MOOC & PreferenceOptimizationConfig to use objectives list
3. Restrict Objective to single/scalarized (reject commas)
4. Migrate isinstance(_, MOOC) checks to is_moo_problem
5. Add threshold/relative_threshold to Objective + storage
6. Remove all internal usage of deprecated classes

Differential Revision: D99386109
Summary:
Part of the Restrict Objective to Single/Scalarized & Simplify
OptimizationConfig design (see design doc:
https://docs.google.com/document/d/1EGQYmBjiNGtYapXu1RLHEBdA5Yz2c7q17acX3es0yV8/edit).

This is Diff 1 of the stack: enables the new
`OptimizationConfig(objectives=[...])` construction path without
breaking any existing code.

Changes:
- `OptimizationConfig.__init__` and `clone_with_args` are now
  keyword-only across `OptimizationConfig`, `MOOC`, and
  `PreferenceOptimizationConfig`. All positional callers updated.
- New kwarg `objectives: list[Objective] | None = None`, mutually
  exclusive with `objective`, on `__init__` and `clone_with_args`
  of all three classes (`OptimizationConfig`, `MOOC`, and
  `PreferenceOptimizationConfig`).
- Internally stores `self._objectives: list[Objective]` (both paths).
- New `objectives` property returns the list.
- `objective` property raises `UnsupportedError` if `len > 1`.
- `is_moo_problem` property: True when multiple objectives or legacy
  multi-objective expression.
- `metric_names`, `metric_name_to_signature`, `metric_signatures`
  aggregate across all objectives + constraints.
- `__repr__` always uses `objectives=`.
- JSON storage: encoder uses `objectives` key; decoder has backward
  compat to convert old `objective` key to `objectives` list.
- SQA storage: encoder iterates `objectives` to encode each one;
  decoder collects multiple OBJECTIVE rows and reconstructs
  `OptimizationConfig(objectives=...)` when `len > 1`.
- Validation ensures no duplicate metrics across objectives and no
  multi-objective expressions in individual list elements.

Differential Revision: D99387020
…one_with_args(objective=)

Summary:
Goal: We added `objectives` input, we're now migrating all usage to `objectives` and eliminating the `objective` input. This will make it easier to eliminate `MultiObjective` and `MultiObjectiveOptimizationConfig`.

Phase 1 of the OptimizationConfig simplification migration:
- Add DeprecationWarning when passing objective= to OptimizationConfig.__init__
- Remove the objective setter on OptimizationConfig (MOOC keeps its own)
- Remove objective= param from OptimizationConfig.clone_with_args (MOOC/PreferenceOC keep theirs)
- Migrate all callers of the removed setter and clone_with_args(objective=)

Differential Revision: D99491494
Summary:
Mechanical migration of all base OptimizationConfig callers in
core_stubs.py from the deprecated objective= kwarg to objectives=[...].
MultiObjectiveOptimizationConfig callers are not changed.

This is part of a phased deprecation of the objective= parameter
from OptimizationConfig.__init__.

Differential Revision: D99506123
@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 7, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 7, 2026

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

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.51553% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.40%. Comparing base (3712dd6) to head (878d3db).

Files with missing lines Patch % Lines
ax/core/optimization_config.py 93.54% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5154      +/-   ##
==========================================
+ Coverage   96.39%   96.40%   +0.01%     
==========================================
  Files         613      613              
  Lines       68385    68493     +108     
==========================================
+ Hits        65919    66032     +113     
+ Misses       2466     2461       -5     

☔ 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