8000 Batch Halton draws in QuasiRandomDesigner.suggest() instead of looping by ALDASTFRANCIS · Pull Request #1337 · google/vizier · GitHub
[go: up one dir, main page]

Skip to content

Batch Halton draws in QuasiRandomDesigner.suggest() instead of looping - #1337

Open
ALDASTFRANCIS wants to merge 1 commit into
google:mainfrom
ALDASTFRANCIS:fix/quasi-random-batch-halton
Open

ALDASTFRANCIS wants to merge 1 commit into
google:mainfrom
ALDASTFRANCIS:fix/quasi-random-batch-halton

Conversation

@ALDASTFRANCIS
Copy link
Copy Markdown

QuasiRandomDesigner.suggest(count) currently draws its count Halton
points one at a time:

for _ in range(count):
  halton_values = self._halton.random(n=1)[0]
  ...

scipy.stats.qmc.Halton (via QMCEngine) supports drawing a batch
directly with random(n=count), and advances its internal sequence
counter by exactly n either way — so random(n=1) called count
times produces the identical sequence of points, in the same order, as
one random(n=count) call. This PR replaces the loop with a single
batched call; no public API or output change.

This path isn't cold: QuasiRandomDesigner seeds initial trials for
GPBandit, GPUCBPE, and EagleStrategy, and gp_bandit.py already
wraps this exact call in
profiler.timeit('quasi_random_sampler_seed_trials').

Verified:

  • halton.random(n=1) x N in a loop == halton.random(n=N) once
    (bit-identical via np.array_equal)
  • Added test_suggest_batch_matches_sequential_calls: suggest(N)
    matches N sequential suggest(1) calls, including dump()/load()
    checkpoint state
  • All existing tests in quasi_random_test.py pass unchanged (7/7
    before, 8/8 after)
  • ~2x-26x faster in isolated benchmarking depending on batch size
    (gap widens with count); consistently faster end-to-end through
    suggest() too, though more modestly, since other per-dimension
    work in the method is unchanged

Happy to adjust the structure if you'd prefer a different approach.

…g. QuasiRandomDesigner.suggest(count) drew its count Halton points one at a time via self._halton.random(n=1) in a loop. scipy's QMCEngine advances its internal sequence counter by exactly n per call, so a single random(n=count) call yields the identical sequence of points, in the same order, without count x the per-call overhead. QuasiRandomDesigner seeds initial trials for GPBandit, GPUCBPE, and EagleStrategy; gp_bandit.py already wraps this call in profiler.timeit('quasi_random_sampler_seed_trials'). Verified halton.random(n=1) x N == halton.random(n=N) bit-identical, added a regression test comparing suggest(N) against N sequential suggest(1) calls including dump/load state, and confirmed all existing quasi_random_test.py tests still pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0