Repository navigation
[2.7.0/tune] Fix hyperband r calculation and stopping (#39157) - #39451
Merged
Merged
Conversation
This PR fixes two flaws in the current hyperband implementation. #### 1. Bug in the `r` calculation. ray-project#1620 introduced a minimum constraint in the `r` calculation during successive halving with `r = min(r, max_t - prev_r)`. It's unclear to me where this is coming from (cc @richardliaw), but in my opinion this is flawed. E.g. for `s=1`, `max_t=8` and `eta=2`, we get `r0 = 4`. Then `r = r0 * 2 = 8`. With the current formula, we then get `r1 = min(r, max_t - r0) = min(8, 8-4) = 4`. Thus, `r0 = r1` and the bracket already "finished" after 4 iterations and should terminate all trials. Or in other words, none of the trials in this bracket will ever proceed. I believe the correct fix here is to set `r = min(r, max_t)`. I couldn't find a reference implementation for comparison, but it logically makes sense and seems to match the formula behavior described in the paper. #### 2. Stopping of "overstepped" trials. The first bug revealed a second shortcoming in the current implementation. When a trial reports a timestep that is higher than `r_i` and `r_(i+1)`, it can hang forever. This is because "good" trials are only continued if `bracket.continue_trial(t)` returns `True`. However, if the trial already overstepped `r_(i+1)`, this can return `False` (specifically when `stop_last_trials=True`). In that case, a paused or running trial will not be terminated nor continued, and instead hang forever. This second case is fixed in this PR by introducing another clause in the processing of "good" trials that checks for this condition. Signed-off-by: Kai Fricke <[email protected]>
Member
|
Pick of #39157 |
Contributor
|
@krfricke and @matthewdeng could you explain and confirm why this is a release blocker? |
matthewdeng
approved these changes
Sep 8, 2023
matthewdeng
left a comment
Contributor
There was a problem hiding this comment.
This is needed to work with the new persistence backend.
zhe-thoughts
approved these changes
Sep 9, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of 212cd04
This PR fixes two flaws in the current hyperband implementation.
1. Bug in the
rcalculation.#1620 introduced a minimum constraint in the
rcalculation during successive halving withr = min(r, max_t - prev_r). It's unclear to me where this is coming from (cc @richardliaw), but in my opinion this is flawed.E.g. for
s=1,max_t=8andeta=2, we getr0 = 4. Thenr = r0 * 2 = 8. With the current formula, we then getr1 = min(r, max_t - r0) = min(8, 8-4) = 4. Thus,r0 = r1and the bracket already "finished" after 4 iterations and should terminate all trials. Or in other words, none of the trials in this bracket will ever proceed.I believe the correct fix here is to set
r = min(r, max_t). I couldn't find a reference implementation for comparison, but it logically makes sense and seems to match the formula behavior described in the paper.2. Stopping of "overstepped" trials.
The first bug revealed a second shortcoming in the current implementation. When a trial reports a timestep that is higher than
r_iandr_(i+1), it can hang forever. This is because "good" trials are only continued ifbracket.continue_trial(t)returnsTrue. However, if the trial already oversteppedr_(i+1), this can returnFalse(specifically whenstop_last_trials=True). In that case, a paused or running trial will not be terminated nor continued, and instead hang forever.This second case is fixed in this PR by introducing another clause in the processing of "good" trials that checks for this condition.
Why are these changes needed?
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.