Repository navigation
Keep quantized integer configs inside the search space bounds - #1667
Open
Mohammad Sohail Shaikh (sohailshk) wants to merge 1 commit into
Open
Mohammad Sohail Shaikh (sohailshk) wants to merge 1 commit into
Mohammad Sohail Shaikh (sohailshk) wants to merge 1 commit into
Conversation
denormalize() (FLOW2, used by CFO and BlendSearch) and unflatten_hierarchical() (BlendSearch's global Optuna search for qlograndint) rounded values to the nearest multiple of q without checking the domain, so configs could fall below lower or above upper whenever a bound was not a multiple of q (qrandint(1, 11, 3) gave 0 and 12, qlograndint(5, 30, 4) gave 4 and 32). Clamp to the multiples of q inside [lower, upper], the grid Quantized.sample() draws from.
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.
Why are these changes needed?
tune.qrandint/tune.qlograndintaccept bounds that are not multiples ofq(the floatquantized()rejects them).Quantized.sample()draws from the multiples ofqinside[lower, upper], but the search side rounds to the nearest multiple without checking the domain, in two places:denormalize()(FLOW2, used by CFO/BlendSearch) andunflatten_hierarchical()(BlendSearch's global Optuna search for qlograndint). On main,tune.qrandint(1, 11, 3)yields 0 and 12 with CFO, and the defaulttune.run(obj, config={"x": tune.qlograndint(5, 30, 4)}, metric="loss", mode="min", num_samples=30, use_ray=False)evaluated 4, below the lower bound (with the change the evaluated values are 8 to 28).Both places now clamp, through one helper, to the first/last multiple of
qinside the bounds. Values on the grid are never moved; domains whose bounds are multiples ofq(all q=1 domains) are unchanged. Clamping widens the two edge bins of the normalized-to-value map: it is a deterministic projection for local search, not a sampling distribution.Not changed: for
qrandint, Optuna's own step grid starts atlower(1, 4, 7, 10 forqrandint(1, 11, 3)); those values are inside the bounds.Tests: denormalize over 0..1 for three domains, a CFO run, a BlendSearch run with
qlograndint(5, 30, 4)and the defaulttune.run(the last two skip without optuna); 6 failed on main, 6 pass. The other tune tests (sample, space, unit_quantization, singleton_integer, tune, searcher, reproducibility) give the same results as main apart from ray/optuna-subprocess ones (test_no_optuna fails on main too).Related issue number
Search-side counterpart of #1605/#1606 (
Quantized.sample()).Checks
Checks run: black (line length 120) and ruff on the changed files. The pinned pre-commit hook versions were not run. No doc changes are needed.