Repository navigation
Keep quantized integer configs inside the search space bounds - #1667
Sohail Shaikh (sohailshk) wants to merge 12 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
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Clean imported-base integration only, reviewed at 2038778ef7f4018ebbc20350fb3e406ef221b7df.
The new foreign SVC constructor change preserves explicit random_state (including None), consumes the random_seed alias, and retains clone/stacking behavior. The imported default forest classifier change leaves preprocessing to predict_proba, avoiding a second transformation while leaving regressor behavior unchanged. The selected tests pass14cases on each pinned stack (28for this head); the representative old-source controls fail26cases and pass2across stacks.
Exact merge-parent and changed-path checks show this is base alignment, not a new edit to this PR's original feature. The separate own-authored release README/docs/version paths were excluded from review. Independent Low coverage is1/1 at the live maximum reasoning, with a CLEAN verdict only for this imported-code scope. This does not resolve existing feature findings, active change requests, missing whole-PR evidence or prior safety stops, and is not overall PR approval.
All-files hooks passed for the retained local evidence commit. No contributor source was edited and no review outputs were pushed here.
At 2026-12-04T02:22:52.927435+00:00, checks=FAILURE; actual current-head workflows: docs=completed/success; Build=in_progress/None; Code formatting=completed/success. Balanced Copilot approval recommendation=True; unresolved threads=0. Workflow permission is not CI success. Existing approval records, if retargeted by a base merge, are not a fresh whole-source or CI signoff.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Imported FLOW2 integration only, reviewed at 25c5a6ff08c27a0ad4f47e3fdf93ebc04c352bee.
The imported unordered categorical choice correction picks an index instead of allowing NumPy to coerce the choice values. Tuple/mixed choices, movement and seeded draws pass14cases on each pinned stack (28for this head). Exact merge/path proofs show no new feature-author edit in this branch. Existing branch-feature findings, active change requests and missing whole-PR coverage are not cleared by this new-base review.
Independent Low coverage1/1 at maximum reasoning; original CLEAN outcome is retained. This narrow verdict is not whole-PR code-review clearance and cannot reset prior safety/coverage bounds.
All-files hooks passed for the retained local evidence commit. Own-authored workflow/package-metadata changes were excluded; no contributor source was edited and no review outputs were pushed here.
At 2026-12-04T07:22:11.970204+00:00, checks=PENDING; actual current-head workflows: Code formatting=completed/success; Build=in_progress/None; docs=completed/success. Balanced Copilot approval recommendation=True; unresolved threads=0. Workflow permission is not CI success.
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.