Unify objective_weights to 2D on TorchOptConfig#4946
Open
saitcakmak wants to merge 3 commits intofacebook:mainfrom
Open
Unify objective_weights to 2D on TorchOptConfig#4946saitcakmak wants to merge 3 commits intofacebook:mainfrom
saitcakmak wants to merge 3 commits intofacebook:mainfrom
Conversation
…onfig Change objective_weights from a 1D tensor to a 2D tensor where each row is one objective and each column is one modeled outcome. This eliminates the is_moo boolean field since MOO is inferred from shape[0] > 1, and adds outcome_mask as a cached property.
objective_weights is now always 2D (n_objectives, n_outcomes). Remove conditional reshaping and 1D fallbacks so callers that accidentally pass 1D tensors fail loudly.
10 tasks
|
@saitcakmak has imported this pull request. If you are a Meta employee, you can view this in D94287924. |
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
Change
objective_weightsonTorchOptConfigfrom a 1D(n_outcomes,)tensor to a 2D(n_objectives, n_outcomes)matrix throughout the Torch generation pipeline. The main motivation is to supportScalarizedObjectivechildren insideMultiObjective, where a single objective can be a weighted combination of multiple outcomes — something the old 1D representation could not express.Key changes across 19 files
New helpers:
ax/adapter/adapter_utils.py:extract_objective_weight_matrix()— builds the 2D weight matrix from anObjective(one row per sub-objective forMultiObjective, single row otherwise).ax/generators/torch/utils.py:extract_objectives()— iterates over rows of the weight matrix to produce per-objective outcome indices and weights.TorchOptConfigupdates (ax/generators/torch_base.py):objective_weightsis now documented as(n_objectives, n_outcomes).is_moois now acached_propertyinferred fromobjective_weights.shape[0] > 1(no longer a constructor argument).outcome_maskcached property: 1D boolean tensor indicating which outcomes participate in at least one objective.Source updates:
ax/adapter/torch.py: Produce 2D weights viaextract_objective_weight_matrix; useextract_objectivesin_untransform_objective_thresholds; dropis_mookwarg fromTorchOptConfigconstruction.ax/adapter/adapter_utils.py: Updateget_pareto_frontier_and_configsandhypervolumeto use 2D weights.ax/generators/torch/utils.py: Updatesubset_modelto operate on 2D weights (column-wise masking/subsetting); update_get_weighted_mo_objectiveto useextract_objectives; updateget_botorch_objective_and_transformto collapse 2D→1D via.sum(dim=0)where a single scalarized weight vector is needed.ax/generators/torch/botorch_moo_utils.py: Updateget_weighted_mc_objective_and_objective_thresholds,pareto_frontier_evaluator, andinfer_objective_thresholdsfor 2D weights.ax/generators/torch/botorch_modular/acquisition.py: Update_update_objective_thresholdsfor 2D weights.ax/generators/torch/botorch_modular/utils.py: Update_objective_threshold_to_outcome_constraintsandchoose_botorch_acqf_classfor 2D weights.ax/generators/torch/botorch_modular/generator.py: Update_get_gen_metadata_from_acqfand_build_candidate_generation_optionsfor 2D weights.ax/generators/utils.py: Updateget_observedandbest_in_sample_pointto handle the 2D weight matrix.Test updates:
objective_weightstensors.Test plan
pytest ax/generators/torch/tests/test_utils.pypytest ax/generators/torch/tests/test_acquisition.pypytest ax/generators/torch/tests/test_generator.pypytest ax/generators/torch/tests/test_surrogate.pypytest ax/generators/tests/test_botorch_moo_utils.pypytest ax/generators/tests/test_torch_utils.pypytest ax/generators/tests/test_utils.pypytest ax/adapter/tests/test_adapter_utils.pypytest ax/adapter/tests/test_torch_adapter.pypytest ax/adapter/tests/test_torch_moo_adapter.py