Skip to content

Keep quantized integer configs inside the search space bounds - #1667

Open
Mohammad Sohail Shaikh (sohailshk) wants to merge 1 commit into
microsoft:mainfrom
sohailshk:fix/denormalize-quantized-int-bounds
Open

Mohammad Sohail Shaikh (sohailshk) wants to merge 1 commit into
microsoft:mainfrom
sohailshk:fix/denormalize-quantized-int-bounds

Conversation

@sohailshk

Copy link
Copy Markdown

Why are these changes needed?

tune.qrandint / tune.qlograndint accept bounds that are not multiples of q (the float quantized() rejects them). Quantized.sample() draws from the multiples of q inside [lower, upper], but the search side rounds to the nearest multiple without checking the domain, in two places: denormalize() (FLOW2, used by CFO/BlendSearch) and unflatten_hierarchical() (BlendSearch's global Optuna search for qlograndint). On main, tune.qrandint(1, 11, 3) yields 0 and 12 with CFO, and the default tune.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 q inside the bounds. Values on the grid are never moved; domains whose bounds are multiples of q (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 at lower (1, 4, 7, 10 for qrandint(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 default tune.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.

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

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