Repository navigation
Batch Halton draws in QuasiRandomDesigner.suggest() instead of looping - #1337
Open
ALDASTFRANCIS wants to merge 1 commit into
Open
ALDASTFRANCIS wants to merge 1 commit into
ALDASTFRANCIS wants to merge 1 commit into
Conversation
…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
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.
QuasiRandomDesigner.suggest(count)currently draws itscountHaltonpoints one at a time:
scipy.stats.qmc.Halton(viaQMCEngine) supports drawing a batchdirectly with
random(n=count), and advances its internal sequencecounter by exactly
neither way — sorandom(n=1)calledcounttimes produces the identical sequence of points, in the same order, as
one
random(n=count)call. This PR replaces the loop with a singlebatched call; no public API or output change.
This path isn't cold:
QuasiRandomDesignerseeds initial trials forGPBandit,GPUCBPE, andEagleStrategy, andgp_bandit.pyalreadywraps 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)test_suggest_batch_matches_sequential_calls:suggest(N)matches N sequential
suggest(1)calls, includingdump()/load()checkpoint state
quasi_random_test.pypass unchanged (7/7before, 8/8 after)
(gap widens with count); consistently faster end-to-end through
suggest()too, though more modestly, since other per-dimensionwork in the method is unchanged
Happy to adjust the structure if you'd prefer a different approach.