MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / need_sync

Method need_sync

trinity/trainer/trainer.py:205–217  ·  view source on GitHub ↗

Whether to sync the model weight.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers 1

trainMethod · 0.95

Calls 1

remoteMethod · 0.80

Tested by

no test coverage detected