Thread equality constraints through adapter layer and TorchOptConfig (#5176)#5176
Closed
sdaulton wants to merge 4 commits into
Closed
Thread equality constraints through adapter layer and TorchOptConfig (#5176)#5176sdaulton wants to merge 4 commits into
sdaulton wants to merge 4 commits into
Conversation
|
@sdaulton has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100256480. |
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
ccd6af6 to
57d666f
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Pull Request resolved: facebook#5176 Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
57d666f to
a0638ff
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
a0638ff to
df6126e
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Pull Request resolved: facebook#5176 Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
df6126e to
34a5205
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5176 +/- ##
========================================
Coverage 96.41% 96.41%
========================================
Files 618 619 +1
Lines 68882 69114 +232
========================================
+ Hits 66410 66639 +229
- Misses 2472 2475 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
Summary: Add support for linear equality constraints (`w^T x == b`) alongside existing inequality constraints (`w^T x <= b`) in Ax's `ParameterConstraint` class. This is the first diff in a stack that threads equality constraints all the way down to BoTorch's `optimize_acqf`. Changes: - Add `extract_coefficient_dict_from_equality` to `ax/utils/common/sympy.py` for parsing `"expr == bound"` strings (SymPy can't parse `==` directly since Python evaluates it as a boolean). - Extend `ParameterConstraint.__init__` to accept `equality=` kwarg alongside existing `inequality=` kwarg. Exactly one must be provided. - Add `is_equality` property. - Update `check()` to use `|w^T x - b| <= tol` for equality constraints. - Update `__repr__`, `clone()`, `clone_with_transformed_parameters()`. - Add comprehensive tests for equality constraints. Differential Revision: D100256486
Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Differential Revision: D100256487
Summary: Update `SearchSpace.check_membership_df` and `compute_chebyshev_center` to handle equality constraints alongside existing inequality constraints. - `check_membership_df`: branch on `constraint.is_equality` — use `|weighted_sum - bound| <= tol` for equality, `weighted_sum <= bound + tol` for inequality. - `compute_chebyshev_center`: separate equality and inequality constraints into `A_eq/b_eq` and `A_ub/b_ub` for `scipy.optimize.linprog`. Equality constraints don't get the `r * ||a_i||` augmentation since the inscribed ball center must lie on the hyperplane. - `check_membership` already works via the updated `constraint.check()`. Differential Revision: D100256478
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
34a5205 to
b969019
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
b969019 to
1ebed86
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
1ebed86 to
0a1da35
Compare
…acebook#5176) Summary: Pull Request resolved: facebook#5176 Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
0a1da35 to
8ce7b00
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…acebook#5176) Summary: Add equality constraint extraction and propagation through the adapter layer to TorchOptConfig, enabling downstream generators to receive equality constraints. - Add `extract_equality_constraints` in `adapter_utils.py` (filters for `is_equality=True` constraints, returns `(A, b)` matrices). - Update `extract_parameter_constraints` to filter out equality constraints. - Add `equality_constraints` parameter to `validate_and_apply_final_transform` (now returns a 7-tuple). - Add `equality_constraints: tuple[Tensor, Tensor] | None` field to `TorchOptConfig`. - Update `TorchAdapter._get_transformed_model_gen_args` to extract equality constraints and pass them through to `TorchOptConfig`. Reviewed By: bletham Differential Revision: D100256480
|
This pull request has been merged in b668431. |
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:
Add equality constraint extraction and propagation through the adapter layer
to TorchOptConfig, enabling downstream generators to receive equality
constraints.
extract_equality_constraintsinadapter_utils.py(filters foris_equality=Trueconstraints, returns(A, b)matrices).extract_parameter_constraintsto filter out equality constraints.equality_constraintsparameter tovalidate_and_apply_final_transform(now returns a 7-tuple).
equality_constraints: tuple[Tensor, Tensor] | Nonefield toTorchOptConfig.TorchAdapter._get_transformed_model_gen_argsto extract equalityconstraints and pass them through to
TorchOptConfig.Reviewed By: bletham
Differential Revision: D100256480