MCPcopy Create free account
hub / github.com/Sin3DM/Sin3DM / save

Method save

src/diffusion/train_util.py:258–281  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

256 self.tb.add_scalar("lr", self.opt.param_groups[0]["lr"], global_step=self.step)
257
258 def save(self):
259 def save_checkpoint(rate, params):
260 state_dict = self.mp_trainer.master_params_to_state_dict(params)
261 # if dist.get_rank() == 0:
262 logger.log(f"saving model {rate}...")
263 if not rate:
264 filename = f"model{(self.step+self.resume_step):06d}.pt"
265 else:
266 filename = f"ema_{rate}_{(self.step+self.resume_step):06d}.pt"
267 with bf.BlobFile(bf.join(get_blob_logdir(), filename), "wb") as f:
268 th.save(state_dict, f)
269
270 # save_checkpoint(0, self.mp_trainer.master_params)
271 for rate, params in zip(self.ema_rate, self.ema_params):
272 save_checkpoint(rate, params)
273
274 # if dist.get_rank() == 0:
275 with bf.BlobFile(
276 bf.join(get_blob_logdir(), f"opt{(self.step+self.resume_step):06d}.pt"),
277 "wb",
278 ) as f:
279 th.save(self.opt.state_dict(), f)
280
281 # dist.barrier()
282
283 def log_loss_dict(self, diffusion, ts, losses):
284 for key, values in losses.items():

Callers 5

run_loopMethod · 0.95
save_checkpointMethod · 0.80
save_mesh_with_texFunction · 0.80
save_mesh_with_pbrFunction · 0.80
save_ckptMethod · 0.80

Calls 1

get_blob_logdirFunction · 0.85

Tested by

no test coverage detected