Commit 4e9f8d3
Re-index TorchOptConfig.objective_thresholds from (n_outcomes,) to (n_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: D963919351 parent ef72a7d commit 4e9f8d3
File tree
15 files changed
+227
-291
lines changed- ax
- adapter
- tests
- generators
- tests
- torch
- botorch_modular
- tests
15 files changed
+227
-291
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
211 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
212 | 220 | | |
213 | | - | |
214 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
215 | 224 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
220 | 230 | | |
221 | 231 | | |
222 | 232 | | |
| |||
225 | 235 | | |
226 | 236 | | |
227 | 237 | | |
228 | | - | |
| 238 | + | |
229 | 239 | | |
230 | 240 | | |
231 | 241 | | |
| |||
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
258 | 280 | | |
259 | 281 | | |
260 | 282 | | |
| |||
769 | 791 | | |
770 | 792 | | |
771 | 793 | | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 794 | + | |
| 795 | + | |
776 | 796 | | |
777 | 797 | | |
778 | 798 | | |
| |||
937 | 957 | | |
938 | 958 | | |
939 | 959 | | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
| 960 | + | |
| 961 | + | |
944 | 962 | | |
945 | 963 | | |
946 | 964 | | |
947 | 965 | | |
948 | | - | |
| 966 | + | |
949 | 967 | | |
950 | 968 | | |
951 | 969 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | | - | |
204 | | - | |
205 | | - | |
| 205 | + | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
186 | 217 | | |
187 | | - | |
188 | | - | |
| 218 | + | |
| 219 | + | |
189 | 220 | | |
190 | 221 | | |
191 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
192 | 226 | | |
193 | | - | |
194 | | - | |
| 227 | + | |
195 | 228 | | |
196 | 229 | | |
197 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1153 | 1153 | | |
1154 | 1154 | | |
1155 | 1155 | | |
1156 | | - | |
| 1156 | + | |
1157 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
1158 | 1160 | | |
1159 | 1161 | | |
1160 | 1162 | | |
1161 | | - | |
| 1163 | + | |
1162 | 1164 | | |
1163 | 1165 | | |
1164 | 1166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | | - | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | | - | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
216 | | - | |
| 217 | + | |
217 | 218 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 219 | + | |
223 | 220 | | |
224 | | - | |
225 | 221 | | |
226 | 222 | | |
227 | 223 | | |
228 | | - | |
229 | 224 | | |
230 | 225 | | |
231 | 226 | | |
| |||
255 | 250 | | |
256 | 251 | | |
257 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
258 | 257 | | |
259 | 258 | | |
260 | 259 | | |
| |||
282 | 281 | | |
283 | 282 | | |
284 | 283 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
289 | 287 | | |
290 | 288 | | |
291 | 289 | | |
| |||
295 | 293 | | |
296 | 294 | | |
297 | 295 | | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 296 | + | |
| 297 | + | |
302 | 298 | | |
303 | 299 | | |
304 | 300 | | |
| |||
312 | 308 | | |
313 | 309 | | |
314 | 310 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 311 | + | |
| 312 | + | |
319 | 313 | | |
320 | 314 | | |
321 | 315 | | |
| |||
350 | 344 | | |
351 | 345 | | |
352 | 346 | | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
| 347 | + | |
| 348 | + | |
357 | 349 | | |
358 | 350 | | |
359 | 351 | | |
| |||
0 commit comments