Skip to content

Comments

Unify objective_weights to 2D on TorchOptConfig#4946

Open
saitcakmak wants to merge 3 commits intofacebook:mainfrom
saitcakmak:unify-objective-weight-matrix
Open

Unify objective_weights to 2D on TorchOptConfig#4946
saitcakmak wants to merge 3 commits intofacebook:mainfrom
saitcakmak:unify-objective-weight-matrix

Conversation

@saitcakmak
Copy link
Contributor

Summary

Change objective_weights on TorchOptConfig from a 1D (n_outcomes,) tensor to a 2D (n_objectives, n_outcomes) matrix throughout the Torch generation pipeline. The main motivation is to support ScalarizedObjective children inside MultiObjective, 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 an Objective (one row per sub-objective for MultiObjective, 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.

TorchOptConfig updates (ax/generators/torch_base.py):

  • objective_weights is now documented as (n_objectives, n_outcomes).
  • is_moo is now a cached_property inferred from objective_weights.shape[0] > 1 (no longer a constructor argument).
  • Added outcome_mask cached property: 1D boolean tensor indicating which outcomes participate in at least one objective.

Source updates:

  • ax/adapter/torch.py: Produce 2D weights via extract_objective_weight_matrix; use extract_objectives in _untransform_objective_thresholds; drop is_moo kwarg from TorchOptConfig construction.
  • ax/adapter/adapter_utils.py: Update get_pareto_frontier_and_configs and hypervolume to use 2D weights.
  • ax/generators/torch/utils.py: Update subset_model to operate on 2D weights (column-wise masking/subsetting); update _get_weighted_mo_objective to use extract_objectives; update get_botorch_objective_and_transform to collapse 2D→1D via .sum(dim=0) where a single scalarized weight vector is needed.
  • ax/generators/torch/botorch_moo_utils.py: Update get_weighted_mc_objective_and_objective_thresholds, pareto_frontier_evaluator, and infer_objective_thresholds for 2D weights.
  • ax/generators/torch/botorch_modular/acquisition.py: Update _update_objective_thresholds for 2D weights.
  • ax/generators/torch/botorch_modular/utils.py: Update _objective_threshold_to_outcome_constraints and choose_botorch_acqf_class for 2D weights.
  • ax/generators/torch/botorch_modular/generator.py: Update _get_gen_metadata_from_acqf and _build_candidate_generation_options for 2D weights.
  • ax/generators/utils.py: Update get_observed and best_in_sample_point to handle the 2D weight matrix.

Test updates:

  • 9 test files updated to use 2D objective_weights tensors.

Test plan

  • pytest ax/generators/torch/tests/test_utils.py
  • pytest ax/generators/torch/tests/test_acquisition.py
  • pytest ax/generators/torch/tests/test_generator.py
  • pytest ax/generators/torch/tests/test_surrogate.py
  • pytest ax/generators/tests/test_botorch_moo_utils.py
  • pytest ax/generators/tests/test_torch_utils.py
  • pytest ax/generators/tests/test_utils.py
  • pytest ax/adapter/tests/test_adapter_utils.py
  • pytest ax/adapter/tests/test_torch_adapter.py
  • pytest ax/adapter/tests/test_torch_moo_adapter.py

…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.
@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 24, 2026
@meta-codesync
Copy link

meta-codesync bot commented Feb 24, 2026

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant