MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / restore_weights

Method restore_weights

utils/pl_utils.py:599–626  ·  view source on GitHub ↗

To restore weights we have two cases. First, attempt to restore hpc weights. If successful, don't restore other weights. Otherwise, try to restore actual weights :param model: :return:

(self, model)

Source from the content-addressed store, hash-verified

597 # restore ckpt
598 # --------------------
599 def restore_weights(self, model):
600 """
601 To restore weights we have two cases.
602 First, attempt to restore hpc weights. If successful, don't restore
603 other weights.
604
605 Otherwise, try to restore actual weights
606 :param model:
607 :return:
608 """
609 # clear cache before restore
610 if self.on_gpu:
611 torch.cuda.empty_cache()
612
613 if self.resume_from_checkpoint is not None:
614 self.restore(self.resume_from_checkpoint, on_gpu=self.on_gpu)
615 else:
616 # restore weights if same exp version
617 self.restore_state_if_checkpoint_exists(model)
618
619 # wait for all models to restore weights
620 if self.use_ddp:
621 # wait for all processes to catch up
622 dist.barrier()
623
624 # clear cache after restore
625 if self.on_gpu:
626 torch.cuda.empty_cache()
627
628 def restore_state_if_checkpoint_exists(self, model):
629 did_restore = False

Callers 1

run_pretrain_routineMethod · 0.95

Calls 2

restoreMethod · 0.95

Tested by

no test coverage detected