Skip to content

Commit f2008d2

Browse files
committed
Log frequency
1 parent c1c31a2 commit f2008d2

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

pufferlib/pufferl.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,14 @@ def _train(env_name, args, backend=_C, sweep_obj=None, result_queue=None, verbos
227227
model_path = os.path.join(checkpoint_dir, f'{pufferl.global_step:16d}.bin')
228228
backend.save_weights(pufferl, model_path)
229229

230-
# Rate-limit dashboard/logging to avoid overhead
231-
#if time.time() < pufferl.last_log_time + 0.6 and epoch != train_epochs - 1:
232-
# continue
230+
# Rate limit, but always log for eval to maintain determinism
231+
if time.time() < pufferl.last_log_time + 0.6 and epoch < train_epochs - 1:
232+
continue
233233

234234
logs = backend.eval_log(pufferl) if epoch >= train_epochs else backend.log(pufferl)
235235
flat_logs = {**flat_logs, **dict(unroll_nested_dict(logs))}
236236

237-
# TODO: determ without logging every epoch
238-
if verbose and epoch % 20 == 0:
237+
if verbose:
239238
print_dashboard(args, model_size, flat_logs)
240239

241240
if target_key not in flat_logs:
@@ -270,7 +269,7 @@ def _train(env_name, args, backend=_C, sweep_obj=None, result_queue=None, verbos
270269
n = args['sweep']['downsample']
271270
metrics = {k: [[]] for k in all_logs[0]}
272271
logged_timesteps = all_logs[-1]['agent_steps']
273-
next_bin = logged_timesteps / (n - 1)
272+
next_bin = logged_timesteps / (n - 1) if n > 1 else np.inf
274273
for log in all_logs:
275274
for k, v in log.items():
276275
metrics[k][-1].append(v)

0 commit comments

Comments
 (0)