Periodic 'latest', 5M-step milestone, and best-gate checkpoints. state_fn() builds the dict only when a save actually happens.
(self, frames, state_fn, gate=None)
| 98 | return None |
| 99 | |
| 100 | def checkpoint(self, frames, state_fn, gate=None): |
| 101 | """Periodic 'latest', 5M-step milestone, and best-gate checkpoints. |
| 102 | state_fn() builds the dict only when a save actually happens.""" |
| 103 | if not self.ckpt_dir or not self.ckpt_every: |
| 104 | return |
| 105 | if frames - self.ckpt_last >= self.ckpt_every: |
| 106 | _atomic_save(state_fn(), os.path.join(self.ckpt_dir, "latest.pt")) |
| 107 | self.ckpt_last = frames |
| 108 | if frames - self.ms_last >= 5_000_000: |
| 109 | _atomic_save(state_fn(), os.path.join(self.ckpt_dir, f"step_{frames // 1_000_000}M.pt")) |
| 110 | self.ms_last = frames |
| 111 | if gate is not None and gate > self.best: |
| 112 | self.best = gate |
| 113 | _atomic_save(state_fn(), os.path.join(self.ckpt_dir, "best.pt")) |
| 114 | |
| 115 | def finalize(self, frames, game_returns, state_fn, k=100): |
| 116 | """Final 'latest' checkpoint + a final.json result summary.""" |
no test coverage detected