(self, load_dir, checkpoint_engine, strict=True)
| 580 | checkpoint_engine.save(final_state_dict, model_ckpt_path) |
| 581 | |
| 582 | def load_state_dir(self, load_dir, checkpoint_engine, strict=True): |
| 583 | for idx, layer in enumerate(self.forward_funcs): |
| 584 | # Functions, etc. will not have state_dicts |
| 585 | if not hasattr(layer, 'load_state_dict'): |
| 586 | continue |
| 587 | |
| 588 | # get all checkpoint files for the layer. |
| 589 | model_ckpt_list = self.ckpt_layer_path_list(load_dir, idx) |
| 590 | mp_rank = self._grid.get_slice_parallel_rank() |
| 591 | mp_world_size = self._grid.get_slice_parallel_world_size() |
| 592 | |
| 593 | sd_loader = SDLoaderFactory.get_sd_loader(model_ckpt_list, |
| 594 | version=2.0, |
| 595 | checkpoint_engine=checkpoint_engine) |
| 596 | load_path, checkpoint, _ = sd_loader.load(mp_world_size, mp_rank, module_key=None, is_pipe_parallel=True) |
| 597 | |
| 598 | layer.load_state_dict(checkpoint) |
| 599 | |
| 600 | # if self._grid.data_parallel_id == 0: |
| 601 | # logger.info( |
| 602 | # f'RANK={self.global_rank} Loaded layer={idx+self._local_start} file={load_path}' |
| 603 | # ) |
| 604 | |
| 605 | self._synchronize_tied_weights() |
| 606 | |
| 607 | def _is_checkpointable(self, funcs): |
| 608 | # This is an unfortunate hack related to torch and deepspeed activation checkpoint implementations. |
no test coverage detected