code
stringlengths
3
6.57k
value.new_zeros(value.size()
range(self.dp_world_size)
dist.all_gather(tensor_list, value, group=self.data_parallel_group)
module_state_dict(self, destination=None, prefix='', keep_vars=False)
self.module.state_dict(destination, prefix, keep_vars)
load_module_state_dict(self, state_dict, strict=True)
self.module.load_state_dict(state_dict, strict=strict)
_get_rank_zero_ckpt_name(self, checkpoints_path, tag, mp_rank, dp_rank)
format(dp_rank)
str(tag)
format(mp_rank)
_get_zero_ckpt_name(self, checkpoints_path, tag)
self.mpu.get_model_parallel_rank()
torch.distributed.get_rank(group=self.optimizer.dp_process_group)
self._get_rank_zero_ckpt_name(checkpoints_path, tag, mp_rank, pp_rank)
_get_ckpt_name(self, checkpoints_path, tag)
self.mpu.get_model_parallel_rank()
self.zero_optimization_partition_weights()
torch.distributed.get_rank(group=self.optimizer.dp_process_group)
str(tag)
format(mp_rank)
str(tag)
format(mp_rank)
os.path.join(load_dir, 'latest')
os.path.isfile(latest_path)
open(latest_path, 'r')
fd.read()
strip()
self.zero_optimization()
self._get_ckpt_name(load_dir, tag)
os.path.exists(load_path)
format(load_path)
logger.info(f'rank: {self.global_rank} loading checkpoint: {load_path}')
torch.load(load_path, map_location=lambda storage, loc: storage)
isinstance(self.module, PipelineModule)
os.path.join(load_dir, tag)
self.zero_optimization()
self.fp16_enabled()
self.optimizer.load_state_dict(checkpoint['optimizer'])
self.lr_scheduler.load_state_dict(checkpoint['lr_scheduler'])
self.train_batch_size()
checkpoint.items()
_load_zero_checkpoint(self, load_dir, tag, load_optimizer_states=True)
self._get_all_zero_checkpoints(load_dir, tag)
self.zero_load_from_fp32_weights()
len(zero_sd_list)
_get_mp_rank_zero_checkpoint_names(self, load_dir, tag, mp_rank, dp_world_size)
range(dp_world_size)
zero_ckpt_names.append(ckpt_name)
range(mp_world_size)
_get_all_zero_checkpoints(self, load_dir, tag)
self.mpu.get_model_parallel_rank()
enumerate(zero_ckpt_names)
os.path.exists(ckpt_name)
os.path.exists(ckpt_name_try)
invalid_zero_ckpt_paths.append(ckpt_name)
len(invalid_zero_ckpt_paths)
zero_sd_list.append(torch.load(ckpt_name, map_location='cpu')
len(zero_optimizer_sd)
_checkpoint_tag_validation(self, tag)
self.checkpoint_tag_validation_enabled()
hashlib.sha1(tag.encode()
torch.ByteTensor([s_hash.digest()
flatten()
to(self.device)
bhash.clone()
bhash.clone()
dist.all_reduce(max_bhash, op=torch.distributed.ReduceOp.MAX)
dist.all_reduce(min_bhash, op=torch.distributed.ReduceOp.MIN)
all(min_bhash == bhash)
all(max_bhash == bhash)
dist.get_rank()
self.checkpoint_tag_validation_fail()
logger.warning(msg)
save_checkpoint(self, save_dir, tag=None, client_state={}, save_latest=True)
self.zero_optimization_partition_weights()
state_dict()
self.optimizer.save_checkpoint_prologue()
os.makedirs(save_dir, exist_ok=True)
str(tag)
self._checkpoint_tag_validation(tag)
self._create_checkpoint_file(save_dir, tag, False)
self._save_checkpoint(save_dir, tag, client_state=client_state)
self._create_zero_checkpoint_files(save_dir, tag)
self._save_zero_checkpoint(save_dir, tag)
open(os.path.join(save_dir, 'latest')
fd.write(tag)
self.zero_optimization_partition_weights()
self.optimizer.save_checkpoint_epilogue()
_create_checkpoint_file(self, save_dir, tag, zero_checkpoint)
name_function(save_dir, tag)
ensure_directory_exists(checkpoint_name)
logger.error(f'Failed saving model checkpoint to {save_dir} with tag {tag}')
_create_zero_checkpoint_files(self, save_dir, tag)
range(self.world_size)
self._create_checkpoint_file(save_dir, tag, True)
dist.barrier()
_save_checkpoint(self, save_dir, tag, client_state={})
self._get_ckpt_name(save_dir, tag)
module_state_dict()