Repository navigation
fix(earlystopping): use the median of Trial averages in medianstop - #2747
Open
parth-patel010 wants to merge 1 commit into
Open
parth-patel010 wants to merge 1 commit into
parth-patel010 wants to merge 1 commit into
Conversation
The medianstop service averaged the completed Trials' running averages instead of taking their median, so a single outlier Trial could move the early stopping threshold and stop Trials that are better than the median. Use statistics.median and add a unit test that mocks the DB manager logs. Signed-off-by: parth-patel010 <parthp12321@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
google-oss-prow
Bot
requested review from
anencore94,
gaocegege and
johnugeorge
November 4, 2026 14:44
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.
What this PR does / why we need it:
The
medianstopearly stopping service was computing the mean of the completed Trials' running averages and using that as the "median" threshold. With one outlier Trial the threshold moves a lot, so Trials that are better than the median can get early stopped (or bad ones keep running). For averages 0.1, 0.2 and 0.9 on aMAXIMIZEobjective, the rule wasaccuracy < 0.4instead ofaccuracy < 0.2.This switches the calculation to
statistics.median, which matches the docs ("the median value of the running averages of all completed Trials") and the original median stopping rule.I also added a unit test that mocks the DB manager's
GetObservationLogresponses for three succeeded Trials and checks the returned rule (name, comparison, start_step and value). The existingGetEarlyStoppingRulestest only checks the status code. The new test fails on master (0.4 != 0.2) and passes with this change.pytest test/unit/v1beta1/earlystopping: 3 passed. pre-commit (isort, black, flake8) is clean on the changed files.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #2746
Checklist: