Skip to content

Commit 32e154a

Browse files
vizier-teamcopybara-github
authored andcommitted
Change the implementation of the Trust Region in the Vizier Acquisition
function to reduce rounding errors. PiperOrigin-RevId: 796448366
1 parent 503f875 commit 32e154a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

vizier/_src/algorithms/designers/gp/acquisitions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def _apply_trust_region(
162162
acquisition = jnp.where(
163163
((distance <= region.trust_radius) | (region.trust_radius > 0.5)),
164164
acquisition,
165-
-1e12 - distance,
165+
-1e4 - distance,
166166
)
167167
aux = aux | {
168168
'mean': pred.mean(),
@@ -420,7 +420,7 @@ def default_ucb_pi(cls, data: types.ModelData) -> 'AcquisitionTrustRegion':
420420
return cls(
421421
UCB(1.8),
422422
PI(best_labels),
423-
bad_acq_value=-1e12,
423+
bad_acq_value=-1e4,
424424
labels=data.labels,
425425
threshold=0.3,
426426
apply_tr_after=0,
@@ -432,7 +432,7 @@ def default_ucb_lcb(cls, data: types.ModelData) -> 'AcquisitionTrustRegion':
432432
UCB(1.8),
433433
LCB(1.8),
434434
labels=data.labels,
435-
bad_acq_value=-1e12,
435+
bad_acq_value=-1e4,
436436
threshold=None,
437437
apply_tr_after=0,
438438
)
@@ -445,7 +445,7 @@ def default_ucb_lcb_wide(
445445
UCB(1.8),
446446
LCB(2.5),
447447
labels=data.labels,
448-
bad_acq_value=-1e12,
448+
bad_acq_value=-1e4,
449449
threshold=None,
450450
apply_tr_after=0,
451451
)
@@ -458,7 +458,7 @@ def default_ucb_lcb_delay_tr(
458458
UCB(1.8),
459459
LCB(1.8),
460460
labels=data.labels,
461-
bad_acq_value=-1e12,
461+
bad_acq_value=-1e4,
462462
threshold=None,
463463
apply_tr_after=5,
464464
)

vizier/_src/algorithms/designers/gp/acquisitions_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_acq_pi_tr_good_point(self):
238238
acq = acquisitions.AcquisitionTrustRegion.default_ucb_pi(data=data)
239239
self.assertAlmostEqual(
240240
acq(tfd.Normal(jnp.float64(0.1), 1)),
241-
-1.0e12,
241+
-1e4,
242242
)
243243

244244
def test_acq_pi_tr_bad_point(self):
@@ -254,7 +254,7 @@ def test_acq_lcb_tr_bad_point(self):
254254
acq = acquisitions.AcquisitionTrustRegion.default_ucb_lcb(data=data)
255255
self.assertAlmostEqual(
256256
acq(tfd.Normal(jnp.float64(0.1), 1)),
257-
jnp.array([-1e12]),
257+
jnp.array([-1e4]),
258258
delta=2.0,
259259
)
260260

vizier/_src/algorithms/designers/gp_ucb_pe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ def _apply_trust_region(
226226
Acquisition function values with trust region applied.
227227
"""
228228
distance = tr.min_linf_distance(xs)
229-
# Due to output normalization, acquisition values can't be as low as -1e12.
229+
# Due to output normalization, acquisition values can't be as low as -1e4.
230230
# We use a bad value that decreases in the distance to trust region so that
231231
# acquisition optimizer can follow the gradient and escape untrustred regions.
232232
return jnp.where(
233233
(distance < tr.trust_radius) | (tr.trust_radius > 0.5),
234234
acq_values,
235-
-1e12 - distance,
235+
-1e4 - distance,
236236
)
237237

238238

@@ -252,13 +252,13 @@ def _apply_trust_region_to_set(
252252
[batch_size].
253253
"""
254254
distance = tr.min_linf_distance(xs) # [batch_size, index_point_set_size]
255-
# Due to output normalization, acquisition values can't be as low as -1e12.
255+
# Due to output normalization, acquisition values can't be as low as -1e4.
256256
# We penalize the acquisition values by an amount that decreases in the
257257
# total distances to the trust region so that acquisition optimizer can follow
258258
# the gradient and escape untrustred regions.
259259
return acq_values + jnp.sum(
260260
((distance > tr.trust_radius) & (tr.trust_radius <= 0.5))
261-
* (-1e12 - distance),
261+
* (-1e4 - distance),
262262
axis=1,
263263
)
264264

0 commit comments

Comments
 (0)