deepspeed

This commit is contained in:
游雁 2024-08-07 12:48:02 +08:00
parent 73c5196e97
commit 29fa4e4789

View File

@ -35,8 +35,7 @@ def load_pretrained_model(
logging.info(f"ckpt: {path}, use_deepspeed: {use_deepspeed}") logging.info(f"ckpt: {path}, use_deepspeed: {use_deepspeed}")
if oss_bucket is None: if use_deepspeed and os.path.isdir(path):
if use_deepspeed:
ckpt_dir = os.path.dirname(path) ckpt_dir = os.path.dirname(path)
ckpt_name = os.path.basename(path) ckpt_name = os.path.basename(path)
if os.path.exists(f"{ckpt_dir}/zero_to_fp32.py"): if os.path.exists(f"{ckpt_dir}/zero_to_fp32.py"):
@ -67,9 +66,6 @@ def load_pretrained_model(
else: else:
src_state = torch.load(path, map_location=map_location) src_state = torch.load(path, map_location=map_location)
else:
buffer = BytesIO(oss_bucket.get_object(path).read())
src_state = torch.load(buffer, map_location=map_location)
src_state = src_state["state_dict"] if "state_dict" in src_state else src_state src_state = src_state["state_dict"] if "state_dict" in src_state else src_state
src_state = src_state["model_state_dict"] if "model_state_dict" in src_state else src_state src_state = src_state["model_state_dict"] if "model_state_dict" in src_state else src_state