Re-index TorchOptConfig.objective_thresholds from (n_outcomes,) to (n_objectives,) (#5018)#5018
Open
saitcakmak wants to merge 1 commit intofacebook:mainfrom
Open
Re-index TorchOptConfig.objective_thresholds from (n_outcomes,) to (n_objectives,) (#5018)#5018saitcakmak wants to merge 1 commit intofacebook:mainfrom
saitcakmak wants to merge 1 commit intofacebook:mainfrom
Conversation
|
@saitcakmak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D96391935. |
8121938 to
6d8c782
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5018 +/- ##
==========================================
- Coverage 96.29% 96.28% -0.01%
==========================================
Files 611 611
Lines 67314 67270 -44
==========================================
- Hits 64822 64773 -49
- Misses 2492 2497 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6d8c782 to
4e9f8d3
Compare
saitcakmak
added a commit
to saitcakmak/Ax
that referenced
this pull request
Mar 20, 2026
…_objectives,) (facebook#5018) Summary: Re-index `objective_thresholds` in `TorchOptConfig` from `(n_outcomes,)` with NaN for non-objective outcomes to `(n_objectives,)` or `None`. This is a prerequisite for supporting `ScalarizedObjective` as a sub-objective of `MultiObjective`. Key changes: - `extract_objective_thresholds` returns `(n_objectives,)` maximization-aligned array (sign-flipped for minimize objectives), or `None` for single-objective. Rewritten to use expression-based API (`parse_objective_expression` / `extract_metric_weights_from_objective_expr`) instead of deprecated `MultiObjective.objectives` / `ScalarizedObjective` class checks. - `_untransform_objective_thresholds` indexes by objective index and un-flips the sign when converting back to raw `ObjectiveThreshold.bound`. - Replaced `get_weighted_mc_objective_and_objective_thresholds` with `get_weighted_mc_objective`, which only returns the objective (thresholds no longer need transformation so callers use them directly). - `infer_objective_thresholds` returns `(n_objectives,)` maximization-aligned. - Removed `objective_thresholds` from `SubsetModelData` and `subset_model` (thresholds are per-objective, not per-outcome, so subsetting doesn't apply). - Simplified `_objective_threshold_to_outcome_constraints` and pruning logic. - Merged `_full_objective_thresholds` and `_objective_thresholds` into single `_objective_thresholds` in the `Acquisition` class. - Pass thresholds directly as `ref_point` to BoTorch input constructors (using the new `ref_point` parameter from D96473523), avoiding the need to convert back to outcome space. - Fixed Pyre type errors in `test_acquisition.py` for `Optional[Tensor]` return from `Acquisition.objective_thresholds`. TRBO isolation (axoptics): - TRBO uses its own `objective_weights` and `max_reference_point` from constructor kwargs -- it does NOT use `TorchOptConfig` from `gen()`. Its `__init__` expects legacy format: `(n_outcomes,)` with raw bounds and NaN for non-objectives, then handles maximization alignment internally. - Replaced the `extract_objective_thresholds` call in axoptics `_mk_TRBO_generation_strategy` with inline legacy logic that produces the `(n_outcomes,)` raw-bounds format TRBO expects, keeping TRBO isolated from the new `(n_objectives,)` format. - Added comments to `trbo.py` documenting the legacy input contract and future refactoring TODO. Differential Revision: D96391935
…_objectives,) (facebook#5018) Summary: Pull Request resolved: facebook#5018 Re-index `objective_thresholds` in `TorchOptConfig` from `(n_outcomes,)` with NaN for non-objective outcomes to `(n_objectives,)` or `None`. This is a prerequisite for supporting `ScalarizedObjective` as a sub-objective of `MultiObjective`. Key changes: - `extract_objective_thresholds` returns `(n_objectives,)` maximization-aligned array (sign-flipped for minimize objectives), or `None` for single-objective. Rewritten to use expression-based API (`parse_objective_expression` / `extract_metric_weights_from_objective_expr`) instead of deprecated `MultiObjective.objectives` / `ScalarizedObjective` class checks. - `_untransform_objective_thresholds` indexes by objective index and un-flips the sign when converting back to raw `ObjectiveThreshold.bound`. - Replaced `get_weighted_mc_objective_and_objective_thresholds` with `get_weighted_mc_objective`, which only returns the objective (thresholds no longer need transformation so callers use them directly). - `infer_objective_thresholds` returns `(n_objectives,)` maximization-aligned. - Removed `objective_thresholds` from `SubsetModelData` and `subset_model` (thresholds are per-objective, not per-outcome, so subsetting doesn't apply). - Simplified `_objective_threshold_to_outcome_constraints` and pruning logic. - Merged `_full_objective_thresholds` and `_objective_thresholds` into single `_objective_thresholds` in the `Acquisition` class. - Pass thresholds directly as `ref_point` to BoTorch input constructors (using the new `ref_point` parameter from D96473523), avoiding the need to convert back to outcome space. - Fixed Pyre type errors in `test_acquisition.py` for `Optional[Tensor]` return from `Acquisition.objective_thresholds`. TRBO isolation (axoptics): - TRBO uses its own `objective_weights` and `max_reference_point` from constructor kwargs -- it does NOT use `TorchOptConfig` from `gen()`. Its `__init__` expects legacy format: `(n_outcomes,)` with raw bounds and NaN for non-objectives, then handles maximization alignment internally. - Replaced the `extract_objective_thresholds` call in axoptics `_mk_TRBO_generation_strategy` with inline legacy logic that produces the `(n_outcomes,)` raw-bounds format TRBO expects, keeping TRBO isolated from the new `(n_objectives,)` format. - Added comments to `trbo.py` documenting the legacy input contract and future refactoring TODO. Differential Revision: D96391935
4e9f8d3 to
90cf05d
Compare
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:
Re-index
objective_thresholdsinTorchOptConfigfrom(n_outcomes,)with NaNfor non-objective outcomes to
(n_objectives,)orNone. This is a prerequisitefor supporting
ScalarizedObjectiveas a sub-objective ofMultiObjective.Key changes:
extract_objective_thresholdsreturns(n_objectives,)maximization-alignedarray (sign-flipped for minimize objectives), or
Nonefor single-objective.Rewritten to use expression-based API (
parse_objective_expression/extract_metric_weights_from_objective_expr) instead of deprecatedMultiObjective.objectives/ScalarizedObjectiveclass checks._untransform_objective_thresholdsindexes by objective index and un-flipsthe sign when converting back to raw
ObjectiveThreshold.bound.get_weighted_mc_objective_and_objective_thresholdswithget_weighted_mc_objective, which only returns the objective (thresholdsno longer need transformation so callers use them directly).
infer_objective_thresholdsreturns(n_objectives,)maximization-aligned.objective_thresholdsfromSubsetModelDataandsubset_model(thresholds are per-objective, not per-outcome, so subsetting doesn't apply).
_objective_threshold_to_outcome_constraintsand pruning logic._full_objective_thresholdsand_objective_thresholdsinto single_objective_thresholdsin theAcquisitionclass.ref_pointto BoTorch input constructors (usingthe new
ref_pointparameter from D96473523), avoiding the need to convertback to outcome space.
test_acquisition.pyforOptional[Tensor]return from
Acquisition.objective_thresholds.TRBO isolation (axoptics):
objective_weightsandmax_reference_pointfromconstructor kwargs -- it does NOT use
TorchOptConfigfromgen().Its
__init__expects legacy format:(n_outcomes,)with raw bounds andNaN for non-objectives, then handles maximization alignment internally.
extract_objective_thresholdscall in axoptics_mk_TRBO_generation_strategywith inline legacy logic that produces the(n_outcomes,)raw-bounds format TRBO expects, keeping TRBO isolated fromthe new
(n_objectives,)format.trbo.pydocumenting the legacy input contract andfuture refactoring TODO.
Differential Revision: D96391935