mirror of
https://github.com/wassname/ray.git
synced 2026-08-03 13:10:57 +08:00
[tune] Prevent MEMORY checkpoints from breaking trial FT (#6691)
* Prevent MEMORY checkpoints from breaking FT * Add save/pause/resume/restore test * change checkpoint return value based on status * Fix test_checkpoint_manager_tests. * Fix test + checkpoint manager bug * lint * Add docstring * Add docstring to checkpoint_manager constructor * Change variable name for clarity * Revert on_checkpoint docstring wording * Break after success * nit: more informative warning * Quarantine test
This commit is contained in:
committed by
Richard Liaw
parent
0834bda8c1
commit
1558307ac4
@@ -172,13 +172,12 @@ class RayTrialExecutor(TrialExecutor):
|
||||
See `RayTrialExecutor.restore` for possible errors raised.
|
||||
"""
|
||||
prior_status = trial.status
|
||||
self.set_status(trial, Trial.RUNNING)
|
||||
trial.set_runner(
|
||||
runner or self._setup_remote_runner(
|
||||
trial,
|
||||
reuse_allowed=checkpoint is not None
|
||||
or trial.has_checkpoint()))
|
||||
if runner is None:
|
||||
reuse_allowed = checkpoint is not None or trial.has_checkpoint()
|
||||
runner = self._setup_remote_runner(trial, reuse_allowed)
|
||||
trial.set_runner(runner)
|
||||
self.restore(trial, checkpoint)
|
||||
self.set_status(trial, Trial.RUNNING)
|
||||
|
||||
previous_run = self._find_item(self._paused, trial)
|
||||
if prior_status == Trial.PAUSED and previous_run:
|
||||
@@ -421,6 +420,11 @@ class RayTrialExecutor(TrialExecutor):
|
||||
def _update_avail_resources(self, num_retries=5):
|
||||
resources = None
|
||||
for i in range(num_retries):
|
||||
if i > 0:
|
||||
logger.warning(
|
||||
"Cluster resources not detected or are 0. Attempt #"
|
||||
"%s...", i + 1)
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
resources = ray.cluster_resources()
|
||||
except Exception:
|
||||
@@ -428,10 +432,8 @@ class RayTrialExecutor(TrialExecutor):
|
||||
# https://github.com/ray-project/ray/issues/4147
|
||||
logger.debug("Using resources for local machine.")
|
||||
resources = ResourceSpec().resolve(True).to_resource_dict()
|
||||
if not resources:
|
||||
logger.warning(
|
||||
"Cluster resources not detected or are 0. Retrying...")
|
||||
time.sleep(0.5)
|
||||
if resources:
|
||||
break
|
||||
|
||||
if not resources:
|
||||
# NOTE: This hides the possibility that Ray may be waiting for
|
||||
@@ -555,14 +557,14 @@ class RayTrialExecutor(TrialExecutor):
|
||||
"""Saves the trial's state to a checkpoint.
|
||||
|
||||
Args:
|
||||
trial (Trial): The state of this trial to be saved.
|
||||
trial (Trial): The trial to be saved.
|
||||
storage (str): Where to store the checkpoint. Defaults to
|
||||
PERSISTENT.
|
||||
result (dict): The state of this trial as a dictionary to be saved.
|
||||
If result is None, the trial's last result will be used.
|
||||
|
||||
Returns:
|
||||
Checkpoint future, or None if an Exception occurs.
|
||||
Checkpoint object, or None if an Exception occurs.
|
||||
"""
|
||||
result = result or trial.last_result
|
||||
|
||||
@@ -588,11 +590,17 @@ class RayTrialExecutor(TrialExecutor):
|
||||
"syncs by setting sync_on_checkpoint=False. Note that this "
|
||||
"might result in faulty trial restoration for some worker "
|
||||
"failure modes.")
|
||||
return checkpoint.value
|
||||
return checkpoint
|
||||
|
||||
def restore(self, trial, checkpoint=None):
|
||||
"""Restores training state from a given model checkpoint.
|
||||
|
||||
Args:
|
||||
trial (Trial): The trial to be restored.
|
||||
checkpoint (Checkpoint): The checkpoint to restore from. If None,
|
||||
the most recent PERSISTENT checkpoint is used. Defaults to
|
||||
None.
|
||||
|
||||
Raises:
|
||||
RuntimeError: This error is raised if no runner is found.
|
||||
AbortTrialExecution: This error is raised if the trial is
|
||||
|
||||
Reference in New Issue
Block a user