Repository navigation
fix: compare the first lexicographic result with the incumbent in FLOW2 - #1669
Anish Mehta (anishmehta24) wants to merge 8 commits into
Conversation
With lexico_objectives, FLOW2.lexico_compare started its history from the first result it was given and returned True without comparing it. on_trial_complete only calls it once there is an incumbent, so the incumbent's own result never entered the history and the next result always replaced it, even when it was worse. With a single objective, losses 1.0 then 5.0 left 5.0 as the incumbent. The history now starts with the incumbent, and the first result goes through the same comparison as every later one.
There was a problem hiding this comment.
🟡 Changes recommended
The comparison rejects valid lexicographic improvements when a higher-priority objective ties at the tolerance boundary, requiring inclusive bounds and a two-objective regression test.
1 open issue
What changed in this PR
This PR fixes FLOW2’s lexicographic history initialization so the first candidate is compared with the incumbent rather than automatically replacing it.
Changes:
- Seed objective histories with the incumbent and apply the existing comparison logic to the first candidate.
- Add single-objective regression tests for minimization and maximization.
| File | Description |
|---|---|
test/tune/test_lexico_flow2.py |
Checks that lexicographic and plain FLOW2 retain the same incumbents for one objective. |
flaml/tune/searcher/flow2.py |
Initializes history from the incumbent and removes unconditional acceptance of the first comparison. |
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Confirmed the current-head Copilot correctness concern: a tied primary objective rejects a valid secondary improvement. With native FLOW2, two minimization objectives, zero tolerances/default targets, and results {"a": 1.0, "b": 5.0} followed by {"a": 1.0, "b": 2.0}, the current implementation keeps {"a": 1.0, "b": 5.0}. The same actual searcher event sequence on exact main f2427d802ae9ca23c2d99bef970373272afc5df1 updates the incumbent to {"a": 1.0, "b": 2.0}. The newly entered comparison treats equality at the tolerance bound as a rejection instead of advancing to the next objective. Please handle inclusive tolerance boundaries and add a two-objective tied-primary regression. This is native FLOW2 state-machine validation, not a full AutoML HPO run. The submitted single-objective tests pass on both native stacks but do not cover this discriminator. I am referencing the existing peer concern, not duplicating or resolving its inline thread.
The required Medium independent review-code lens batch is still running; no complete six-lens or clean whole-PR signoff is claimed at this point. These driver-confirmed P2 findings justify the changes request independently of pending CI. No approval is submitted and no earlier review was dismissed.
Posted by thinkall-agent-auto-reviewer
With zero tolerance, a result that tied the incumbent on a higher-priority objective failed the strict "<" bound check and was rejected without looking at the next objective, so (1, 3) did not replace (1, 5). Use "<=" like update_fbest and lexico_best in tune.py.
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The zero-tolerance primary-tie correction is verified: the three regression cases now pass on native Python 3.10 and 3.13. There is still a P2: an initial NaN incumbent makes the next finite trial crash in the new history-seeding path.
With FLOW2(init_config={"x": 0.5}, metric="a", mode="min", space={"x": tune.uniform(0, 1)}, lexico_objectives={"metrics": ["a", "b"], "modes": ["min", "min"], "tolerances": {}, "targets": {}}), use the normal suggest / on_trial_complete callbacks for these two results:
{"a": float("nan"), "b": 5.0}
{"a": 1.0, "b": 3.0}The second completion raises ValueError: zero-size array to reduction operation minimum which has no identity. Seeding _histories with the NaN incumbent makes the feasible set empty before the second objective's reduction. Please handle non-finite incumbents/history without losing the finite follow-up, and add this regression.
I reproduced this through the public callbacks on both native stacks: current a318784a0fa9e62458b4db3f6b8c388c3237a6f1 and the previous PR head fail; exact main recovers to (a=1,b=3). This is a remaining regression from the full PR, not a claim that the latest tie-only correction introduced it. Other reported percentage/tightened-tie behavior also exists on main and is not being relabeled as new here.
The current independent Medium batch has five valid dirty lenses and one retained empty-response failure; its single same-model recovery is pending. The completed evidence and this bounded verification are committed locally. No clean overall signoff, approval, foreign-thread resolution or prior-review dismissal is claimed.
Posted by thinkall-agent-auto-reviewer
A NaN incumbent seeded into the history made update_fbest's feasible set empty, so the next result raised a ValueError. NaN now counts as the worst value in lexico_compare, for both the history and the comparisons.
|
Fixed in b54c223. |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The reported initial-NaN crash is corrected at b54c22393f2177d7f5aee42125914a2b086d26a8: four current cases pass on each native stack, while the same definitions fail once on the preceding source; public callback probes now recover to the finite incumbent (1,3).
A finite-objective compatibility regression remains in the new np.isnan check. With one minimized metric, normal FLOW2.suggest / on_trial_complete calls reporting Fraction(2,3) and then Fraction(1,3) now raise TypeError: ufunc 'isnan' not supported for the input types on the second completion. The exact preceding implementation accepts the improvement to 1/3. Both native stacks reproduce the difference.
Please detect scalar NaN without unnecessarily restricting previously comparable finite numeric values, and add the finite-fraction case. Also narrow the regression comment: a better primary objective can legitimately win even when a lower-priority objective is NaN; that is not whole-trial NaN rejection.
The latest 3,499-byte author delta was independently reviewed through review-code using gpt-6.2-astra at maximum reasoning. Its original findings and native evidence are committed locally. This bounded correction review is not a new clean whole-PR or Ray/Spark compatibility clearance, and the old-head NaN finding is not being falsely reported as still reproduced here. No approval, thread resolution or prior-review dismissal is submitted.
Posted by thinkall-agent-auto-reviewer
np.isnan raised a TypeError for objective values such as Fraction or Decimal, which compared fine before. v != v is only true for NaN and works for any comparable value.
|
Fixed in 2f5a3e3. NaN is now detected with |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The Fraction/Decimal correction and revised NaN-priority assertion are verified at 2f5a3e3e1e7d70eaa9055c39b6ade47d39f47eac: six current cases pass on each native Python 3.10/3.13 stack, versus two expected non-float failures and four controls on the preceding source.
P2: mixed max/min feasibility can still reject the next valid improvement. With metrics ["a","b"], modes ["max","min"], tolerances {"a":1.0,"b":10.0}, and default targets, complete these results through normal FLOW2 callbacks:
(a=9.5, b=55)
(a=1.0, b=0)
(a=10.0, b=58)
Current FLOW2 retains (9.5,55); exact main and the project's own ExperimentAnalysis.lexico_best choose (10,58). Both native stacks reproduce this without injecting search history. The primary-poor (1,0) should not set the secondary feasible best to 0, but update_fbest uses the un-negated default +inf target for the maximized objective. It then rejects the last point against a secondary bound of 10 instead of the feasible bound of 65.
Please make the helper's target normalization consistent with lexico_compare / lexico_best and add this mixed-mode regression. The underlying filter predates the PR; changed incumbent seeding exposes the different final selection. This is a remaining whole-PR interaction, not a regression introduced by the latest v != v correction, and main's intermediate acceptance of the bad first candidate is not being endorsed.
The current author delta received the required Low review-code review using actual gpt-6.2-astra at maximum reasoning; its original findings, baseline qualifications and native proof are committed locally. No whole-PR clean, full Tune/Ray/Spark matrix, PR approval, thread resolution or prior-review dismissal is claimed.
Posted by thinkall-agent-auto-reviewer
update_fbest compared the minimized histories with the raw target, so the default +inf target of a "max" objective made every result feasible on it. A result far outside the tolerance could then set the bound on the next objective and block a valid improvement. Negate the target as lexico_compare and lexico_best in tune.py do.
|
Fixed in b9db3b7. |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The max-target correction fixes the earlier absolute-tolerance case, including the public factory path. All seven submitted regression cases pass on Python 3.10 and 3.13 (14 passes).
Changes requested for the existing percentage-max tolerance discussion. I independently reproduced it on this head using public FLOW2 callbacks: modes ["max", "min"], tolerances {"a": "10%", "b": 0}, default targets, and results (10, 5) then (11, 4). The second completion raises ValueError: zero-size array to reduction operation minimum which has no identity. With minimized best -11, the percentage bound becomes -12.1; the newly negated default target is -inf, so the primary feasible prefix becomes empty.
Preceding 2f5a3e3 and exact main f2427d8 complete that case on both native stacks. Current on_trial_result followed by on_trial_complete also triggers the crash. Please make percentage slack sign-aware in both bound calculations, preserve infinite/zero-percent behavior, and add regression coverage. I have not duplicated the existing inline finding or resolved its thread.
Low-priority full-PR follow-up: exact zero-tolerance ties return None from the annotated Boolean lexico_compare method, versus False on main. Internal callers treat both as falsey, but an explicit final return False would preserve the method contract.
Validation above uses public callbacks and the actual project analysis oracle for the fixed absolute-tolerance case; it is not a full Tune/Ray/Spark run.
Posted by thinkall-agent-auto-reviewer
A percentage tolerance was applied as f_best * (1 + p), which moves a negative best value down. A "max" objective is negated, so its bound fell below every result and, with the negated default target of -inf, update_fbest raised a ValueError. Negative best values now move up by the same percentage, in one helper used by update_fbest and lexico_compare. Infinite values and 0% keep their bound as before. lexico_compare also returns False explicitly when every objective ties.
|
Fixed in b4e07e1. A percentage tolerance now moves a negative best value up instead of down, in one helper used by
|
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because percentage-bound handling remains inconsistent in final trial selection, causing best-result access to raise ValueError for mixed max/min objectives.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The percentage-bound and Boolean-return corrections are verified: all eleven submitted cases pass on Python 3.10 and 3.13 (22 passes). A remaining full-PR state-reset regression still blocks approval.
P2: reconfiguring FLOW2 can accept a strictly worse primary objective at zero tolerance. Using metrics ["a", "b"], modes ["min", "min"], zero tolerances and default targets, complete (100, 5) and (90, 6), call public set_search_properties(config=...), then complete (1, 10) and (2, 0). Current and preceding PR source finish at (2, 0); exact main retains (1, 10) on both native stacks. All observations were delivered through suggest/on_trial_complete; no histories were injected.
_init_search resets best_obj but leaves _histories and _f_best behind, so the new first incumbent is omitted from the old history. The changed inclusive comparison then treats the worse primary value as feasible and advances to the improved secondary value. Please reset the coupled history/best-bound state when resetting the searcher and add this public lifecycle regression. This defect remains from the earlier full-PR changes; I am not attributing it to the latest percentage helper.
Separately, actual sequential CFO/Tune percentage best_result errors reproduce on exact main as well as preceding/current source, so they are retained as inherited integration follow-ups rather than mislabeled new regressions. Decimal/Fraction percentage and malformed-tolerance limitations likewise need separate qualification; passing the new unit cases is not full Tune/Ray/Spark clearance.
The full Medium review remains blocked at 4/6 valid lenses after one bounded missing-output recovery for each failed lens. Every failure is retained as such; none is counted as independent signoff.
Posted by thinkall-agent-auto-reviewer
_init_search, which set_search_properties(config=...) calls, reset best_obj but kept _histories and _f_best. The new first incumbent was then missing from the old history, so with zero tolerance a result with a worse first objective could replace it. Both are now reset with it.
|
Fixed in ce95e06. |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
The history-reset correction addresses the previously reported reset regression. All 12 regression cases pass on Python 3.10 and 3.13 (24 passes), while the new reset case fails on the preceding head in both stacks. The skill-owned Astra/max review is clean for this author delta.
Approval remains blocked. The current Ubuntu/Python3.12 Build job failed. Its log shows MLflow FileStore run-metadata YAML parsing errors; I have not established what produced the malformed metadata or attributed it to this correction.
The prior whole-PR Medium review also remains incomplete at 4/6 valid lenses after exhausted bounded recoveries. A clean Low correction does not replace that required coverage or erase the retained whole-PR follow-ups. No failed reviewer was counted as signoff, and no prior review or foreign thread was dismissed or resolved.
Posted by thinkall-agent-auto-reviewer
|
The ubuntu 3.12 failure looks unrelated: the same 40 tune tests fail with the same |

Why are these changes needed?
With
lexico_objectives,FLOW2.lexico_comparebuilt its history from the first result it got and returnedTruewithout comparing it. It is only called once there is an incumbent (andcreate()starts every local search thread with one), so the incumbent's own result never entered the history and the next result always replaced it, even when it was worse. With one objective and losses 1.0, 5.0, 3.0, 0.5, 2.0, plain FLOW2 keeps the 1.0 incumbent until 0.5 comes in, while lexicographic FLOW2 moves to 5.0 and then 3.0.The history now starts with the incumbent, and the first result goes through the same comparison as later ones. The tolerance bound checks in
lexico_comparenow use<=likeupdate_fbest, so a tie on a higher-priority objective is decided by the next one: with zero tolerances, (1, 3) replaces (1, 5) instead of being rejected.A NaN objective now counts as the worst value in
lexico_compare(detected withv != v, so values likeFractionstill work). Before, a NaN incumbent in the history emptied the feasible set inupdate_fbest, and the next result raised aValueError.update_fbestnow negates the target of a "max" objective, aslexico_compareandExperimentAnalysis.lexico_bestdo. It compared the minimized history with the raw target, so the default+inftarget made every result feasible on that objective. With modes max/min, tolerances 1 and 10, and results (9.5, 55), (1, 0), (10, 58), the (1, 0) result set the bound on "b" to 10 and (10, 58) was rejected.A percentage tolerance is now applied so that it also loosens the bound when the best value is negative, in one helper used by
update_fbestandlexico_compare. It wasf_best * (1 + p), and a "max" objective is negated, so with the negated default target every result fell outside the bound andupdate_fbestraised aValueError(modes max/min, tolerance "10%" on "a", results (10, 5) then (11, 4)). Infinite values and 0% keep the same bound._init_search, whichset_search_properties(config=...)calls, now resets the lexicographic history along with the incumbent. Before, the new first incumbent was missing from the old history, so with zero tolerances a (2, 0) result replaced a (1, 10) incumbent after a reset.Related issue number
None found.
Checks
test/tune/test_lexico_flow2.py(min and max mode, a two-objective tie case, NaN results, Fraction/Decimal objectives, a mixed max/min case, percentage tolerances on negative values, and aset_search_propertiesreset) passes with the change; all but the Fraction/Decimal, 0%, inf and reset cases fail on main. The rest ofpytest test/tunepasses, apart fromtest_no_optuna, which callspip uninstalland fails the same way on main in my venv. On the Branin-Currin setup fromtest_lexiflow_performance, the best currin is 2.05 (2.18 on main), still within the test's 2.2 check. Most of the diff inflow2.pyis re-indentation from removing theelse;git diff -wshows the actual change.