mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
[tune] Node Fault Tolerance (#3238)
This PR introduces single-node fault tolerance for Tune. ## Previous behavior: - Actors will be restarted without checking if resources are available. This can lead to problems if we lose resources. ## New behavior: - RUNNING trials will be resumed on another node on a best effort basis (meaning they will run if resources available). - If the cluster is saturated, RUNNING trials on that failed node will become PENDING and queued. - During recovery, TrialSchedulers and SearchAlgorithms should receive notification of this (via `trial_runner.stop_trial`) so that they don’t wait/block for a trial that isn’t running. Remaining questions: - Should `last_result` be consistent during restore? Yes; but not for earlier trials (trials that are yet to be checkpointed). - Waiting for some PRs to merge first (#3239) Closes #2851.
This commit is contained in:
@@ -85,9 +85,10 @@ class Checkpoint(object):
|
||||
MEMORY = "memory"
|
||||
DISK = "disk"
|
||||
|
||||
def __init__(self, storage, value):
|
||||
def __init__(self, storage, value, last_result=None):
|
||||
self.storage = storage
|
||||
self.value = value
|
||||
self.last_result = last_result
|
||||
|
||||
@staticmethod
|
||||
def from_object(value=None):
|
||||
@@ -277,6 +278,14 @@ class Trial(object):
|
||||
def has_checkpoint(self):
|
||||
return self._checkpoint.value is not None
|
||||
|
||||
def should_recover(self):
|
||||
"""Returns whether the trial qualifies for restoring.
|
||||
|
||||
This is if a checkpoint frequency is set, which includes settings
|
||||
where there may not yet be a checkpoint.
|
||||
"""
|
||||
return self.checkpoint_freq > 0
|
||||
|
||||
def update_last_result(self, result, terminate=False):
|
||||
if terminate:
|
||||
result.update(done=True)
|
||||
|
||||
Reference in New Issue
Block a user