[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:
Richard Liaw
2018-12-29 11:42:25 +08:00
committed by GitHub
parent 382b138fc7
commit aad3c50e2d
16 changed files with 806 additions and 128 deletions
+7 -3
View File
@@ -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,