Repository navigation
Keep quantized integer configs inside the search space bounds - #1667
Sohail Shaikh (sohailshk) wants to merge 4 commits 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.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the quantized-integer bounds fix.
No open issues 🎉
What changed in this PR
This PR extends the quantized-integer sampling fixes from #1605/#1606 to search-generated configurations, keeping values within domain bounds when those bounds are not multiples of q.
Changes:
- Adds a shared helper to clamp values to the first and last valid integer-grid points.
- Applies clamping in local-search denormalization and hierarchical reconstruction for quantized logarithmic integers.
- Adds regression tests for denormalization, CFO, BlendSearch, and default
tune.run.
| File | Description |
|---|---|
test/tune/test_quantized_integer_bounds.py |
Adds bounds and grid-alignment regression tests across search paths. |
flaml/tune/space.py |
Clamps quantized integer values to valid grid bounds in both conversion paths. |
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Review update at 214db7e0aee7ea0cbb1f395b2bdce3dd14ca0be8: the submitted six regression cases pass on native Python 3.10 and 3.13 and fail on exact main. Please add a deterministic, Optuna-independent unflatten_hierarchical endpoint test, assert evaluated is nonempty in the final default-search test, and cover negative bounds in the ceiling/floor projection.
I checked the repeated Uniform qrandint grid concern against the explicit PR scope: a real BlendSearch run produces the same lower-anchored proposals on this head and main. That behavior is explicitly excluded here and the values stay inside the numeric bounds; I am not presenting it as an introduced P2 or asking this bounds fix to include unrelated grid changes.
The independent Medium review used gemini-4-carbon at high reasoning. Five of six required lenses have valid results; the remaining lens returned empty output again after its one allowed same-model recovery. All original results and failure diagnostics are committed locally with the scope adjudication. This execution coverage gap is not a contributor regression, but it prevents a complete clean signoff. No PR approval, thread resolution or review dismissal is submitted.
Posted by thinkall-agent-auto-reviewer
…ative bounds Add a search-backend-free unflatten_hierarchical endpoint test, negative-bound denormalize cases, and a non-empty check in the default-search test.
|
Thanks for the review, thinkall. I've addressed all three requested points and pushed the test updates in commit d6980b3.
Added a parametrized test that calls The test covers both flat and nested dictionary search spaces using The expected outputs for the raw values are:
The test also verifies that the resulting value is an integer.
Added an assertion that the evaluated results are non-empty in the final default-search test. This ensures the test verifies that the search actually evaluates configurations rather than passing without producing any results.
Added denormalization coverage for negative and mixed-sign bounds:
This extends coverage beyond positive-only integer ranges.
Verified the tests against both the PR implementation and the original implementation from main. With
On the PR head:
This confirms that the added tests detect the behavior addressed by the existing implementation.
Also ran:
Both pass, with 37 tests passed in total.
Commit d6980b3 modifies Summary All three review requests are covered with deterministic regression tests, including endpoint handling, non-empty search results, and negative quantized integer bounds. The tests demonstrate clear red/green behavior against the original implementation, while the source code remains unchanged in this commit. |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
All 16 selected quantized-bound cases pass on both native stacks. The deterministic nested endpoint cases and assert evaluated improve the test evidence.
One low-priority gap remains: upper=-2, q=3 already rounds to -3, so it does not independently exercise flooring the negative upper clamp. An entirely negative domain such as [-11, -1] with q=3 and expected endpoints [-9, -3] would require both clamps to work.
No new production failure is claimed. This Low test-only correction does not recover the earlier missing full Medium lens; its incomplete coverage and failed diagnostics remain retained.
Posted by thinkall-agent-auto-reviewer
|
Added the requested test case: qrandint(-11, -1, 3) with endpoints [-9, -3]. The test verifies that the upper clamp rounds down. Comparison with main: Using the current space.py from main, 13 tests fail and 4 pass. The new case passes with the PR change. |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The test-only delta at f237de8ea248a3377c3cc5f1689ff37ae6c2b773 is clean. The negative off-grid endpoints now detect both missing lower and upper clamps, and the targeted suites passed 34 tests across the two native stacks.
This is one Low review of the narrow test correction, not a replacement for the previously incomplete whole-PR Medium review. Its 5/6 coverage gap remains an approval blocker even with successful workflows and a Balanced approval recommendation.
All review evidence remains in detached local worktrees; nothing is pushed to this PR.
Posted by thinkall-agent-auto-reviewer
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.