See `BaseCheckpointer.save` for details. In addition to behavior in `BaseCheckpointer`, saving only happens if the configured checkpoint policy returns True for the given step and evaler summaries.
(
self, *, step: int, state: NestedTensor, evaler_summaries: Optional[dict[str, Any]] = None
)
| 1106 | return build_step_dir(cfg.dir, step=step) |
| 1107 | |
| 1108 | def save( |
| 1109 | self, *, step: int, state: NestedTensor, evaler_summaries: Optional[dict[str, Any]] = None |
| 1110 | ): |
| 1111 | """See `BaseCheckpointer.save` for details. |
| 1112 | |
| 1113 | In addition to behavior in `BaseCheckpointer`, saving only happens if the configured |
| 1114 | checkpoint policy returns True for the given step and evaler summaries. |
| 1115 | """ |
| 1116 | if not self._save_policy(step=step, evaler_summaries=(evaler_summaries or {})): |
| 1117 | return |
| 1118 | if step < 0 or step >= 10**8: |
| 1119 | raise ValueError(f"Out-of-range: {step}") |
| 1120 | ckpt_dir = self.ckpt_dir(step) |
| 1121 | self._storage.save_to_dir( |
| 1122 | step=step, state=state, ckpt_dir=ckpt_dir, on_commit_callback=self._index_writer |
| 1123 | ) |
| 1124 | if "summary_writer" in self.children: |
| 1125 | self.summary_writer.log_checkpoint( |
| 1126 | step=step, |
| 1127 | state=state, |
| 1128 | ckpt_dir=ckpt_dir, |
| 1129 | action=CheckpointerAction.SAVE, |
| 1130 | ) |
| 1131 | |
| 1132 | def _run_garbage_collection(self): |
| 1133 | """Runs one round of garbage collection of past checkpoints. |