[train][tests] Abort cancels validation tasks and has deterministic behavior#61510
Open
TimothySeah wants to merge 2 commits intoray-project:masterfrom
Open
[train][tests] Abort cancels validation tasks and has deterministic behavior#61510TimothySeah wants to merge 2 commits intoray-project:masterfrom
TimothySeah wants to merge 2 commits intoray-project:masterfrom
Conversation
…ehavior Signed-off-by: Timothy Seah <tseah@anyscale.com>
python/ray/train/v2/_internal/execution/checkpoint/validation_manager.py
Show resolved
Hide resolved
Signed-off-by: Timothy Seah <tseah@anyscale.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request aims to fix a race condition during validation task cancellation upon run abortion. The changes introduce a before_controller_abort hook to explicitly cancel pending validation tasks and make the corresponding test more deterministic by using SIGINT instead of ray.cancel. The overall approach is sound, but I've found a critical issue where the new before_controller_abort hook is not actually called, which means the fix for cancelling validation tasks is incomplete. I've provided a detailed comment with a suggested fix.
Note: Security Review did not run due to the size of the PR.
python/ray/train/v2/_internal/execution/checkpoint/validation_manager.py
Show resolved
Hide resolved
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.
Summary
We observed the following flaky behavior in
test_report_validation_fn_resumptionEssentially what happened was
ray.cancelSIGINTto the trainer and recursively cancelled the validation taskSIGINTmade Ray Train go through the abortion code, which includes transitioning to theABORTEDstateafter_controller_state_updatesometimes (I think there's a race between whenafter_controller_state_updateis called and when the validation task is cancelled) saw the cancelled validation task and updated the metrics accordingly.This PR avoids this race by:
after_controller_state_updateto do nothing if the state is terminal. We will process validation tasks fromFINISHEDandERROREDtrain runs inbefore_controller_shutdownand cancel validation tasks inABORTEDtrain runs inbefore_controller_abort.test_report_validation_fn_resumptionto SIGINT a process (the same pattern astest_sigint_abort) rather thanray.cancela task (the old pattern) to deterministically test the graceful abortion path.Testing
Unit tests.