6d23cc7e7c32d1a6aa1d2d4a4c94abe50c980126,fairseq/trainer.py,Trainer,save_checkpoint,#Trainer#Any#Any#,277

Before Change


            checkpoint_utils.save_state(
                filename,
                self.cfg,
                self.model.state_dict(),
                self.get_criterion(),
                self.optimizer,
                self.lr_scheduler,
                self.get_num_updates(),
                optim_history=self._optim_history,
                extra_state=extra_state,
                task=self.task,
            )
            logger.info(f"Finished saving checkpoint to {filename}")

After Change


            state_dict["last_optimizer_state"] = self.optimizer.state_dict()
        return state_dict

    def save_checkpoint(self, filename, extra_state):
        Save all training state in a checkpoint file.
        logger.info(f"Saving checkpoint to {filename}")
        // call state_dict on all ranks in case it needs internal communication
        state_dict = utils.move_to_cpu(self.state_dict())
        state_dict["extra_state"].update(extra_state)
        if self.should_save_checkpoint_on_current_rank:
            checkpoint_utils.torch_persistent_save(
                state_dict,
                filename,
                async_write=self.cfg.checkpoint.write_checkpoints_asynchronously,
            )
        logger.info(f"Finished saving checkpoint to {filename}")

    def load_checkpoint(
        self,
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: pytorch/fairseq
Commit Name: 6d23cc7e7c32d1a6aa1d2d4a4c94abe50c980126
Time: 2021-03-04
Author: myleott@fb.com
File Name: fairseq/trainer.py
Class Name: Trainer
Method Name: save_checkpoint


Project Name: kengz/SLM-Lab
Commit Name: 700780ace70cf3fb6b3f33fbf95241d9f7d48c20
Time: 2019-05-17
Author: kengzwl@gmail.com
File Name: slm_lab/agent/algorithm/actor_critic.py
Class Name: ActorCritic
Method Name: train


Project Name: Microsoft/nni
Commit Name: 73b2221b5eb4fd21802e6bf41e21d5df8ef9bf2c
Time: 2019-11-22
Author: v-yugzh@microsoft.com
File Name: src/sdk/pynni/nni/nas/pytorch/darts/trainer.py
Class Name: DartsTrainer
Method Name: train_one_epoch


Project Name: pytorch/fairseq
Commit Name: 6d23cc7e7c32d1a6aa1d2d4a4c94abe50c980126
Time: 2021-03-04
Author: myleott@fb.com
File Name: fairseq/trainer.py
Class Name: Trainer
Method Name: save_checkpoint