mirror of
https://github.com/wassname/ray.git
synced 2026-07-15 11:25:40 +08:00
[tune] Cluster Fault Tolerance (#3309)
This PR introduces cluster-level fault tolerance for Tune by checkpointing global state. This occurs with relatively high frequency and allows users to easily resume experiments when the cluster crashes. Note that this PR may affect automated workflows due to auto-prompting, but this is resolvable.
This commit is contained in:
@@ -10,6 +10,7 @@ import io
|
||||
import logging
|
||||
import os
|
||||
import pickle
|
||||
from six import string_types
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
@@ -216,10 +217,11 @@ class Trainable(object):
|
||||
|
||||
checkpoint_dir = os.path.join(checkpoint_dir or self.logdir,
|
||||
"checkpoint_{}".format(self._iteration))
|
||||
os.makedirs(checkpoint_dir)
|
||||
if not os.path.exists(checkpoint_dir):
|
||||
os.makedirs(checkpoint_dir)
|
||||
checkpoint = self._save(checkpoint_dir)
|
||||
saved_as_dict = False
|
||||
if isinstance(checkpoint, str):
|
||||
if isinstance(checkpoint, string_types):
|
||||
if (not checkpoint.startswith(checkpoint_dir)
|
||||
or checkpoint == checkpoint_dir):
|
||||
raise ValueError(
|
||||
@@ -237,7 +239,9 @@ class Trainable(object):
|
||||
with open(checkpoint_path, "wb") as f:
|
||||
pickle.dump(checkpoint, f)
|
||||
else:
|
||||
raise ValueError("Return value from `_save` must be dict or str.")
|
||||
raise ValueError(
|
||||
"`_save` must return a dict or string type: {}".format(
|
||||
str(type(checkpoint))))
|
||||
pickle.dump({
|
||||
"experiment_id": self._experiment_id,
|
||||
"iteration": self._iteration,
|
||||
|
||||
Reference in New Issue
Block a user