[tune] Add a time/timesteps since last restore metric (#2819)

* rsm

* always log to avoid changing schema for csv writer

* add iter since restore

* update

* criteria warn
This commit is contained in:
Eric Liang
2018-09-05 17:45:09 -07:00
committed by GitHub
parent 995ac24a2c
commit d81605e9e7
4 changed files with 48 additions and 2 deletions
+12 -1
View File
@@ -75,6 +75,10 @@ class Trainable(object):
self._iteration = 0
self._time_total = 0.0
self._timesteps_total = None
self._time_since_restore = 0.0
self._timesteps_since_restore = 0
self._iterations_since_restore = 0
self._restored = False
self._setup()
self._initialize_ok = True
self._local_ip = ray.services.get_node_ip_address()
@@ -143,12 +147,14 @@ class Trainable(object):
result = result.copy()
self._iteration += 1
self._iterations_since_restore += 1
if result.get(TIME_THIS_ITER_S) is not None:
time_this_iter = result[TIME_THIS_ITER_S]
else:
time_this_iter = time.time() - start
self._time_total += time_this_iter
self._time_since_restore += time_this_iter
result.setdefault(DONE, False)
@@ -157,6 +163,7 @@ class Trainable(object):
if self._timesteps_total is None:
self._timesteps_total = 0
self._timesteps_total += result[TIMESTEPS_THIS_ITER]
self._timesteps_since_restore += result[TIMESTEPS_THIS_ITER]
# self._timesteps_total should not override user-provided total
result.setdefault(TIMESTEPS_TOTAL, self._timesteps_total)
@@ -176,7 +183,10 @@ class Trainable(object):
pid=os.getpid(),
hostname=os.uname()[1],
node_ip=self._local_ip,
config=self.config)
config=self.config,
time_since_restore=self._time_since_restore,
timesteps_since_restore=self._timesteps_since_restore,
iterations_since_restore=self._iterations_since_restore)
self._result_logger.on_result(result)
@@ -248,6 +258,7 @@ class Trainable(object):
self._iteration = metadata[1]
self._timesteps_total = metadata[2]
self._time_total = metadata[3]
self._restored = True
def restore_from_object(self, obj):
"""Restores training state from a checkpoint object.