Whether to sync the model weight.
(self)
| 203 | return batch, metrics, repr_samples |
| 204 | |
| 205 | async def need_sync(self) -> bool: |
| 206 | """Whether to sync the model weight.""" |
| 207 | if self.sync_style in {SyncStyle.FIXED, SyncStyle.TRAINER_DRIVEN, SyncStyle.FULLY_ASYNC}: |
| 208 | return ( |
| 209 | self.last_sync_step != self.train_step_num |
| 210 | and self.train_step_num % self.sync_interval == 0 |
| 211 | ) |
| 212 | else: # explorer driven |
| 213 | # for memory & checkpoint; TODO: apply to nccl sync |
| 214 | if self.last_sync_step == self.train_step_num and self.sync_method != SyncMethod.NCCL: |
| 215 | await self.synchronizer.notify_no_new_model_state_dict.remote() |
| 216 | return False |
| 217 | return await self.synchronizer.explorer_requires_sync.remote() |
| 218 | |
| 219 | def need_save(self) -> bool: |
| 220 | """Whether to save the checkpoint.""" |