Skip to content

Deprecate OptimizationConfig.__init__(objective=), remove setter & clone_with_args(objective=) (#5151)#5151

Open
saitcakmak wants to merge 2 commits intofacebook:mainfrom
saitcakmak:export-D99491494
Open

Deprecate OptimizationConfig.__init__(objective=), remove setter & clone_with_args(objective=) (#5151)#5151
saitcakmak wants to merge 2 commits intofacebook:mainfrom
saitcakmak:export-D99491494

Conversation

@saitcakmak
Copy link
Copy Markdown
Contributor

@saitcakmak saitcakmak commented Apr 7, 2026

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

@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 D99491494.

@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 7, 2026
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 both `__init__` and `clone_with_args`.
- 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=) (facebook#5151)

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
@meta-codesync meta-codesync bot changed the title Deprecate OptimizationConfig.__init__(objective=), remove setter & clone_with_args(objective=) Deprecate OptimizationConfig.__init__(objective=), remove setter & clone_with_args(objective=) (#5151) Apr 7, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

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

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

☔ 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