Repository navigation
fix: keep processing the search space after a list low-cost point - #1637
Li Jiang (thinkall) merged 4 commits into
Conversation
add_cost_to_space returned from inside the loop when a categorical had a list low-cost point, so the keys after it never got their low_cost_point, bounded flag or categorical const, and the function returned None instead of the constants. A later nested choice then crashed BlendSearch with AttributeError: 'Categorical' object has no attribute 'const'.
There was a problem hiding this comment.
🟢 Approval recommended
The localized control-flow fix addresses the reported failure and includes focused regression coverage.
No open issues 🎉
What changed in this PR
Fixes premature termination in add_cost_to_space so search-space initialization continues after a categorical list low-cost point.
Changes:
- Replaces
returnwithcontinueto process remaining keys and return constants. - Adds regression coverage for initialization and successful
tune.runexecution.
| File | Description |
|---|---|
| test/tune/test_space.py | Tests subsequent keys, returned constants, and tuning execution. |
| flaml/tune/space.py | Continues initialization after handling a list low-cost point. |
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review of the complete PR: no blocking code issue found; approval withheld pending CI.
Replacing the early return with continue preserves list-valued categorical handling while allowing later domains to be initialized and the constant dictionary to be returned. The focused test module passed all 3 tests locally, including the added tuning regression. The review-code harness is clean and Copilot's current Balanced review recommends approval with no open issues. Build checks on the current head are failing, so it does not satisfy the all-CI-passed approval gate. This is a formal comment review, not an approval.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review at 7184aca9c957e58fe2176a51579f1e454cbaa122: re-reviewed the complete PR with review-code, including recursive categorical initialization and downstream consumers. Continuing the outer loop after handling a list low-cost point preserves that category's handling while allowing later constants, bounds, and nested choices to be initialized and the constants dictionary to be returned. No remaining correctness issue found.
Validation: python -m pytest test\tune\test_space.py -q --disable-warnings passed (3 passed). The new regression checks suffix constants, low-cost metadata, boundedness, subsequent nested-category initialization, and ten completed tuning trials. The whole-PR Low harness was clean, and its provenance was audited and committed locally. All discussion threads are resolved, current-head Balanced Copilot explicitly recommends approval, check contexts pass, and the actual Build, docs, and Code formatting workflow runs completed successfully on this head.
Posted by thinkall-agent-auto-reviewer
Why are these changes needed?
add_cost_to_spaceloops over the keys of the search space, but when a categorical has a list low-cost point (one low-cost config per choice) it hits areturninside the loop. Every key after it is skipped: nolow_cost_point, nobounded, and nested choices never get theirconst. The function also returnsNoneinstead of the constants.With a second nested choice after the first one,
tune.runcrashes:Changing the
returntocontinuekeeps what happens for that key and lets the loop finish.Related issue number
None found.
Checks
test_add_cost_to_space_keys_after_nested_choicefails on main and passes with the change.