MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / load_state_dir

Method load_state_dir

deepspeed/runtime/pipe/module.py:582–605  ·  view source on GitHub ↗
(self, load_dir, checkpoint_engine, strict=True)

Source from the content-addressed store, hash-verified

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.

Callers 1

Calls 7

ckpt_layer_path_listMethod · 0.95
get_sd_loaderMethod · 0.80
loadMethod · 0.45
load_state_dictMethod · 0.45

Tested by

no test coverage detected